151 tree := parser "expression"statementList. |
151 tree := parser "expression"statementList. |
152 "/ now, convert the emphasis-array to a runArray |
152 "/ now, convert the emphasis-array to a runArray |
153 text emphasisCollection:(text emphasis asRunArray). |
153 text emphasisCollection:(text emphasis asRunArray). |
154 |
154 |
155 tree == #Error ifTrue:[ |
155 tree == #Error ifTrue:[ |
156 "/ mhmh - which is better ... |
156 "/ mhmh - which is better ... |
157 "/ alternative1: color rest after error in red |
157 "/ alternative1: color rest after error in red |
158 "/ text |
158 "/ text |
159 "/ emphasizeFrom:(parser sourceStream position) |
159 "/ emphasizeFrom:(parser sourceStream position) |
160 "/ to:text size |
160 "/ to:text size |
161 "/ with:(#color->Color red). |
161 "/ with:(#color->Color red). |
162 |
162 |
163 |
163 |
164 "/ alternative2: take original emphasis for rest |
164 "/ alternative2: take original emphasis for rest |
165 |
165 |
166 endPos := parser sourceStream position1Based. |
166 endPos := parser sourceStream position+1. |
167 endPos >= text size ifTrue:[ |
167 endPos >= text size ifTrue:[ |
168 ^ text |
168 ^ text |
169 ]. |
169 ]. |
170 ^ ((text copyTo:endPos) , (aString copyFrom:(endPos+1))). |
170 ^ ((text copyTo:endPos) , (aString copyFrom:(endPos+1))). |
171 |
171 |
172 "/ alternative3: no emphasis for rest. |
172 "/ alternative3: no emphasis for rest. |
173 |
173 |
174 "/ ^ text "/ aString |
174 "/ ^ text "/ aString |
175 ]. |
175 ]. |
176 ^ text |
176 ^ text |
177 |
177 |
178 " |
178 " |
179 self |
179 self |
180 formatExpression:'(1 + 2) max:5' |
180 formatExpression:'(1 + 2) max:5' |
181 in:UndefinedObject |
181 in:UndefinedObject |
182 " |
182 " |
183 |
183 |
184 "Created: / 25-07-2010 / 08:56:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
184 "Created: / 25-07-2010 / 08:56:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
185 "Modified: / 25-07-2010 / 10:57:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
185 "Modified: / 25-07-2010 / 10:57:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
186 "Modified: / 02-01-2018 / 20:02:34 / stefan" |
186 ! |
187 ! |
187 |
188 |
188 formatMethod:aString in:aClass using:preferencesOrNil elementsInto: elements |
189 formatMethod:aString in:aClass using:preferencesOrNil elementsInto: elements |
189 "format (recolor) a method in a given class. |
190 "format (recolor) a method in a given class. |
190 Return the text containing font changes and color information." |
191 Return the text containing font changes and color information." |