syntax highlighting
authorClaus Gittinger <cg@exept.de>
Tue, 31 Mar 1998 20:02:29 +0200
changeset 1516 91b6f64b56e6
parent 1515 293aa84c6b80
child 1517 b0160018704c
syntax highlighting
BrowserView.st
BrwsrView.st
--- a/BrowserView.st	Mon Mar 30 23:21:48 1998 +0200
+++ b/BrowserView.st	Tue Mar 31 20:02:29 1998 +0200
@@ -20,7 +20,7 @@
 		lockUpdates autoSearch myLabel acceptClass lastSourceLogMessage
 		lastCategory lastModule lastPackage lastMethodMoveClass
 		namespaceList allNamespaces gotClassList classList selectorList
-		showAllNamespaces classInstVarsInVarList'
+		showAllNamespaces classInstVarsInVarList coloringProcess'
 	classVariableNames:'CheckForInstancesWhenRemovingClasses RememberAspect DefaultIcon
 		StopIcon TraceIcon TimeIcon CanvasIcon MenuIcon ImageIcon
 		TabListIcon HierarchicalListIcon TableColumnsIcon HelpIcon
@@ -8852,6 +8852,16 @@
 
 !BrowserView methodsFor:'misc'!
 
+codeChanged
+    codeView modified ifTrue:[
+        codeView modified:false.
+        self startSyntaxHighlightProcess.
+    ]
+
+    "Created: / 31.3.1998 / 14:25:29 / cg"
+    "Modified: / 31.3.1998 / 19:03:49 / cg"
+!
+
 instanceProtocol:aBoolean
     "switch between instance and class protocol"
 
@@ -8933,8 +8943,52 @@
     "Modified: 23.4.1996 / 21:39:24 / cg"
 !
 
+startSyntaxHighlightProcess
+    |oldCodeList|
+
+    coloringProcess notNil ifTrue:[
+        coloringProcess terminate.
+        coloringProcess := nil.
+    ].
+    currentMethod isNil ifTrue:[^ self].
+
+    oldCodeList := codeView list.
+
+    coloringProcess := [
+        |oldCode oldEmp code cls selStartLine selStartCol selEndLine selEndCol|
+
+        oldCode := oldCodeList asString.
+        oldEmp := oldCode emphasis.
+        code := oldCode string.
+        cls := actualClass.
+        
+"/ Transcript showCR:'-------1|'; show:oldCode; showCR:'|'.
+        code := SyntaxHighlighter formatMethod:code in:cls.
+"/ Transcript showCR:'-------2|'; show:code; showCR:'|'.
+        code emphasis ~= oldEmp ifTrue:[
+            Processor activeProcess withPriority:(Processor activePriority + 2) do:[
+                selStartLine := codeView selectionStartLine.
+                selStartCol := codeView selectionStartCol.
+                selEndLine := codeView selectionEndLine.
+                selEndCol := codeView selectionEndCol.
+                codeView setContents:code.
+                selStartLine notNil ifTrue:[
+                    codeView selectFromLine:selStartLine col:selStartCol
+                                     toLine:selEndLine col:selEndCol
+                ]
+            ].
+        ].
+        coloringProcess := nil.
+    ] forkAt:(Processor userBackgroundPriority).
+
+    "Created: / 31.3.1998 / 14:25:29 / cg"
+    "Modified: / 31.3.1998 / 19:03:12 / cg"
+!
+
 updateCodeView
-    |code sourceLineNumber|
+    |code sourceLineNumber doStartSyntax|
+
+    codeView modifiedChannel retractInterestsFor:self.
 
     aspect == #hierarchy ifTrue:[
         ^ self classHierarchy
@@ -9005,11 +9059,24 @@
 
 "'.
                 codeView acceptAction:[:text | nil].
-            ].
+            ] ifFalse:[
+                UserPreferences current syntaxColoring ifTrue:[
+                    code size < 1000 ifTrue:[       
+                        code := SyntaxHighlighter formatMethod:code in:actualClass.
+                        codeView modifiedChannel onChangeSend:#codeChanged to:self.
+                    ] ifFalse:[
+                        doStartSyntax := true.
+                    ]
+                ]
+            ]
         ]
     ].
     codeView contents:code.
     codeView modified:false.
