Fix #10: Add Carp highlighter for AbstractFileReference
This commit is contained in:
31
src/Carp/AbstractFileReference.extension.st
Normal file
31
src/Carp/AbstractFileReference.extension.st
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
Extension { #name : #AbstractFileReference }
|
||||||
|
|
||||||
|
{ #category : #'*Carp' }
|
||||||
|
AbstractFileReference >> gtCarpFor: aView [
|
||||||
|
|
||||||
|
<gtView>
|
||||||
|
self isFile ifFalse: [ ^ aView empty ].
|
||||||
|
self path extension = 'carp' ifFalse: [ ^ aView empty ].
|
||||||
|
[ self readStreamDo: [ :s | s next: 1000 ] ]
|
||||||
|
on: ZnInvalidUTF8
|
||||||
|
do: [ ^ aView empty ].
|
||||||
|
^ aView explicit
|
||||||
|
title: 'Carp' translated;
|
||||||
|
priority: 50;
|
||||||
|
stencil: [
|
||||||
|
(GtCarpCoderModel code: self contents) asElement matchParent ];
|
||||||
|
actionStencil: [ :tab |
|
||||||
|
BrButton new
|
||||||
|
aptitude: BrGlamorousButtonWithIconAptitude;
|
||||||
|
label: 'Save';
|
||||||
|
icon: BrGlamorousVectorIcons accept;
|
||||||
|
action: [
|
||||||
|
| newContents |
|
||||||
|
newContents := tab viewContentElement children first children
|
||||||
|
second children first children first editor text asString.
|
||||||
|
(self fullName , '.backup') asFileReference ensureDelete.
|
||||||
|
self copyTo: (self fullName , '.backup') asFileReference.
|
||||||
|
self
|
||||||
|
ensureDelete;
|
||||||
|
writeStreamDo: [ :s | s nextPutAll: newContents ] ] ]
|
||||||
|
]
|
@@ -9,7 +9,7 @@ Class {
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
CarpExpression >> asElement [
|
CarpExpression >> asElement [
|
||||||
^ (GtCarpCoderModel new sourceCode: (GtCoderExplicitStringSource new source: self toCarp)) asElement
|
^ (GtCarpCoderModel code: self toCarp) asElement
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@@ -8,6 +8,13 @@ Class {
|
|||||||
#category : #'Carp-Coder'
|
#category : #'Carp-Coder'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #'instance creation' }
|
||||||
|
GtCarpCoderModel class >> code: aString [
|
||||||
|
|
||||||
|
^ self new sourceCode:
|
||||||
|
(GtCoderExplicitStringSource new source: aString)
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #converting }
|
{ #category : #converting }
|
||||||
GtCarpCoderModel >> asCoderViewModel [
|
GtCarpCoderModel >> asCoderViewModel [
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user