SmallSense__EditSupport.st
author Claus Gittinger
Wed, 26 Feb 2014 19:06:00 +0100
changeset 174 3e08d765d86f
parent 144 a43236d0c411
child 176 df6d3225d1e4
permissions -rw-r--r--
sync from current CVS head; fixed comment highlighting for STXEOLRule
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'jv:smallsense' }"
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: SmallSense }"
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Object subclass:#EditSupport
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
     6
	instanceVariableNames:'service codeView textView backspaceIsUndo completionController
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
     7
		snippets ignoreKeystrokes ignoreKeystrokesPosition'
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	classVariableNames:''
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	poolDictionaries:''
67
020b7461b15e Package structure reorganization.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 64
diff changeset
    10
	category:'SmallSense-Core-Services'
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
112
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
    13
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
!EditSupport class methodsFor:'instance creation'!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
forLanguage: aProgrammingLanguage
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    aProgrammingLanguage notNil ifTrue:[
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
        aProgrammingLanguage isSmalltalk ifTrue:[
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
            ^ SmalltalkEditSupport new
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
        ].
122
a0d62e942364 Oops, more fixes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 120
diff changeset
    21
        (aProgrammingLanguage askFor: #isJava) ifTrue:[    
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
            ^ JavaEditSupport new
122
a0d62e942364 Oops, more fixes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 120
diff changeset
    23
        ].
a0d62e942364 Oops, more fixes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 120
diff changeset
    24
        (aProgrammingLanguage askFor: #isGroovy) ifTrue:[    
a0d62e942364 Oops, more fixes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 120
diff changeset
    25
            ^ GroovyEditSupport new
a0d62e942364 Oops, more fixes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 120
diff changeset
    26
        ]  
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
    ].
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
    ^GenericEditSupport new.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
    "Created: / 24-07-2013 / 23:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
122
a0d62e942364 Oops, more fixes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 120
diff changeset
    32
    "Modified: / 04-10-2013 / 08:41:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
!EditSupport methodsFor:'accessing'!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    37
codeView
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    38
    ^ codeView
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    39
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    40
    "Created: / 21-01-2014 / 23:13:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    41
    "Modified: / 03-02-2014 / 23:28:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    42
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    43
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
language
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
    ^ self subclassResponsibility.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
    "Created: / 24-07-2013 / 23:44:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
service
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
    ^ service
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    52
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    53
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    54
textView
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    55
    ^ textView
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    56
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    57
    "Created: / 03-02-2014 / 23:28:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
120
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    60
!EditSupport methodsFor:'accessing-classes'!
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    61
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    62
completionEngineClass
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    63
    "Returns a code completion engine class or nil, of 
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    64
     no completion is supported"
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    65
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    66
    ^ nil
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    67
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    68
    "Created: / 03-10-2013 / 17:43:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    69
!
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    70
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    71
scannerClass
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    72
    "Returns a class to use for scanning lines. If nil, scanning is
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    73
     not supported and scanLine* methods will return an empty array."
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    74
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    75
    ^ nil
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    76
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    77
    "Created: / 22-10-2013 / 00:33:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
120
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    78
! !
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    79
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
!EditSupport methodsFor:'editing'!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    82
electricDeleteCharacterAtCol: col 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    83
    textView deleteCharAtLine: textView cursorLine col: col
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    84
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    85
    "Created: / 22-01-2014 / 21:17:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    86
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    87
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    88
electricDeleteCharacterAtLine:line col: col 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    89
    textView deleteCharAtLine: line col: col
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    90
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    91
    "Created: / 22-01-2014 / 21:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    92
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    93
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    94
electricDo:aBlock 
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    95
    textView completionSupport notNil ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    96
        (textView completionSupport)
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    97
            stopCompletionProcess;
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
    98
            closeCompletionView.
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
    99
    ].
89
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   100
    textView hasSelection ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   101
        textView undoableDo:[ textView deleteSelection ].
89
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   102
    ].
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   103
    textView undoableDo:[ aBlock value. ].
