Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView` jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 14 Jan 2017 00:35:41 +0000
branchjv
changeset 6063 ef1842cb1d75
parent 6062 0853775c6449
child 6064 613a55d2067a
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView` ...and remove it there. https://swing.fit.cvut.cz/projects/stx-jv/ticket/116
EditTextView.st
--- a/EditTextView.st	Fri Jan 13 23:33:34 2017 +0000
+++ b/EditTextView.st	Sat Jan 14 00:35:41 2017 +0000
@@ -3366,9 +3366,20 @@
     |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
 
     wasOn := self hideCursor.
-    (autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[
+
+    "JV@2012-01-06: Do not play with autoindent iff cursor is at the very beginning of the line"
+    (autoIndent 
+    and:[cursorCol ~~ 1
+    and:[ (tabPositions includes:cursorCol) 
+    ]]) ifTrue:[
         prevTab := (self prevTabBefore:cursorCol) max:1.
-        ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''.
+        "JV@2011-12-10: The list can be shorter than cursorLine,
+         trailing because empty lines are not physically in the list."
+        (list size >= cursorLine) ifTrue:[
+            ln := originalLine := (list at:cursorLine) ? ''.
+        ] ifFalse:[        
+            ln := originalLine := ''.
+        ].    
         ln size < prevTab ifTrue:[
             ln := ln , (String new:prevTab withAll:Character space).
         ].
@@ -3378,10 +3389,9 @@
                     self st80EditMode ifTrue:[
                         "/ ensure that there is no conflict here: st80EditMode will
                         "/ not allow a cursor position beyond the end of line,
-                        "/ so ensure that cursorLine:col: will force us to the beginning of the line
+                        "/ so avoid that cursorLine:col: will force us to the beginning of the line
                         originalLine size < prevTab ifTrue:[
-                            self checkForExistingLine:cursorLine.    
-                            self basicListAt:cursorLine put:ln
+                            self at:cursorLine put:ln
                         ]
                     ].
                     self cursorLine:cursorLine col:prevTab.
@@ -3389,10 +3399,15 @@
                     ^  self
                 ].
             ] ifFalse:[
-                self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
-                self cursorLine:cursorLine col:prevTab.
-                wasOn ifTrue:[ self showCursor ].
-                ^  self.
+                "/ cg: this is ugly behavior; deleting multiple chars at the beginning
+                "/ is annoying.
+                "/ therefore, only do it, if there are only blanks after the cursor
+"/                (ln copyFrom:prevTab+1 to:((cursorCol-1) min:ln size)) isBlank ifTrue:[
+"/                    self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
+"/                    self cursorLine:cursorLine col:prevTab.
+"/                    wasOn ifTrue:[ self showCursor ].
+"/                    ^  self.
+"/                ]
             ]
         ].
     ].
@@ -3439,7 +3454,9 @@
     ].
     wasOn ifTrue:[ self showCursor ]
 
-    "Modified: / 16.1.1998 / 22:33:04 / cg"
+    "Modified: / 16-01-1998 / 22:33:04 / cg"
+    "Modified: / 12-01-2017 / 22:38:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 13-01-2017 / 22:10:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 deleteCharsAtLine:lineNr fromCol:colNr