Tools__CodeNavigationService.st
changeset 12913 c5fdb1a82ed1
parent 12867 03a18d91ded1
child 12930 658aaa9b2245
equal deleted inserted replaced
12912:64879653709c 12913:c5fdb1a82ed1
   259     "/ if I show a quick senders/implementors menu, eat this event
   259     "/ if I show a quick senders/implementors menu, eat this event
   260     ^ menuShown notNil
   260     ^ menuShown notNil
   261 !
   261 !
   262 
   262 
   263 isQuickMenuModifierPressed
   263 isQuickMenuModifierPressed
       
   264     |sensor|
       
   265 
       
   266     sensor := textView sensor.
   264     UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[
   267     UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[
   265         ^ textView sensor ctrlDown
   268         ^ sensor ctrlDown
   266     ].
   269     ].
   267     ^ textView sensor metaDown
   270     ^ sensor metaDown
   268 !
   271 !
   269 
   272 
   270 isQuickMenuModifierReleased
   273 isQuickMenuModifierReleased
       
   274     |sensor|
       
   275 
       
   276     sensor := textView sensor.
   271     UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[
   277     UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[
   272         ^ textView sensor ctrlDown not
   278         ^ sensor ctrlDown not
   273     ].
   279     ].
   274     ^ textView sensor metaDown not
   280     ^ sensor metaDown not
   275 !
   281 !
   276 
   282 
   277 keyPress:key x:x y:y in:view 
   283 keyPress:key x:x y:y in:view 
   278     "Handles an event in given view (a subview of codeView).
   284     "Handles an event in given view (a subview of codeView).
   279      If the method returns true, it has eaten the event and it will not be processed
   285      If the method returns true, it has eaten the event and it will not be processed
   300 "/        codeView reallyModified "textView modified" ifTrue:[
   306 "/        codeView reallyModified "textView modified" ifTrue:[
   301 "/            self highlightClear. 
   307 "/            self highlightClear. 
   302 "/            codeView syntaxElements: nil.
   308 "/            codeView syntaxElements: nil.
   303 "/            ^ false
   309 "/            ^ false
   304 "/        ].
   310 "/        ].
   305          (key == #CursorRight
   311 
   306             or:[key == #CursorDown
   312         view sensor metaDown ifTrue:[
   307             or:[key == #CursorLeft
   313             (key == #CursorRight or:[key == #CursorDown]) ifTrue:[
   308             or:[key == #CursorUp]]]) ifTrue:[   
   314                 view sensor pushUserEvent:#findNextVariableFromCursor for:self.
   309             view sensor pushUserEvent:#highlightVariableAtCursor for:self .
   315             ] ifFalse:[
       
   316                 view sensor pushUserEvent:#findPreviousVariableFromCursor for:self.
       
   317             ]
   310         ] ifFalse:[
   318         ] ifFalse:[
   311             view sensor pushUserEvent:#highlightClear for:self .
   319             (key == #CursorRight
       
   320               or:[key == #CursorDown
       
   321               or:[key == #CursorLeft
       
   322               or:[key == #CursorUp]]]
       
   323             ) ifTrue:[
       
   324                 view sensor pushUserEvent:#highlightVariableAtCursor for:self .
       
   325             ] ifFalse:[
       
   326                 view sensor pushUserEvent:#highlightClear for:self .
       
   327             ]
   312         ]
   328         ]
   313 
       
   314     ].
   329     ].
   315     ^ false
   330     ^ false
   316 
   331 
   317     "Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   332     "Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   318     "Modified: / 05-09-2011 / 05:17:30 / cg"
   333     "Modified: / 05-09-2011 / 05:17:30 / cg"
   329     (view == textView and:[textView isQuickMenuModifierReleased]) ifTrue:[
   344     (view == textView and:[textView isQuickMenuModifierReleased]) ifTrue:[
   330         "/    (view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[
   345         "/    (view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[
   331         "/ because it is delegated, the position is not correct
   346         "/ because it is delegated, the position is not correct
   332         ev := WindowGroup lastEventQuerySignal query.
   347         ev := WindowGroup lastEventQuerySignal query.
   333         p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view.
   348         p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view.
   334         self highlightClear. 
   349  "/       self highlightClear. 
   335 "/        view sensor pushUserEvent:#highlightClear for:self. 
   350 "/        view sensor pushUserEvent:#highlightClear for:self. 
   336         ^ false "/ true -- do not eat the event
   351         ^ false "/ true -- do not eat the event
   337     ].
   352     ].
   338     ^ false
   353     ^ false
   339 
   354 
   394     characterPosition := textView characterPositionOfLine:line col:col.
   409     characterPosition := textView characterPositionOfLine:line col:col.
   395     syntaxElements := codeView syntaxElements.
   410     syntaxElements := codeView syntaxElements.
   396     syntaxElements isEmptyOrNil ifTrue:[
   411     syntaxElements isEmptyOrNil ifTrue:[
   397         ^ nil.
   412         ^ nil.
   398     ].
   413     ].
   399     index := syntaxElements indexForInserting:characterPosition.
   414     0"1" to:0 by:-1 do:[:d |
   400     index > syntaxElements size ifTrue:[^nil].
   415         index := (syntaxElements indexForInserting:characterPosition) - d.
   401     element := syntaxElements at:index ifAbsent:nil.
   416         index > syntaxElements size ifTrue:[^nil].
   402     element notNil ifTrue:[
   417         element := syntaxElements at:index ifAbsent:nil.
   403         (characterPosition between: element start - 1 and: element stop) ifTrue:[^element].
   418         element notNil ifTrue:[
       
   419             (characterPosition between: element start - 1 and: element stop) ifTrue:[^element].
       
   420         ].
   404     ].
   421     ].
   405     ^nil
   422     ^nil
   406 
   423 
   407     "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   424     "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   408     "Modified: / 21-08-2011 / 11:03:29 / cg"
   425     "Modified: / 21-08-2011 / 11:03:29 / cg"
   552 !
   569 !
   553 
   570 
   554 highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol
   571 highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol
   555     |line start end|
   572     |line start end|
   556 
   573 
   557     (lineNo between:startLine and:endLine) ifFalse:[
   574     (lineNo between:startLine and:endLine) ifFalse:[ ^ self ].
   558         ^ self
       
   559     ].
       
   560     line := textView listAt:lineNo.
   575     line := textView listAt:lineNo.
   561     line isEmpty ifTrue:[^self].
   576     line isEmpty ifTrue:[^self].
   562     start := lineNo = startLine ifTrue:[
   577     start := (lineNo = startLine) 
   563                 startCol
   578                 ifTrue:[ startCol  ] 
   564             ] ifFalse:[
   579                 ifFalse:[ line indexOfNonSeparator ].
   565                 line indexOfNonSeparator
   580     end := (lineNo = endLine) 
   566             ].
   581                 ifTrue:[ endCol ] 
   567     end := lineNo = endLine ifTrue:[
   582                 ifFalse:[ line size ].
   568                 endCol
       
   569             ] ifFalse:[ line size ].
       
   570     line 
   583     line 
   571         emphasisFrom:(start max: 1)
   584         emphasisFrom:(start max: 1)
   572         to:(end min: line size)
   585         to:(end min: line size)
   573         add: currentEmphasis.
   586         add: currentEmphasis.
       
   587 
   574     linesToRedraw add: lineNo.
   588     linesToRedraw add: lineNo.
   575 
   589 
   576     "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   590     "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   577     "Modified: / 08-07-2011 / 13:02:51 / cg"
   591     "Modified: / 08-07-2011 / 13:02:51 / cg"
   578     "Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   592     "Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   617     "Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   631     "Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   618 !
   632 !
   619 
   633 
   620 highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol 
   634 highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol 
   621 
   635 
   622     textView list keysAndValuesDo:
   636     textView list keysAndValuesDo: [:lineNo :line|
   623         [:lineNo :line|
   637         line isText ifTrue: [
   624         |start end|
   638             self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol
   625         line isText ifTrue:
   639         ]
   626             [self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]].
   640     ].
   627 
   641 
   628     "Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   642     "Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   629 ! !
   643 ! !
   630 
   644 
   631 !CodeNavigationService methodsFor:'redrawing'!
   645 !CodeNavigationService methodsFor:'redrawing'!
   641 ! !
   655 ! !
   642 
   656 
   643 !CodeNavigationService class methodsFor:'documentation'!
   657 !CodeNavigationService class methodsFor:'documentation'!
   644 
   658 
   645 version
   659 version
   646     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.23 2013-06-06 17:41:36 cg Exp $'
   660     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.24 2013-06-14 14:34:43 cg Exp $'
   647 !
   661 !
   648 
   662 
   649 version_CVS
   663 version_CVS
   650     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.23 2013-06-06 17:41:36 cg Exp $'
   664     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.24 2013-06-14 14:34:43 cg Exp $'
   651 !
   665 !
   652 
   666 
   653 version_SVN
   667 version_SVN
   654     ^ '$Id: Tools__CodeNavigationService.st,v 1.23 2013-06-06 17:41:36 cg Exp $'
   668     ^ '$Id: Tools__CodeNavigationService.st,v 1.24 2013-06-14 14:34:43 cg Exp $'
   655 ! !
   669 ! !
   656 
   670