89
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   104
    backspaceIsUndo := true.
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   105
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   106
    "Created: / 17-09-2013 / 23:15:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   107
    "Modified: / 22-10-2013 / 03:15:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
89
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   108
!
8ff5fb2b27bf Improvement in (Smalltalk)EditSupport.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   109
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   110
electricInsert:text 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   111
    self electricInsert:text advanceCursorBy:nil.
135
f40d2ac07f38 Electric editing for Smalltalk: autoinsert space fter assignment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 134
diff changeset
   112
f40d2ac07f38 Electric editing for Smalltalk: autoinsert space fter assignment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 134
diff changeset
   113
    "Created: / 22-10-2013 / 11:08:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
f40d2ac07f38 Electric editing for Smalltalk: autoinsert space fter assignment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 134
diff changeset
   114
!
f40d2ac07f38 Electric editing for Smalltalk: autoinsert space fter assignment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 134
diff changeset
   115
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   116
electricInsert:stringOrLines advanceCursorBy:offsetOrNil 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   117
    ^ self 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   118
            electricInsert:stringOrLines
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   119
            advanceCursorBy:offsetOrNil
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   120
            ignoreKeystrokes:nil
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   121
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   122
    "Created: / 22-10-2013 / 11:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   123
    "Modified: / 19-01-2014 / 20:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   124
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   125
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   126
electricInsert:stringOrLines advanceCursorBy:offsetOrNil ignoreKeystrokes:ignoreKeystrokeSequence 
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   127
    "Insert given stringOrLines. If offsetOrNil is not nil, then
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   128
     move cursor by `offsetOrNil` after the **begining** of
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   129
     inserted text. If `ignoreKeystrokeSequence` is not nil and not empty, then if
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   130
     subsequent key strokes are ignored (i.e, does nothing) if matches
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   131
     the given sequence. This is used to avoid duplication if user is not
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   132
     aware of electric insertion and types whole text that has been
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   133
     (electrically) inserted).
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   134
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   135
     `stringOrLines` could be either string or collection of strings (lines)
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   136
     `offsetOrNil` could be either integer (cursor is then advanced by
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   137
            offsetOrNil characters after **begining** of inserted text)
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   138
            or point (x,y, cursor is then advanced by x lines after current
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   139
            line and by y characters after beggining of the inserted text
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   140
            (if x == 0) or at set at column y (if x ~~ 0)
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   141
     `ignoreKeystrokeSequence` a sequenceable collection of keys (in a form
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   142
            as passed to #keyPress:x:y: method."
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   143
    
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   144
    | lineOffset  colOffset  newCursorCol  newCursorLine  advanceCursor |
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   145
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   146
    advanceCursor := false.
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   147
    offsetOrNil notNil ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   148
        lineOffset := offsetOrNil isPoint ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   149
                offsetOrNil x
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   150
            ] ifFalse:[ 0 ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   151
        colOffset := offsetOrNil isPoint ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   152
                offsetOrNil y
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   153
            ] ifFalse:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   154
                offsetOrNil
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   155
            ].
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   156
        newCursorLine := textView cursorLine + lineOffset.
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   157
        newCursorCol := (lineOffset == 0 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   158
                ifTrue:[ textView cursorCol ]
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   159
                ifFalse:[ 0 ]) + colOffset.
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   160
        advanceCursor := true.
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   161
    ].
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   162
    self 
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   163
        electricDo:[
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   164
            stringOrLines isString ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   165
                "/ Simple strin
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   166
                textView insertStringAtCursor:stringOrLines.
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   167
            ] ifFalse:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   168
                "/ C
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   169
                textView insertLines:stringOrLines withCR:false.
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   170
            ].
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   171
            advanceCursor ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   172
                (textView cursorLine ~~ newCursorLine 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   173
                    or:[ textView cursorCol ~~ newCursorCol ]) 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   174
                        ifTrue:[ textView cursorLine:newCursorLine col:newCursorCol. ].
