EditTextView.st
changeset 6614 228cd1c3eac9
parent 6613 745a9c495c42
child 6620 d1af1ea90691
equal deleted inserted replaced
6613:745a9c495c42 6614:228cd1c3eac9
  1017     "Created: / 14.2.1997 / 16:44:01 / cg"
  1017     "Created: / 14.2.1997 / 16:44:01 / cg"
  1018     "Modified: / 30.1.1998 / 14:20:15 / cg"
  1018     "Modified: / 30.1.1998 / 14:20:15 / cg"
  1019 !
  1019 !
  1020 
  1020 
  1021 autoIndent
  1021 autoIndent
       
  1022     ^ autoIndent value
       
  1023 
       
  1024     "Modified: / 26-06-2019 / 23:16:17 / Claus Gittinger"
       
  1025 !
       
  1026 
       
  1027 autoIndent:aBoolean
       
  1028     autoIndent value: aBoolean
       
  1029 
       
  1030     "Created: / 05-03-1996 / 14:37:50 / cg"
       
  1031     "Modified: / 26-06-2019 / 23:19:24 / Claus Gittinger"
       
  1032 !
       
  1033 
       
  1034 autoIndentHolder
  1022     ^ autoIndent
  1035     ^ autoIndent
  1023 !
  1036 
  1024 
  1037     "Created: / 26-06-2019 / 23:16:24 / Claus Gittinger"
  1025 autoIndent:aBoolean
       
  1026     autoIndent := aBoolean
       
  1027 
       
  1028     "Created: 5.3.1996 / 14:37:50 / cg"
       
  1029 !
  1038 !
  1030 
  1039 
  1031 codeAspectHolder
  1040 codeAspectHolder
  1032     ^ codeAspectHolder
  1041     ^ codeAspectHolder
  1033 !
  1042 !
  3427     |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
  3436     |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
  3428 
  3437 
  3429     list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete.
  3438     list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete.
  3430     
  3439     
  3431     wasOn := self hideCursor.
  3440     wasOn := self hideCursor.
  3432     (autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[
  3441     (self autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[
  3433         prevTab := (self prevTabBefore:cursorCol) max:1.
  3442         prevTab := (self prevTabBefore:cursorCol) max:1.
  3434         ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''.
  3443         ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''.
  3435         ln size < prevTab ifTrue:[
  3444         ln size < prevTab ifTrue:[
  3436             ln := ln , (String new:prevTab).
  3445             ln := ln , (String new:prevTab).
  3437         ].
  3446         ].
  3458                 ^  self.
  3467                 ^  self.
  3459             ]
  3468             ]
  3460         ].
  3469         ].
  3461     ].
  3470     ].
  3462 
  3471 
  3463 "/        (autoIndent
  3472 "/        (self autoIndent 
  3464 "/    and:[cursorCol  ~~ 1
  3473 "/    and:[cursorCol  ~~ 1
  3465 "/    and:[cursorLine <= (list size)]])
  3474 "/    and:[cursorLine <= (list size)]])
  3466 "/     ifTrue:[
  3475 "/     ifTrue:[
  3467 "/        soCol := (self leftIndentForLine:cursorLine) + 1.
  3476 "/        soCol := (self leftIndentForLine:cursorLine) + 1.
  3468 "/
  3477 "/
  3501         ]
  3510         ]
  3502     ].
  3511     ].
  3503     wasOn ifTrue:[ self showCursor ]
  3512     wasOn ifTrue:[ self showCursor ]
  3504 
  3513 
  3505     "Modified: / 16-01-1998 / 22:33:04 / cg"
  3514     "Modified: / 16-01-1998 / 22:33:04 / cg"
  3506     "Modified: / 24-03-2019 / 09:57:57 / Claus Gittinger"
  3515     "Modified: / 26-06-2019 / 23:19:59 / Claus Gittinger"
  3507 !
  3516 !
  3508 
  3517 
  3509 deleteCharsAtLine:lineNr fromCol:colNr
  3518 deleteCharsAtLine:lineNr fromCol:colNr
  3510     "delete characters from colNr up to the end in line lineNr"
  3519     "delete characters from colNr up to the end in line lineNr"
  3511 
  3520 
  4543 !
  4552 !
  4544 
  4553 
  4545 withAutoIndent:aBoolean do:aBlock
  4554 withAutoIndent:aBoolean do:aBlock
  4546     |sav|
  4555     |sav|
  4547 
  4556 
  4548     sav := autoIndent.
  4557     sav := self autoIndent.
  4549     autoIndent := aBoolean.
  4558     self autoIndent:aBoolean.
  4550     aBlock ensure:[ autoIndent := sav ].
  4559     aBlock ensure:[ self autoIndent:sav ].
       
  4560 
       
  4561     "Modified: / 26-06-2019 / 23:18:17 / Claus Gittinger"
  4551 !
  4562 !
  4552 
  4563 
  4553 withoutRedrawAt:lineNr put:aString
  4564 withoutRedrawAt:lineNr put:aString
  4554     "replace a line at lineNr"
  4565     "replace a line at lineNr"
  4555 
  4566 
  4914     ].
  4925     ].
  4915     leftPart := self listAt:lineNr.
  4926     leftPart := self listAt:lineNr.
  4916 
  4927 
  4917     leftPart isNil ifTrue:[
  4928     leftPart isNil ifTrue:[
  4918         leftPart := ''.
  4929         leftPart := ''.
  4919         autoIndent ifTrue:[
  4930         self autoIndent ifTrue:[
  4920             "/ cg: only do this, if the second line has no indent
  4931             "/ cg: only do this, if the second line has no indent
  4921             (i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[
  4932             (i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[
  4922                 leftPart := String new:(self leftIndentForLine:lineNr)
  4933                 leftPart := String new:(self leftIndentForLine:lineNr)
  4923             ]
  4934             ]
  4924         ]
  4935         ]
  4942         self deleteLine:nextLineNr
  4953         self deleteLine:nextLineNr
  4943     ]
  4954     ]
  4944 
  4955 
  4945     "Created: / 09-09-1997 / 09:27:38 / cg"
  4956     "Created: / 09-09-1997 / 09:27:38 / cg"
  4946     "Modified: / 25-04-2017 / 12:41:20 / cg"
  4957     "Modified: / 25-04-2017 / 12:41:20 / cg"
       
  4958     "Modified: / 26-06-2019 / 23:19:41 / Claus Gittinger"
  4947 !
  4959 !
  4948 
  4960 
  4949 basicReplace:aCharacter atLine:lineNr col:colNr
  4961 basicReplace:aCharacter atLine:lineNr col:colNr
  4950     "replace a single character at lineNr/colNr"
  4962     "replace a single character at lineNr/colNr"
  4951 
  4963 
  5638         ].
  5650         ].
  5639         ^ self
  5651         ^ self
  5640     ].
  5652     ].
  5641 
  5653 
  5642     (key == #ToggleAutoIndent) ifTrue:[
  5654     (key == #ToggleAutoIndent) ifTrue:[
  5643         self autoIndent:(autoIndent not).
  5655         self autoIndent:(self autoIndent not).
  5644         ^ self.
  5656         ^ self.
  5645     ].
  5657     ].
  5646 
  5658 
  5647     key == #ToggleInsertMode ifTrue:[
  5659     key == #ToggleInsertMode ifTrue:[
  5648         self insertMode:(editMode value == EditMode insertMode) not.
  5660         self insertMode:(editMode value == EditMode insertMode) not.
  5940     super keyPress:key x:x y:y
  5952     super keyPress:key x:x y:y
  5941 
  5953 
  5942     "Modified: / 06-02-1998 / 11:59:59 / stefan"
  5954     "Modified: / 06-02-1998 / 11:59:59 / stefan"
  5943     "Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5955     "Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5944     "Modified: / 28-04-2017 / 09:25:22 / cg"
  5956     "Modified: / 28-04-2017 / 09:25:22 / cg"
  5945     "Modified: / 26-06-2019 / 21:58:48 / Claus Gittinger"
  5957     "Modified: / 26-06-2019 / 23:17:08 / Claus Gittinger"
  5946 !
  5958 !
  5947 
  5959 
  5948 executeKeyboardMacro:cmdMacro
  5960 executeKeyboardMacro:cmdMacro
  5949     Error handle:[:ex |
  5961     Error handle:[:ex |
  5950         self warn:'Error in keyboard macro: ' , ex description.
  5962         self warn:'Error in keyboard macro: ' , ex description.
  6047         self cursorReturn.
  6059         self cursorReturn.
  6048         ^ self.
  6060         ^ self.
  6049     ].
  6061     ].
  6050     self isInInsertMode ifFalse:[
  6062     self isInInsertMode ifFalse:[
  6051         self cursorReturn:true.
  6063         self cursorReturn:true.
  6052         autoIndent == true ifTrue:[
  6064         self autoIndent ifTrue:[
  6053             i := self leftIndentForLine:(cursorLine + 1).
  6065             i := self leftIndentForLine:(cursorLine + 1).
  6054             (self listAt:cursorLine) isEmptyOrNil ifTrue:[
  6066             (self listAt:cursorLine) isEmptyOrNil ifTrue:[
  6055                 self cursorCol:(i+1 max:1)
  6067                 self cursorCol:(i+1 max:1)
  6056             ]
  6068             ]
  6057         ].
  6069         ].
  6084             [:line |
  6096             [:line |
  6085                 bracketStrings contains:[:pair | line startsWith:(pair second)].
  6097                 bracketStrings contains:[:pair | line startsWith:(pair second)].
  6086             ].
  6098             ].
  6087     ]. 
  6099     ]. 
  6088     
  6100     
  6089     autoIndent == true ifTrue:[
  6101     self autoIndent ifTrue:[
  6090         (rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[
  6102         (rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[
  6091             "/ nothing to do.
  6103             "/ nothing to do.
  6092         ] ifFalse:[
  6104         ] ifFalse:[
  6093             i := self leftIndentForLine:cursorLine. 
  6105             i := self leftIndentForLine:cursorLine. 
  6094             
  6106             
  6132             self cursorCol:(newIndent+1 max:1)
  6144             self cursorCol:(newIndent+1 max:1)
  6133         ]
  6145         ]
  6134     ].
  6146     ].
  6135 
  6147 
  6136     "Created: / 26-06-2019 / 21:57:50 / Claus Gittinger"
  6148     "Created: / 26-06-2019 / 21:57:50 / Claus Gittinger"
  6137     "Modified: / 26-06-2019 / 23:01:52 / Claus Gittinger"
  6149     "Modified: / 26-06-2019 / 23:17:45 / Claus Gittinger"
  6138 !
  6150 !
  6139 
  6151 
  6140 keyPress:key x:x y:y
  6152 keyPress:key x:x y:y
  6141     "handle keyboard input"
  6153     "handle keyboard input"
  6142 
  6154 
  6628     acceptChannel := ValueHolder with:false.
  6640     acceptChannel := ValueHolder with:false.
  6629     acceptChannel addDependent:self.
  6641     acceptChannel addDependent:self.
  6630     showMatchingParenthesis := false.
  6642     showMatchingParenthesis := false.
  6631     hasKeyboardFocus := false.
  6643     hasKeyboardFocus := false.
  6632     tabMeansNextField := false.
  6644     tabMeansNextField := false.
  6633     "/ autoIndent := UserPreferences current autoIndentInCodeView.
  6645     "/ autoIndent := UserPreferences current autoIndentInCodeView asValue.
  6634     autoIndent := false.
  6646     autoIndent := false asValue.
  6635     editMode := ValueHolder with:EditMode insertMode.
  6647     editMode := ValueHolder with:EditMode insertMode.
  6636     learnMode := ValueHolder with:false.
  6648     learnMode := ValueHolder with:false.
  6637     cursorMovementWhenUpdating := #beginOfText.
  6649     cursorMovementWhenUpdating := #beginOfText.
  6638     lastReplacementInfo := LastReplacementInfo new.
  6650     lastReplacementInfo := LastReplacementInfo new.
  6639 
  6651 
  6642 
  6654 
  6643     undoSupport := UndoSupport for:self.
  6655     undoSupport := UndoSupport for:self.
  6644     codeAspectHolder := ValueHolder with:nil.
  6656     codeAspectHolder := ValueHolder with:nil.
  6645 
  6657 
  6646     "Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  6658     "Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  6659     "Modified (comment): / 26-06-2019 / 23:21:46 / Claus Gittinger"
  6647 !
  6660 !
  6648 
  6661 
  6649 initializeCompletionSupport
  6662 initializeCompletionSupport
  6650     |supportClass|
  6663     |supportClass|
  6651 
  6664 
  7015     convertSubMenu receiver:self.
  7028     convertSubMenu receiver:self.
  7016     toolSubMenu subMenuAt:#convertMenu put:convertSubMenu.
  7029     toolSubMenu subMenuAt:#convertMenu put:convertSubMenu.
  7017 
  7030 
  7018     subSubMenu := PopUpMenu itemList:miscItems resources:resources performer:model.
  7031     subSubMenu := PopUpMenu itemList:miscItems resources:resources performer:model.
  7019     subSubMenu receiver:self.
  7032     subSubMenu receiver:self.
  7020     subSubMenu checkToggleAt:#autoIndent: put:autoIndent.
  7033     subSubMenu checkToggleAt:#autoIndent: put:(self autoIndent).
  7021     subSubMenu checkToggleAt:#insertMode: put:(self isInInsertMode).
  7034     subSubMenu checkToggleAt:#insertMode: put:(self isInInsertMode).
  7022     subSubMenu checkToggleAt:#learnMode: put:(self learnModeHolder value).
  7035     subSubMenu checkToggleAt:#learnMode: put:(self learnModeHolder value).
  7023 
  7036 
  7024     sub subMenuAt:#misc put:subSubMenu.
  7037     sub subMenuAt:#misc put:subSubMenu.
  7025 
  7038 
  7134         m disable:#accept
  7147         m disable:#accept
  7135     ].
  7148     ].
  7136     ^ m.
  7149     ^ m.
  7137 
  7150 
  7138     "Modified: / 30-11-2017 / 15:06:03 / cg"
  7151     "Modified: / 30-11-2017 / 15:06:03 / cg"
  7139     "Modified: / 06-06-2019 / 11:22:31 / Claus Gittinger"
  7152     "Modified: / 26-06-2019 / 23:17:26 / Claus Gittinger"
  7140 !
  7153 !
  7141 
  7154 
  7142 getTextSelectionFromHistory
  7155 getTextSelectionFromHistory
  7143     "present the copyBufferHistory as a shortened list (first line of each),
  7156     "present the copyBufferHistory as a shortened list (first line of each),
  7144      and let user select from it.
  7157      and let user select from it.