Add highlighting to current nesting level in Carp highlighter
This commit is contained in:
27
src/Carp/CarpApplication.class.st
Normal file
27
src/Carp/CarpApplication.class.st
Normal file
@@ -0,0 +1,27 @@
|
||||
Class {
|
||||
#name : #CarpApplication,
|
||||
#superclass : #LanguageLinkApplication,
|
||||
#instVars : [
|
||||
'uniqueInstance'
|
||||
],
|
||||
#category : #'Carp-LanguageLink'
|
||||
}
|
||||
|
||||
{ #category : #'start-stop' }
|
||||
CarpApplication class >> start [
|
||||
|
||||
^ self startWith: LanguageLinkSettings jsDefaultSettings.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpApplication >> baseApplication [
|
||||
^ CarpApplication
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpApplication >> initializeHandlers [
|
||||
loggingHandler := LanguageLinkLoggingHandler application: self.
|
||||
communicationHandler := LanguageLinkCommunicationHandler application: self.
|
||||
processHandler := LanguageLinkServerHandler application: self.
|
||||
"executionHandler := CarpExecutionHandler application: self"
|
||||
]
|
88
src/Carp/CarpStylerUtilities.class.st
Normal file
88
src/Carp/CarpStylerUtilities.class.st
Normal file
@@ -0,0 +1,88 @@
|
||||
Class {
|
||||
#name : #CarpStylerUtilities,
|
||||
#superclass : #Object,
|
||||
#category : #'Carp-Styler'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpStylerUtilities class >> colorAndHighlightParenthesesLeft: aLeftIndex right: aRightIndex atNestingLevel: aNestingLevel inText: aText [
|
||||
self
|
||||
highlightParenthesesLeft: aLeftIndex
|
||||
right: aRightIndex
|
||||
inText: aText.
|
||||
self
|
||||
colorParenthesesLeft: aLeftIndex
|
||||
right: aRightIndex
|
||||
atNestingLevel: aNestingLevel
|
||||
inText: aText
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpStylerUtilities class >> colorParenthesesLeft: aLeftIndex right: aRightIndex atNestingLevel: aNestingLevel inText: aText [
|
||||
| color |
|
||||
color := self parenthesesColorAt: aNestingLevel.
|
||||
(aText
|
||||
from: aLeftIndex
|
||||
to: aLeftIndex)
|
||||
foreground: color.
|
||||
(aText
|
||||
from: aRightIndex
|
||||
to: aRightIndex)
|
||||
foreground: color
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpStylerUtilities class >> highlightParenthesesLeft: aLeftIndex right: aRightIndex inText: aText [
|
||||
| theParanthesesMarker cursorEnterAction cursorLeaveAction |
|
||||
|
||||
theParanthesesMarker := BrTextInvisibleMarkerAttribute new.
|
||||
aText
|
||||
attribute: theParanthesesMarker
|
||||
from: aLeftIndex
|
||||
to: aRightIndex.
|
||||
|
||||
cursorEnterAction := [ :aTextEditor |
|
||||
aTextEditor text
|
||||
findAttribute: theParanthesesMarker
|
||||
indicesDo: [ :aParanthesesStart :aParanthesesEnd |
|
||||
aTextEditor text
|
||||
attribute: (GtPharoParenthesesHighlightAttribute paint: BrGlamorousColors neutralBackgroundColor)
|
||||
from: aParanthesesStart
|
||||
to: aParanthesesEnd ] ].
|
||||
|
||||
cursorLeaveAction := [ :aTextEditor |
|
||||
aTextEditor text
|
||||
findAttribute: theParanthesesMarker
|
||||
indicesDo: [ :aParanthesesStart :aParanthesesEnd |
|
||||
(aTextEditor text
|
||||
from: aParanthesesStart
|
||||
to: aParanthesesEnd)
|
||||
clearAttributesOfClass: GtPharoParenthesesHighlightAttribute ] ].
|
||||
|
||||
(aText
|
||||
from: aLeftIndex
|
||||
to: aLeftIndex)
|
||||
onCursorEnter: cursorEnterAction
|
||||
leave: cursorLeaveAction.
|
||||
|
||||
(aText
|
||||
from: aRightIndex
|
||||
to: aRightIndex)
|
||||
onCursorEnter: cursorEnterAction
|
||||
leave: cursorLeaveAction
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpStylerUtilities class >> parenthesesColorAt: anIndex [
|
||||
| colors |
|
||||
colors := self parenthesesColors.
|
||||
^ colors at: (anIndex - 1) \\ colors size + 1
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
CarpStylerUtilities class >> parenthesesColors [
|
||||
| colors |
|
||||
colors := BrGlamorousColors distinctTenStrongColors allButFirst allButLast
|
||||
collect: [ :each | each twiceDarker ].
|
||||
^ colors
|
||||
]
|
Reference in New Issue
Block a user