144
a43236d0c411 Indentation fixes for electric-inserted code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 139
diff changeset
   175
            ].
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   176
        ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   177
    ignoreKeystrokeSequence notEmptyOrNil ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   178
        ignoreKeystrokes := ignoreKeystrokeSequence.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   179
        ignoreKeystrokesPosition := 1.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   180
    ].
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   181
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   182
    "Created: / 19-01-2014 / 20:29:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   183
    "Modified: / 20-01-2014 / 09:24:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   184
    "Modified (format): / 22-01-2014 / 21:13:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   185
!
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   186
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   187
electricInsert:text ignoreKeystrokes:ignore 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   188
    self 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   189
        electricInsert:text
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   190
        advanceCursorBy:nil
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   191
        ignoreKeystrokes:ignore
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   192
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   193
    "Created: / 21-01-2014 / 23:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   194
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   195
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   196
electricInsertBlockOpenedBy:openText closedBy:closeText 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   197
    | indent  lines  autoIndent |
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   199
    textView completionSupport notNil ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   200
        (textView completionSupport)
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   201
            stopCompletionProcess;
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   202
            closeCompletionView.
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   203
    ].
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
    indent := self indentAtCursorLine.
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   205
    autoIndent := textView autoIndent.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   206
    textView autoIndent:false.
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   207
    [
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   208
        textView 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   209
            undoableDo:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   210
                lines := Array 
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   211
                        with:openText ? ''
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   212
                        with:''
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   213
                        with:((String new:indent withAll:Character space) , closeText).
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   214
                self electricInsert:lines advanceCursorBy:1 @ (indent + 5)
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   215
            ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   216
    ] ensure:[ textView autoIndent:autoIndent ].
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
    "Created: / 25-07-2013 / 10:41:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   219
    "Modified: / 22-01-2014 / 21:20:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   220
!
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   221
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   222
electricInsertSnippet
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   223
    ^ false
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   224
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   225
    "Created: / 22-10-2013 / 01:54:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   228
!EditSupport methodsFor:'event handling'!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   229
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
keyPress: key x:x y:y in: view
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
    "Handles an event in given view (a subview of codeView).
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
     If the method returns true, the event will not be processed
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   233
     by the view.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   234
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   235
     IMPORTANT: Never ever call `^ super keyPress: key x:x y:y in: view`,
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   236
     as keyPresIgnore... advances position and calling keyPressIgnore here
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   237
     and calling super would advance it twice!!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   238
     "
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   239
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   240
    view ~~ textView ifTrue:[ ^ false ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   241
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   242
    (self keyPressIgnored: key) ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   243
        ^ true.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   244
    ].
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   246
    key == Character space ifTrue:[
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   247
        ^ self electricInsertSnippet
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   248
    ].
109
59448a46a48f Completion refactoring (part 2).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 108
diff changeset
   249
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
    ^false
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
    "Created: / 24-07-2013 / 23:31:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   253
    "Modified (format): / 20-01-2014 / 09:20:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   254
!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   255
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   256
keyPressIgnored: key
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   257
    "raise an error: this method should be implemented (TODO)"
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   258
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   259
    ignoreKeystrokes notNil ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   260
        (ignoreKeystrokes at: ignoreKeystrokesPosition) == key ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   261
            "/ Key stroke should be ignored...
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   262
            ignoreKeystrokesPosition := ignoreKeystrokesPosition + 1.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   263
            ignoreKeystrokesPosition > ignoreKeystrokes size ifTrue:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   264
                "/ Nil out instvars if there's no more keys to ignore.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   265
                ignoreKeystrokes := ignoreKeystrokesPosition := nil.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   266
            ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   267
            ^ true.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   268
        ] ifFalse:[
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   269
            "/ Nil out instvars, user typed something else!!
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   270
            ignoreKeystrokes := ignoreKeystrokesPosition := nil.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   271
            ^ false.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   272
        ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   273
    ].
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   274
    ^ false.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   275
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   276
    "Created: / 20-01-2014 / 09:11:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   277
