class: EditTextView
authorClaus Gittinger <cg@exept.de>
Fri, 18 Oct 2013 17:01:49 +0200
changeset 4812 ca6d48bf0053
parent 4811 e868808b229e
child 4813 938c3cbafe4c
class: EditTextView comment/format in: #insertLines:from:to:before: changed: #doKeyPress:x:y: some autoindent changes, but still not perfect
EditTextView.st
--- a/EditTextView.st	Thu Oct 17 16:11:06 2013 +0200
+++ b/EditTextView.st	Fri Oct 18 17:01:49 2013 +0200
@@ -3176,17 +3176,18 @@
     autoIndent ifTrue:[
         indent := self leftIndentForLine:lineNr.
 
-        text := someText collect:[:ln||line|
-            ln notNil ifTrue:[
-                line := ln withoutLeadingSeparators.
-                (line isEmpty or:[indent == 0]) ifFalse:[
-                    line := (String new:indent), line
-                ].
-                line
-            ] ifFalse:[
-                nil
-            ]
-        ].
+        text := someText 
+            collect:[:ln||line|
+                ln notNil ifTrue:[
+                    line := ln withoutLeadingSeparators.
+                    (line isEmpty or:[indent == 0]) ifFalse:[
+                        line := (String new:indent), line
+                    ].
+                    line
+                ] ifFalse:[
+                    nil
+                ]
+            ].
     ] ifFalse:[
         text := someText
     ].
@@ -5058,6 +5059,8 @@
                     ]
                 ]
             ] ifTrue:[
+                |rest|
+
                 "/ old version just unselected ...
                 "/ self unselect; makeCursorVisible.
 
@@ -5067,14 +5070,22 @@
                 ] ifFalse:[
                     self copyAndDeleteSelection.
                 ].
-                i := self leftIndentOfLine:cursorLine.
+                rest := (self listAt:cursorLine from:cursorCol) ? ''.
                 self insertCharAtCursor:(Character cr).
                 autoIndent == true ifTrue:[
-                    (self listAt:cursorLine) isEmptyOrNil ifTrue:[
-                        i := self leftIndentForLine:cursorLine.
-                    ].
-                    self indentFromLine:cursorLine toLine:cursorLine by:i.
-                    self cursorCol:(i+1 max:1)
+                    (rest isEmpty and:[cursorCol ~~ 1]) ifTrue:[
+                        "/ self cursorUp.
+                    ] ifFalse:[
+                        ((self listAt:cursorLine) isEmptyOrNil 
+                        or:[ cursorCol == 1 ]) ifTrue:[
+                            i := (self leftIndentForLine:cursorLine).
+                            (rest withoutSeparators startsWith:']') ifFalse:[
+                                i := i + 4.
+                            ].
+                            self indentFromLine:cursorLine toLine:cursorLine by:i.
+                            self cursorCol:(i+1 max:1)
+                        ].
+                    ]
                 ].
             ].
         ].
@@ -8406,10 +8417,10 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.589 2013-10-17 14:11:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.590 2013-10-18 15:01:49 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.589 2013-10-17 14:11:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.590 2013-10-18 15:01:49 cg Exp $'
 ! !