268 "/ First, check if the cursor is at the end of line, i.e., if |
268 "/ First, check if the cursor is at the end of line, i.e., if |
269 "/ there's no text after the cursor... |
269 "/ there's no text after the cursor... |
270 lineNr := textView cursorLine. |
270 lineNr := textView cursorLine. |
271 line := textView listAt: lineNr. |
271 line := textView listAt: lineNr. |
272 i := line size. |
272 i := line size. |
273 [ i > 0 and:[ (c := line at:i) isSeparator ] ] whileTrue:[ i := i - 1 ]. |
273 i >= textView cursorCol ifTrue:[ |
274 i <= textView cursorCol ifFalse:[ |
274 [ i > 0 and:[ (c := line at:i) isSeparator ] ] whileTrue:[ i := i - 1 ]. |
275 "/ If not, do not indent... |
275 i <= textView cursorCol ifFalse:[ |
276 ^ false |
276 "/ If not, do not indent... |
|
277 ^ false |
|
278 ]. |
277 ]. |
279 ]. |
278 |
280 |
279 "/ Search for closest non-empty line above |
281 "/ Search for closest non-empty line above |
280 lineNr := textView cursorLine. |
282 lineNr := textView cursorLine. |
281 line := textView listAt: lineNr. |
283 [ lineNr > 0 and:[ (line := textView list at: lineNr ifAbsent:[nil]) isEmptyOrNil ] ] whileTrue:[ lineNr := lineNr - 1 ]. |
282 [ line isEmptyOrNil and:[lineNr > 0 ] ] whileTrue:[ lineNr := lineNr - 1 ]. |
|
283 lineNr == 0 ifTrue:[ |
284 lineNr == 0 ifTrue:[ |
284 "/ No such line found, givin up |
285 "/ No such line found, givin up |
285 ^ false. |
286 ^ false. |
286 ]. |
287 ]. |
287 indent := line indexOfNonSeparator. |
288 indent := line indexOfNonSeparator. |
296 textView cursorCol: indent. |
297 textView cursorCol: indent. |
297 ]. |
298 ]. |
298 ^ true |
299 ^ true |
299 |
300 |
300 "Created: / 13-08-2014 / 15:30:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
301 "Created: / 13-08-2014 / 15:30:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
301 "Modified: / 31-03-2015 / 13:30:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
302 "Modified: / 04-05-2015 / 00:17:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
302 ! ! |
303 ! ! |
303 |
304 |
304 !JavaEditSupport methodsFor:'initialization'! |
305 !JavaEditSupport methodsFor:'initialization'! |
305 |
306 |
306 initializeForService: anEditService |
307 initializeForService: anEditService |