!
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   278
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   279
keyPressSpace
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   280
    ^ self electricInsertSnippet
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   281
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   282
    "Created: / 22-10-2013 / 01:43:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   283
! !
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   284
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   285
!EditSupport methodsFor:'initialization'!
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   286
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   287
initializeCompletion
120
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   288
    self completionEngineClass  notNil ifTrue:[
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   289
        completionController := CompletionController for: service textView.
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   290
        completionController support: self.
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   291
        service textView completionSupport: completionController.
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   292
    ].
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   293
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   294
    "Created: / 27-09-2013 / 13:20:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
120
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   295
    "Modified: / 03-10-2013 / 17:44:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   296
!
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   297
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   298
initializeForService:aSmallSenseService
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   299
    service := aSmallSenseService.
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   300
    codeView := aSmallSenseService codeView.
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   301
    textView := aSmallSenseService textView.
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   302
    backspaceIsUndo := false.
120
4fefce92f5bb Initial support for Java/Groovy completion and for mixed-language completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   303
    self initializeCompletion.
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   304
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   305
    "Created: / 27-09-2013 / 13:19:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   306
    "Modified: / 03-02-2014 / 23:28:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   307
! !
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   308
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   309
!EditSupport methodsFor:'private'!
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   310
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   311
indentAtCursorLine
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
    | line |
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   314
    line := service textView listAt: service textView cursorLine.
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
    ^ line isNil ifTrue:[
139
bf1538a4e7ce Fixed off-by-one bug when computing indent level for closing curly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 137
diff changeset
   316
        (service textView cursorCol - 1) max: 0.
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
    ] ifFalse:[
139
bf1538a4e7ce Fixed off-by-one bug when computing indent level for closing curly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 137
diff changeset
   318
        (line indexOfNonSeparator - 1) max: 0.
64
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   319
    ]
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   320
2257d7223898 All classes moved to namespace SmallSense.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   321
    "Created: / 25-07-2013 / 00:13:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
bf1538a4e7ce Fixed off-by-one bug when computing indent level for closing curly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 137
diff changeset
   322
    "Modified: / 25-10-2013 / 18:04:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   323
!
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   324
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   325
wordBeforeCursor
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   326
    | currentLine wordStart wordEnd |
132
7c23c51d2cfd Completion insertion refactoring.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 122
diff changeset
   327
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   328
    currentLine := textView list at: textView cursorLine.
109
59448a46a48f Completion refactoring (part 2).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 108
diff changeset
   329
    currentLine isNil ifTrue:[ ^ '' ].
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   330
    wordEnd := textView cursorCol - 1.
110
5ee9a90dbed5 Bug/UX fixes for autocomplete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   331
    wordEnd > currentLine size ifTrue:[ ^ '' ].
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   332
    wordEnd ~~ 0 ifTrue:[
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   333
        wordStart := wordEnd.
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   334
        [ wordStart > 0 and:[(currentLine at: wordStart) isAlphaNumeric] ] whileTrue:[
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   335
            wordStart := wordStart - 1.
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   336
        ].
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   337
        wordStart := wordStart + 1.
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   338
        wordStart <= wordEnd ifTrue:[
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   339
            ^ currentLine copyFrom: wordStart to: wordEnd.
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   340
        ].
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   341
    ].
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   342
    ^ ''
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   343
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   344
    "Created: / 27-09-2013 / 15:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
132
7c23c51d2cfd Completion insertion refactoring.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 122
diff changeset
   345
    "Modified: / 17-10-2013 / 00:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   346
