EditTextView.st
changeset 6613 745a9c495c42
parent 6612 dd61bcd8d7da
child 6614 228cd1c3eac9
equal deleted inserted replaced
6612:dd61bcd8d7da 6613:745a9c495c42
  6100                 (endsWithOpeningBracket value:leftPart) ifTrue:[
  6100                 (endsWithOpeningBracket value:leftPart) ifTrue:[
  6101                     newIndent := i.  "/ leftIndentForLine already adjusted the value if ending in an opening bracket
  6101                     newIndent := i.  "/ leftIndentForLine already adjusted the value if ending in an opening bracket
  6102                 ] ifFalse:[
  6102                 ] ifFalse:[
  6103                     (false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[
  6103                     (false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[
  6104                         newIndent := (self prevTabBefore:i)-1.
  6104                         newIndent := (self prevTabBefore:i)-1.
  6105                     ].
  6105                     ] ifFalse:[
       
  6106                         newIndent := i.  "/ leftIndentForLine returns the previous line's indent
       
  6107                     ]
  6106                 ].
  6108                 ].
  6107             ] ifFalse:[
  6109             ] ifFalse:[
  6108                 (endsWithOpeningBracket value:leftPart) ifTrue:[
  6110                 (endsWithOpeningBracket value:leftPart) ifTrue:[
  6109                     rightPart notEmptyOrNil ifTrue:[
  6111                     rightPart notEmptyOrNil ifTrue:[
  6110                         newIndent := (self nextTabAfter:i+1)-1.
  6112                         newIndent := (self nextTabAfter:i+1)-1.
  6130             self cursorCol:(newIndent+1 max:1)
  6132             self cursorCol:(newIndent+1 max:1)
  6131         ]
  6133         ]
  6132     ].
  6134     ].
  6133 
  6135 
  6134     "Created: / 26-06-2019 / 21:57:50 / Claus Gittinger"
  6136     "Created: / 26-06-2019 / 21:57:50 / Claus Gittinger"
       
  6137     "Modified: / 26-06-2019 / 23:01:52 / Claus Gittinger"
  6135 !
  6138 !
  6136 
  6139 
  6137 keyPress:key x:x y:y
  6140 keyPress:key x:x y:y
  6138     "handle keyboard input"
  6141     "handle keyboard input"
  6139 
  6142 
  6491 
  6494 
  6492     |line lnr indent 
  6495     |line lnr indent 
  6493      endsWithOpeningBracket endsWithClosingBracket bracketStrings language|
  6496      endsWithOpeningBracket endsWithClosingBracket bracketStrings language|
  6494 
  6497 
  6495     endsWithOpeningBracket := endsWithClosingBracket := [:line | false].
  6498     endsWithOpeningBracket := endsWithClosingBracket := [:line | false].
  6496     (language := self editedLanguage) notNil ifTrue:[
  6499     language := self editedLanguage ? SmalltalkLanguage instance.
  6497         bracketStrings := language bracketStrings ? #().
  6500 
  6498         endsWithOpeningBracket := 
  6501     bracketStrings := language bracketStrings ? #().
  6499             [:line |
  6502     endsWithOpeningBracket := 
  6500                 bracketStrings contains:[:pair | line endsWith:(pair first)].
  6503         [:line |
  6501             ].
  6504             bracketStrings contains:[:pair | line endsWith:(pair first)].
  6502         endsWithClosingBracket := 
  6505         ].
  6503             [:line |
  6506     endsWithClosingBracket := 
  6504                 bracketStrings contains:[:pair | line endsWith:(pair second)].
  6507         [:line |
  6505             ].
  6508             bracketStrings contains:[:pair | line endsWith:(pair second)].
  6506     ]. 
  6509         ].
  6507 
  6510 
  6508     lnr := lineNr.
  6511     lnr := lineNr.
  6509     [lnr > 1] whileTrue:[        
  6512     [lnr > 1] whileTrue:[        
  6510         lnr  := lnr - 1.
  6513         lnr  := lnr - 1.
  6511         line := self listAt:lnr.
  6514         line := self listAt:lnr.
  6512 
  6515 
  6513         line notEmptyOrNil ifTrue:[
  6516         line notEmptyOrNil ifTrue:[
  6514             indent := (line indexOfNonSeparatorStartingAt:1) - 1.
  6517             indent := (line indexOfNonSeparatorStartingAt:1) - 1.
  6515             indent >= 0 ifTrue:[
  6518             indent >= 0 ifTrue:[
  6516                 (self editedLanguage isNil or:[self editedLanguage isSmalltalk]) ifTrue:[
  6519                 (endsWithOpeningBracket value:line) ifTrue:[
  6517                     (endsWithOpeningBracket value:line) ifTrue:[
  6520                     "/ ^ indent + 4
  6518                         "/ ^ indent + 4
  6521                     ^ (self nextTabAfter:indent+1)-1
  6519                         ^ (self nextTabAfter:indent+1)-1
       
  6520                     ].
       
  6521                     (endsWithClosingBracket value:line) ifTrue:[
       
  6522                         "/ ^ indent - 4
       
  6523                         ^ (self prevTabBefore:indent)-1
       
  6524                     ].
       
  6525                 ].
  6522                 ].
       
  6523                 "/ no, not with kr indentation style
       
  6524                 "/ (endsWithClosingBracket value:line) ifTrue:[
       
  6525                 "/     "/ ^ indent - 4
       
  6526                 "/     ^ (self prevTabBefore:indent)-1
       
  6527                 "/ ].
  6526                 ^ indent
  6528                 ^ indent
  6527             ]
  6529             ]
  6528         ]
  6530         ]
  6529     ].
  6531     ].
  6530     ^ 0
  6532     ^ 0
  6531 
  6533 
  6532     "Created: / 05-03-1996 / 14:58:53 / cg"
  6534     "Created: / 05-03-1996 / 14:58:53 / cg"
  6533     "Modified (format): / 25-04-2017 / 12:57:44 / cg"
  6535     "Modified (format): / 25-04-2017 / 12:57:44 / cg"
  6534     "Modified: / 26-06-2019 / 22:48:34 / Claus Gittinger"
  6536     "Modified: / 26-06-2019 / 23:05:47 / Claus Gittinger"
  6535 !
  6537 !
  6536 
  6538 
  6537 undentBy4
  6539 undentBy4
  6538     self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4.
  6540     self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4.
  6539 
  6541