Tools__CodeNavigationService.st
changeset 13564 05ed2f6a11ab
parent 13561 14ca499f0ca4
child 13613 066908b0c801
child 13699 462794004446
--- a/Tools__CodeNavigationService.st	Wed Sep 18 15:45:33 2013 +0200
+++ b/Tools__CodeNavigationService.st	Wed Sep 18 16:20:55 2013 +0200
@@ -293,11 +293,37 @@
 !
 
 findNextVariableFromCursor
+    | currentElement nextElement |
+
+    codeView hasSelection ifTrue:[
+        currentElement := self elementAtLine: textView selectionStartLine col: textView selectionStartCol.
+    ] ifFalse:[
+        currentElement := codeView syntaxElementSelection.
+    ].
+    currentElement isVariable ifTrue:[
+        nextElement := currentElement next.
+        nextElement notNil ifTrue:[
+            textView selectFrom: nextElement start to: nextElement stop. 
+        ]
+    ]
 
     "Created: / 18-09-2013 / 13:15:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 findPreviousVariableFromCursor
+    | currentElement prevElement |
+
+    codeView hasSelection ifTrue:[
+        currentElement := self elementAtLine: textView selectionStartLine col: textView selectionStartCol.
+    ] ifFalse:[
+        currentElement := codeView syntaxElementSelection.
+    ].
+    currentElement isVariable ifTrue:[
+        prevElement := currentElement prev.
+        prevElement notNil ifTrue:[
+            textView selectFrom: prevElement start to: prevElement stop. 
+        ]
+    ]
 
     "Created: / 18-09-2013 / 13:15:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
@@ -355,29 +381,32 @@
 "/            ^ false
 "/        ].
 
-        sensor metaDown ifTrue:[
-            (key == #CursorRight or:[key == #CursorDown]) ifTrue:[
-                sensor pushUserEvent:#findNextVariableFromCursor for:self.
-            ] ifFalse:[(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
-                sensor pushUserEvent:#findPreviousVariableFromCursor for:self.
-            ]].
+
+        (key == #FocusNext) ifTrue:[
+            sensor pushUserEvent:#findNextVariableFromCursor for:self.            
+            ^ true.
+        ].
+        (key == #FocusPrevious) ifTrue:[
+            sensor pushUserEvent:#findPreviousVariableFromCursor for:self.
+            ^ true.
+        ].
+
+        (key == #CursorRight
+          or:[key == #CursorDown
+          or:[key == #CursorLeft
+          or:[key == #CursorUp]]]
+        ) ifTrue:[
+            sensor pushUserEvent:#highlightVariableAtCursor for:self .
         ] ifFalse:[
-            (key == #CursorRight
-              or:[key == #CursorDown
-              or:[key == #CursorLeft
-              or:[key == #CursorUp]]]
-            ) ifTrue:[
-                sensor pushUserEvent:#highlightVariableAtCursor for:self .
-            ] ifFalse:[
-                "/ sensor pushUserEvent:#highlightClear for:self .
-            ]
+            "/ sensor pushUserEvent:#highlightClear for:self .
         ]
+
     ].
     ^ false
 
     "Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 05-09-2011 / 05:17:30 / cg"
-    "Modified: / 27-09-2011 / 19:24:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-09-2013 / 15:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 keyRelease: key x:x y:y in: view
@@ -771,14 +800,14 @@
 !CodeNavigationService class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.38 2013-09-18 13:24:31 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.39 2013-09-18 14:20:55 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.38 2013-09-18 13:24:31 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.39 2013-09-18 14:20:55 vrany Exp $'
 !
 
 version_SVN
-    ^ '$Id: Tools__CodeNavigationService.st,v 1.38 2013-09-18 13:24:31 vrany Exp $'
+    ^ '$Id: Tools__CodeNavigationService.st,v 1.39 2013-09-18 14:20:55 vrany Exp $'
 ! !