! !
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   347
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   348
!EditSupport methodsFor:'private-completion'!
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   349
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   350
computeCompletion
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   351
    | completionEngineClass codeView result |
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   352
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   353
    completionEngineClass := self completionEngineClass.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   354
    completionEngineClass isNil ifTrue: [ ^ nil ].
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   355
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   356
    codeView := service codeView.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   357
    UserInformation 
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   358
        handle: [:ex | 
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   359
            codeView showInfo: (ex messageText).
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   360
            ex proceed.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   361
        ]
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   362
        do: [
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   363
            | context |
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   364
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   365
            context := CompletionContext new.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   366
            context support: self.
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   367
            result := completionEngineClass new complete: context
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   368
        ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   369
    ^ result.
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   370
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 115
diff changeset
   371
    "Created: / 27-09-2013 / 13:21:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
174
3e08d765d86f sync from current CVS head; fixed comment highlighting for STXEOLRule
Claus Gittinger
parents: 144
diff changeset
   372
    "Modified: / 21-01-2014 / 23:17:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
108
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   373
! !
71471dc81e77 Completion refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 100
diff changeset
   374
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   375
!EditSupport methodsFor:'private-scanning'!
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   376
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   377
scanLineAt: lineNumber 
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   378
    "Scans line at given line number.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   379
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   380
     Returns and array of tokens, **excluding** EOF. Each token is represented
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   381
     by four subsequent items in the array: token type, token value, start position, end position.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   382
     Thus, returned array size is always multiple of 4."
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   383
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   384
    ^ self scanLineAt: lineNumber using: self scannerClass
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   385
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   386
    "Created: / 22-10-2013 / 00:34:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   387
!
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   388
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   389
scanLineAt: lineNumber using: scannerClass
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   390
    "Scans line at given line number using given scanner class.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   391
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   392
     Returns and array of tokens, **excluding** EOF. Each token is represented
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   393
     by four subsequent items in the array: token type, token value, start position, end position.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   394
     Thus, returned array size is always multiple of 4."
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   395
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   396
    | line scanner token tokenLastEndPosition |
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   397
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   398
    scannerClass isNil ifTrue:[ ^ #() ].
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   399
    line := (service textView listAt: service textView cursorLine).
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   400
    line isNil ifTrue:[ ^ #() ].
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   401
    scanner := scannerClass for: line string.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   402
    tokenLastEndPosition := 0.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   403
    ^ OrderedCollection streamContents:[:tokens |
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   404
        [
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   405
            [ token := scanner nextToken.token ~~ #EOF ] whileTrue:[
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   406
                tokens 
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   407
                    nextPut: token; 
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   408
                    nextPut: (scanner tokenName notNil ifTrue:[scanner tokenName] ifFalse:[ scanner tokenValue printString ]); 
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   409
                    nextPut: scanner tokenStartPosition;
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   410
                    nextPut: (tokenLastEndPosition := scanner tokenEndPosition).
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   411
            ].
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   412
        ] on: Error do:[
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   413
                tokens 
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   414
                    nextPut: 'Error'; 
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   415
                    nextPut: (line copyFrom: tokenLastEndPosition + 1 to: line size); 
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   416
                    nextPut: tokenLastEndPosition + 1;
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   417
                    nextPut: line size.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   418
        ].
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   419
    ].
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   420
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   421
    "Created: / 22-10-2013 / 00:31:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
137
12232e62cf54 Fixes in electring snippets (both in API and Smalltalk snippets)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 135
diff changeset
   422
    "Modified: / 22-10-2013 / 12:01:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
134
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   423
!
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   424
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   425
scanLineAtCursor
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   426
    "Scans current cursor line.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   427
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   428
     Returns and array of tokens, **excluding** EOF. Each token is represented
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   429
     by four subsequent items in the array: token type, token value, start position, end position.
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   430
     Thus, returned array size is always multiple of 4."
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   431
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   432
    ^ self scanLineAt: service codeView textView cursorLine using: self scannerClass
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   433
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   434
    "Created: / 22-10-2013 / 00:34:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   435
! !
e34ee6ceb7c8 Initial support for "electric snippets".
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 132
diff changeset
   436
112
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   437
!EditSupport class methodsFor:'documentation'!
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   438
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   439
version_HG
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   440
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   441
    ^ '$Changeset: <not expanded> $'
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   442
! !
5c8f0eb0dd55 UX fixes for completion: do not close the completionwindow then pressing Ctrl-space
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 110
diff changeset
   443