--- a/SyntaxHighlighter.st Fri Sep 10 12:59:11 2004 +0200
+++ b/SyntaxHighlighter.st Wed Sep 15 13:36:33 2004 +0200
@@ -114,7 +114,26 @@
"format (recolor) a method in a given class.
Return the text containing font changes and color information."
- |parser tree text endPos eColor|
+ ^ self formatMethod:aString in:aClass using:nil
+
+ "
+ self
+ formatMethod:'foo
+ ^ self bar:''hello''.
+
+ ' , (Character doubleQuote asString) , 'some comment' , (Character doubleQuote asString) , '
+'
+ in:UndefinedObject
+ "
+
+ "Modified: / 23.10.1998 / 22:48:45 / cg"
+!
+
+formatMethod:aString in:aClass using:preferencesOrNil
+ "format (recolor) a method in a given class.
+ Return the text containing font changes and color information."
+
+ |highlighter tree text endPos eColor|
aString isNil ifTrue:[^ nil].
@@ -123,14 +142,15 @@
"/ ex suspendedContext fullPrintAll.
^ aString
] do:[
- parser := self for:(ReadStream on:aString string) in:aClass.
- parser ignoreErrors:true.
- parser ignoreWarnings:true.
- parser sourceText:(text := aString string asText).
+ highlighter := self for:(ReadStream on:aString string) in:aClass.
+ preferencesOrNil notNil ifTrue:[highlighter preferences:preferencesOrNil].
+ highlighter ignoreErrors:true.
+ highlighter ignoreWarnings:true.
+ highlighter 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.
+ tree := highlighter parseMethod.
"/ now, convert the emphasis-array to a runArray
text emphasisCollection:(text emphasis asRunArray).
@@ -140,13 +160,13 @@
"/ mhmh - which is better ...
"/ alternative1: color rest after error in red
text
- emphasizeFrom:(parser sourceStream position1Based)
+ emphasizeFrom:(highlighter sourceStream position1Based)
to:text size
with:(#color->eColor).
] ifFalse:[
"/ alternative2: take original emphasis for rest
- endPos := parser sourceStream position1Based.
+ endPos := highlighter sourceStream position1Based.
endPos >= text size ifTrue:[
^ text
].
@@ -171,6 +191,10 @@
!SyntaxHighlighter methodsFor:'accessing'!
+preferences:something
+ preferences := something.
+!
+
sourceText
"return the value of the instance variable 'sourceText' (automatically generated)"
@@ -313,7 +337,10 @@
markFrom:pos1 to:pos2
withEmphasis:(preferences commentEmphasis) color:(preferences commentColor)
- "Modified: / 31.3.1998 / 18:01:55 / cg"
+ "
+ UserPreferences current commentEmphasis
+ "
+ "Modified: / 31.3.1998 / 18:01:55 / cg"
!
markConstantFrom:pos1 to:pos2
@@ -598,5 +625,5 @@
!SyntaxHighlighter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.45 2004-06-30 15:23:24 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/SyntaxHighlighter.st,v 1.46 2004-09-15 11:36:33 cg Exp $'
! !