+    doStartSyntax == true ifTrue:[
+        self startSyntaxHighlightProcess.
+        codeView modifiedChannel onChangeSend:#codeChanged to:self.
+    ].
     sourceLineNumber notNil ifTrue:[
     sourceLineNumber ~~ 1 ifTrue:[
             codeView gotoLine:sourceLineNumber.
@@ -9021,8 +9088,8 @@
     ].
     self normalLabel.
 
-    "Created: 23.11.1995 / 14:16:43 / cg"
-    "Modified: 30.7.1997 / 16:16:10 / cg"
+    "Created: / 23.11.1995 / 14:16:43 / cg"
+    "Modified: / 31.3.1998 / 19:08:01 / cg"
 ! !
 
 !BrowserView methodsFor:'namespace menu'!
@@ -11338,6 +11405,6 @@
 !BrowserView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.375 1998-03-20 15:31:08 tz Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.376 1998-03-31 18:02:29 cg Exp $'
 ! !
 BrowserView initialize!
--- a/BrwsrView.st	Mon Mar 30 23:21:48 1998 +0200
+++ b/BrwsrView.st	Tue Mar 31 20:02:29 1998 +0200
@@ -20,7 +20,7 @@
 		lockUpdates autoSearch myLabel acceptClass lastSourceLogMessage
 		lastCategory lastModule lastPackage lastMethodMoveClass
 		namespaceList allNamespaces gotClassList classList selectorList
-		showAllNamespaces classInstVarsInVarList'
+		showAllNamespaces classInstVarsInVarList coloringProcess'
 	classVariableNames:'CheckForInstancesWhenRemovingClasses RememberAspect DefaultIcon
 		StopIcon TraceIcon TimeIcon CanvasIcon MenuIcon ImageIcon
 		TabListIcon HierarchicalListIcon TableColumnsIcon HelpIcon
@@ -8852,6 +8852,16 @@
 
 !BrowserView methodsFor:'misc'!
 
+codeChanged
+    codeView modified ifTrue:[
+        codeView modified:false.
+        self startSyntaxHighlightProcess.
+    ]
+
+    "Created: / 31.3.1998 / 14:25:29 / cg"
+    "Modified: / 31.3.1998 / 19:03:49 / cg"
+!
+
 instanceProtocol:aBoolean
     "switch between instance and class protocol"
 
@@ -8933,8 +8943,52 @@
     "Modified: 23.4.1996 / 21:39:24 / cg"
 !
 
+startSyntaxHighlightProcess
+    |oldCodeList|
+
+    coloringProcess notNil ifTrue:[
+        coloringProcess terminate.
+        coloringProcess := nil.
+    ].
+    currentMethod isNil ifTrue:[^ self].
+
+    oldCodeList := codeView list.
+
+    coloringProcess := [
+        |oldCode oldEmp code cls selStartLine selStartCol selEndLine selEndCol|
+
+        oldCode := oldCodeList asString.
+        oldEmp := oldCode emphasis.
+        code := oldCode string.
+        cls := actualClass.
+        
+"/ Transcript showCR:'-------1|'; show:oldCode; showCR:'|'.
+        code := SyntaxHighlighter formatMethod:code in:cls.
+"/ Transcript showCR:'-------2|'; show:code; showCR:'|'.
+        code emphasis ~= oldEmp ifTrue:[
+            Processor activeProcess withPriority:(Processor activePriority + 2) do:[
+                selStartLine := codeView selectionStartLine.
+                selStartCol := codeView selectionStartCol.
+                selEndLine := codeView selectionEndLine.
+                selEndCol := codeView selectionEndCol.
+                codeView setContents:code.
+                selStartLine notNil ifTrue:[
+                    codeView selectFromLine:selStartLine col:selStartCol
+                                     toLine:selEndLine col:selEndCol
+                ]
+            ].
+        ].
+        coloringProcess := nil.
+    ] forkAt:(Processor userBackgroundPriority).
+
+    "Created: / 31.3.1998 / 14:25:29 / cg"
+    "Modified: / 31.3.1998 / 19:03:12 / cg"
+!
+
 updateCodeView
-    |code sourceLineNumber|
+    |code sourceLineNumber doStartSyntax|
+
+    codeView modifiedChannel retractInterestsFor:self.
 
     aspect == #hierarchy ifTrue:[
         ^ self classHierarchy
@@ -9005,11 +9059,24 @@
 
 "'.
                 codeView acceptAction:[:text | nil].
-            ].
+            ] ifFalse:[
+                UserPreferences current syntaxColoring ifTrue:[
+                    code size < 1000 ifTrue:[       
+                        code := SyntaxHighlighter formatMethod:code in:actualClass.
+                        codeView modifiedChannel onChangeSend:#codeChanged to:self.
+                    ] ifFalse:[
+                        doStartSyntax := true.
+                    ]
+                ]
+            ]
         ]
     ].
     codeView contents:code.
     codeView modified:false.
+    doStartSyntax == true ifTrue:[
+        self startSyntaxHighlightProcess.
+        codeView modifiedChannel onChangeSend:#codeChanged to:self.
+    ].
     sourceLineNumber notNil ifTrue:[
     sourceLineNumber ~~ 1 ifTrue:[
             codeView gotoLine:sourceLineNumber.
@@ -9021,8 +9088,8 @@
     ].
     self normalLabel.
 
-    "Created: 23.11.1995 / 14:16:43 / cg"
-    "Modified: 30.7.1997 / 16:16:10 / cg"
+    "Created: / 23.11.1995 / 14:16:43 / cg"
+    "Modified: / 31.3.1998 / 19:08:01 / cg"
 ! !
 
 !BrowserView methodsFor:'namespace menu'!
@@ -11338,6 +11405,6 @@
 !BrowserView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Attic/BrwsrView.st,v 1.375 1998-03-20 15:31:08 tz Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Attic/BrwsrView.st,v 1.376 1998-03-31 18:02:29 cg Exp $'
 ! !
 BrowserView initialize!