"{ Package: 'jv:smallsense' }"
"{ NameSpace: SmallSense }"
Object subclass:#EditSupport
instanceVariableNames:'service textView'
classVariableNames:''
poolDictionaries:''
category:'SmallSense-Core-Services'
!
!EditSupport class methodsFor:'instance creation'!
forLanguage: aProgrammingLanguage
aProgrammingLanguage notNil ifTrue:[
aProgrammingLanguage isSmalltalk ifTrue:[
^ SmalltalkEditSupport new
].
aProgrammingLanguage isJava ifTrue:[
^ JavaEditSupport new
]
].
^GenericEditSupport new.
"Created: / 24-07-2013 / 23:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 04-08-2013 / 02:06:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!EditSupport methodsFor:'accessing'!
language
^ self subclassResponsibility.
"Created: / 24-07-2013 / 23:44:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
service
^ service
!
service:aSmallSenseService
service := aSmallSenseService.
textView := aSmallSenseService textView.
"Modified: / 25-07-2013 / 00:11:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!EditSupport methodsFor:'editing'!
insertElectricBlockOpenedBy: openText closedBy: closeText
| line col indent |
indent := self indentAtCursorLine.
textView undoableDo:[
textView insertStringAtCursor: (openText ? '') , Character cr , Character cr, (String new:indent withAll:Character space) , closeText , Character cr.
line := textView cursorLine - 1.
col := textView cursorCol + 3.
textView cursorLine: line col: col.
].
"Created: / 25-07-2013 / 10:41:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 04-08-2013 / 02:15:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!EditSupport methodsFor:'event handling'!
doKeyPressKeyComplete
"Not supported in generic edit support"
textView flash.
^ true
"Created: / 04-08-2013 / 02:31:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
keyPress: key x:x y:y in: view
"Handles an event in given view (a subview of codeView).
If the method returns true, the event will not be processed
by the view."
key == #CodeCompletion ifTrue: [
^ self doKeyPressKeyComplete.
].
^false
"Created: / 24-07-2013 / 23:31:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 04-08-2013 / 02:32:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!EditSupport methodsFor:'private'!
indentAtCursorLine
| line |
line := service textView listAt: service textView cursorLine.
^ line isNil ifTrue:[
service textView cursorCol - 1.
] ifFalse:[
line indexOfNonSeparator - 1.
]
"Created: / 25-07-2013 / 00:13:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 04-08-2013 / 02:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !