Tools__CodeNavigationService.st
branchjv
changeset 13178 c9bf900fe729
parent 13173 e9da2324940d
parent 12997 f03191d56013
child 13179 b5d9725e479a
--- a/Tools__CodeNavigationService.st	Mon Jul 01 12:31:33 2013 +0100
+++ b/Tools__CodeNavigationService.st	Mon Jul 01 22:15:23 2013 +0100
@@ -28,9 +28,11 @@
 "{ NameSpace: Tools }"
 
 CodeViewService subclass:#CodeNavigationService
-	instanceVariableNames:'selectorEmphasis variableEmphasis currentEmphasis linesToRedraw
-		menuShown'
-	classVariableNames:'DefaultVariableEmphasis DefaultSelectorEmphasis'
+	instanceVariableNames:'selectorEmphasis variableEmphasis currentEmphasis
+		currentEmphasisForAssign linesToRedraw menuShown
+		assignmentEmphasis'
+	classVariableNames:'DefaultVariableEmphasis DefaultSelectorEmphasis
+		DefaultAssignmentEmphasis'
 	poolDictionaries:''
 	category:'Interface-CodeView'
 !
@@ -85,6 +87,13 @@
 
 !CodeNavigationService class methodsFor:'accessing - defaults'!
 
+defaultAssignmentEmphasis
+    DefaultAssignmentEmphasis isNil ifTrue:[
+        ^ Array with:(#backgroundColor -> (UserPreferences current assignmentBackgroundColorForNavigationService))
+    ].
+    ^ DefaultAssignmentEmphasis
+!
+
 defaultSelectorEmphasis
     DefaultSelectorEmphasis isNil ifTrue:[
         ^ Array with:(#backgroundColor -> (UserPreferences current selectorBackgroundColorForNavigationService))
@@ -418,11 +427,29 @@
     super initialize.
     selectorEmphasis := self class defaultSelectorEmphasis.
     variableEmphasis := self class defaultVariableEmphasis.
+    assignmentEmphasis := self class defaultAssignmentEmphasis.
     linesToRedraw := OrderedCollection new.
 
     "Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!CodeNavigationService methodsFor:'misc'!
+
+highlightInstanceVariable:name
+    |element|
+
+    element := (codeView syntaxElements ? #()) 
+                    detect:[:e |     
+                        e isVariable
+                        and:[ e isInstanceVariable
+                        and:[ e name = name ]]
+                    ] ifNone:nil.
+
+    self highlightClear.
+    codeView syntaxElementSelection:nil.
+    self highlightVariable:element.
+! !
+
 !CodeNavigationService methodsFor:'private'!
 
 elementAtCursor
@@ -507,12 +534,18 @@
 highlightClear: redraw
 
     codeView syntaxElementSelection == nil ifTrue:[ ^ self ].
+
     textView list isNil ifTrue:[ ^ self ].
     textView list withIndexDo:[:line :lineNo | 
         line isText ifTrue:[ 
             (line hasEmphasis: currentEmphasis) ifTrue:[
                 line emphasisAllRemove:currentEmphasis.
                 linesToRedraw add: lineNo.
+            ] ifFalse:[
+                (currentEmphasisForAssign notNil and:[line hasEmphasis: currentEmphasisForAssign]) ifTrue:[
+                    line emphasisAllRemove:currentEmphasisForAssign.
+                    linesToRedraw add: lineNo.
+                ]
             ]
         ] 
     ].
@@ -526,19 +559,30 @@
 !
 
 highlightElement:element 
-    |e|
+    |e savedEmphasis currentSelection|
 
-    codeView syntaxElementSelection == element ifTrue:[ ^ self ]. "/ no change
-    codeView syntaxElementSelection notNil ifTrue:[
+    (currentSelection := codeView syntaxElementSelection) == element ifTrue:[ ^ self ]. "/ no change
+    currentSelection notNil ifTrue:[
         self highlightClear: false.
     ].
 
-    currentEmphasis := self highlighEmphasisFor:element.
+    currentEmphasis := savedEmphasis := self highlighEmphasisFor:element.
+    currentEmphasisForAssign := nil.
+
     element notNil ifTrue:[ 
         codeView syntaxElementSelection:element.
         e := element firstElementInChain.
         [ e notNil ] whileTrue:[ 
-            self highlightWithoutClearFrom:e start to:e stop.
+            e assigned ifTrue:[
+                [
+                    currentEmphasis := currentEmphasisForAssign := assignmentEmphasis.
+                    self highlightWithoutClearFrom:e start to:e stop.
+                ] ensure:[
+                    currentEmphasis := savedEmphasis.
+                ].
+            ] ifFalse:[
+                self highlightWithoutClearFrom:e start to:e stop.
+            ].
             e := e nextElement 
         ].
     ].
@@ -603,6 +647,7 @@
     |line start end|
 
     (lineNo between:startLine and:endLine) ifFalse:[ ^ self ].
+
     line := textView listAt:lineNo.
     line isEmpty ifTrue:[^self].
     start := (lineNo = startLine) 
@@ -611,21 +656,29 @@
     end := (lineNo = endLine) 
                 ifTrue:[ endCol ] 
                 ifFalse:[ line size ].
+    line setRuns:(line runs asArray).
+    "/ JV: CG commented following and added the commtent code below.
+    "/     however, this clear all other emphasis like bold, color and so on!!
     line 
         emphasisFrom:(start max: 1)
         to:(end min: line size)
         add: currentEmphasis.
+"/    line 
+"/        emphasizeFrom:(start max: 1)
+"/        to:(end min: line size)
+"/        with: currentEmphasis.
+    line setRuns:(line runs asRunArray).                              
 
     linesToRedraw add: lineNo.
 
     "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 08-07-2011 / 13:02:51 / cg"
-    "Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-07-2013 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-highlightVariable:e 
-    (e notNil and:[ e isVariableOrSelf ]) ifTrue:[
-        self highlightElement:e.
+highlightVariable:element 
+    (element notNil and:[ element isVariableOrSelf ]) ifTrue:[
+        self highlightElement:element.
     ] ifFalse:[
         self highlightClear.
     ].
@@ -679,7 +732,7 @@
     linesToRedraw do:[:lineNo|
         textView invalidateLine: lineNo.
     ].
-    linesToRedraw := OrderedCollection new: 1
+    linesToRedraw := OrderedCollection new
 
     "Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (format): / 18-08-2011 / 16:01:34 / cg"
@@ -688,11 +741,11 @@
 !CodeNavigationService class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.25 2013-06-19 11:18:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.28 2013-06-24 19:44:05 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.25 2013-06-19 11:18:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.28 2013-06-24 19:44:05 cg Exp $'
 !
 
 version_HG
@@ -701,6 +754,6 @@
 !
 
 version_SVN
-    ^ '$Id: Tools__CodeNavigationService.st,v 1.25 2013-06-19 11:18:22 stefan Exp $'
+    ^ '$Id: Tools__CodeNavigationService.st,v 1.28 2013-06-24 19:44:05 cg Exp $'
 ! !