SyntaxHighlighter.st
changeset 680 ebc432c71aec
parent 678 da6c65951755
child 681 3add270b9c1e
--- a/SyntaxHighlighter.st	Tue Apr 07 09:55:22 1998 +0200
+++ b/SyntaxHighlighter.st	Tue Apr 07 09:57:39 1998 +0200
@@ -50,7 +50,8 @@
 !SyntaxHighlighter class methodsFor:'highlighting'!
 
 formatMethod:aString in:aClass
-    "format a method in a given class."
+    "format (recolor) a method in a given class.
+     Return the text containing font changes and color information."
 
     |parser tree text endPos|
 
@@ -60,19 +61,32 @@
     parser ignoreErrors.
     parser ignoreWarnings.
     parser sourceText:(text := aString string asText).
+    "/ use an array here - this can be changed much faster using #at:put:
+    text emphasisCollection:(Array new:aString size).
 
     tree := parser parseMethod.
+    "/ now, convert the emphasis-array to a runArray
+    text emphasisCollection:(text emphasis asRunArray).
+
     tree == #Error ifTrue:[
+        "/ mhmh - which is better ...
+        "/ alternative1: color rest after error in red
 "/        text 
 "/            emphasizeFrom:(parser sourceStream position) 
 "/            to:text size 
 "/            with:(#color->Color red).
+
+
+        "/ alternative2: take original emphasis for rest
+
         endPos := parser sourceStream position.
         endPos >= text size ifTrue:[
             ^ text
         ].
         ^ (text copyTo:endPos) , (aString copyFrom:(endPos+1))
-        
+
+        "/ alternative3: no emphasis for rest.
+
 "/        ^ text "/ aString
     ].
     ^ text
@@ -87,7 +101,7 @@
         in:UndefinedObject
     "
 
-    "Modified: / 3.4.1998 / 17:13:52 / cg"
+    "Modified: / 7.4.1998 / 09:57:19 / cg"
 ! !
 
 !SyntaxHighlighter methodsFor:'accessing'!
@@ -334,5 +348,5 @@
 !SyntaxHighlighter class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.8 1998-04-03 17:29:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.9 1998-04-07 07:57:39 cg Exp $'
 ! !