Fixes in electring snippets (both in API and Smalltalk snippets)
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 22 Oct 2013 17:25:26 +0100
changeset 137 12232e62cf54
parent 136 a1c1b160f2ca
child 138 3355e5292e1d
Fixes in electring snippets (both in API and Smalltalk snippets)
Make.proto
SmallSense__EditSupport.st
SmallSense__SmalltalkEditSupport.st
bc.mak
extensions.st
jv_smallsense.st
smallsense.rc
--- a/Make.proto	Tue Oct 22 12:14:07 2013 +0100
+++ b/Make.proto	Tue Oct 22 17:25:26 2013 +0100
@@ -34,7 +34,7 @@
 # add the path(es) here:,
 # ********** OPTIONAL: MODIFY the next lines ***
 # LOCALINCLUDES=-Ifoo -Ibar
-LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg -I$(INCLUDE_TOP)/stx/libhtml -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/lint -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libview -I$(INCLUDE_TOP)/stx/libwidg2
+LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg -I$(INCLUDE_TOP)/stx/libhtml -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/lint -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libview -I$(INCLUDE_TOP)/stx/libwidg2
 
 
 # if you need any additional defines for embedded C code,
@@ -137,7 +137,6 @@
 	cd $(TOP)/libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/goodies/refactoryBrowser/browser && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
-	cd $(TOP)/goodies/sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/goodies/refactoryBrowser/lint && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/libhtml && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
--- a/SmallSense__EditSupport.st	Tue Oct 22 12:14:07 2013 +0100
+++ b/SmallSense__EditSupport.st	Tue Oct 22 17:25:26 2013 +0100
@@ -86,13 +86,34 @@
 !
 
 insertElectric: text
-    self insertDo:[textView insertStringAtCursor: text].
+    self insertElectric:text advanceCursorBy:nil.
 
     "Created: / 22-10-2013 / 11:08:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+insertElectric:text advanceCursorBy:offsetOrNil 
+    "Insert given text. If offsetOrNil is not nil, then
+     move cursor by `offsetOrNil` character after **beggining** of
+     inserted text."
+    
+    self 
+        insertDo:[
+            offsetOrNil isNil ifTrue:[
+                textView insertStringAtCursor:text
+            ] ifFalse:[
+                | col |
+
+                col := textView cursorCol.
+                textView insertStringAtCursor:text.
+                textView cursorCol:col + offsetOrNil.
+            ].
+        ].
+
+    "Created: / 22-10-2013 / 11:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 insertElectricBlockOpenedBy: openText closedBy: closeText
-    | line col indent |
+    | lineNr indent lines autoIndent |
 
     textView completionSupport notNil ifTrue:[
         textView completionSupport 
@@ -102,15 +123,31 @@
 
     indent := self indentAtCursorLine.
 
-    textView undoableDo:[
-        textView insertStringAtCursor: (openText ? '') , Character cr , Character cr, (String new:indent withAll:Character space) , closeText , Character cr.
-        line := textView cursorLine - 1.
-        col := textView cursorCol  + 3.
-        textView cursorLine: line col: col.
+    autoIndent :=  textView autoIndent.
+    textView autoIndent: false. 
+    [
+        textView undoableDo:[
+            lineNr :=  textView cursorLine.
+            lines := Array 
+                        with: openText ? ''
+                        with: '' 
+                        with: ((String new:indent withAll:Character space) , closeText ).
+            textView 
+                insertLines: lines
+                withCR: false.
+            textView cursorLine: lineNr + 1 col: indent + 5. 
+
+    "/        textView insertStringAtCursor: (openText ? '') , Character cr , Character cr,  , closeText , Character cr.
+    "/        line := textView cursorLine - 1.
+    "/        col := textView cursorCol  + 3.
+    "/        textView cursorLine: line col: col.
+        ].
+    ] ensure:[
+        textView autoIndent: autoIndent 
     ].
 
     "Created: / 25-07-2013 / 10:41:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 22-10-2013 / 03:16:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-10-2013 / 17:10:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 insertElectricSnippet    
@@ -260,7 +297,7 @@
             [ token := scanner nextToken.token ~~ #EOF ] whileTrue:[
                 tokens 
                     nextPut: token; 
-                    nextPut: scanner tokenName; 
+                    nextPut: (scanner tokenName notNil ifTrue:[scanner tokenName] ifFalse:[ scanner tokenValue printString ]); 
                     nextPut: scanner tokenStartPosition;
                     nextPut: (tokenLastEndPosition := scanner tokenEndPosition).
             ].
@@ -274,7 +311,7 @@
     ].
 
     "Created: / 22-10-2013 / 00:31:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 22-10-2013 / 02:16:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-10-2013 / 12:01:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 scanLineAtCursor
--- a/SmallSense__SmalltalkEditSupport.st	Tue Oct 22 12:14:07 2013 +0100
+++ b/SmallSense__SmalltalkEditSupport.st	Tue Oct 22 17:25:26 2013 +0100
@@ -39,26 +39,6 @@
 
 !SmalltalkEditSupport methodsFor:'editing'!
 
-insertElectricBlockOpenedBy: openText closedBy: closeText
-    | line col |
-
-    textView completionSupport notNil ifTrue:[
-        textView completionSupport 
-            stopCompletionProcess;
-            closeCompletionView.
-    ].  
-
-    textView undoableDo:[
-        textView insertStringAtCursor: (openText ? '') , Character cr , Character cr, closeText , Character cr.
-        line := textView cursorLine - 1.
-        col := textView cursorCol  + 2.
-        textView cursorLine: line col: col.
-    ].
-
-    "Created: / 25-07-2013 / 10:41:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 22-10-2013 / 03:16:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 insertElectricSnippet
     lastTypedKey0 == Character space ifTrue:[
         ^ self insertElectricSnippetAfterSpace
@@ -86,7 +66,7 @@
 
         tokens size > 4 ifTrue:[
             (#(#do #select #reject #detect #contains #allSatisfy #anySatisfy) includes: lastValue0) ifTrue:[
-                | collectionName eachName space |
+                | collectionName eachName space part1 part2 |
                 space := RBFormatter spaceAfterKeywordSelector ifTrue:[' '] ifFalse:[''].
                 eachName := 'each'.
                 tokens size > 4 ifTrue:[
@@ -98,13 +78,13 @@
                         ].
                     ].
                 ].
-                self insertElectricBlockOpenedBy: ':', space , '[:' , eachName , ' |' closedBy: ']'. 
+                part1 := ':', space , '[:' , eachName , ' | '.
+                part2 := ' ]'.
+                self insertElectric: part1 , part2 advanceCursorBy: part1 size.
                 ^ true.
             ]. 
             RBFormatter spaceAfterKeywordSelector ifTrue:[
-                self insertDo:[ 
-                    textView insertStringAtCursor:': ' 
-                ].  
+                self insertElectric: ': '.
                 ^ true.
             ]
         ].
@@ -113,6 +93,7 @@
     ^ false.
 
     "Created: / 22-10-2013 / 03:05:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-10-2013 / 12:00:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 insertElectricSnippetAfterSpace
@@ -129,7 +110,7 @@
 
         tokens size > 4 ifTrue:[
             (#(#do: #select: #reject: #detect: #contains: #allSatisfy: #anySatisfy:) includes: lastValue0) ifTrue:[
-                | collectionName eachName |
+                | collectionName eachName part1 part2 |
                 eachName := 'each'.
                 tokens size > 4 ifTrue:[
                     (collectionName := (tokens at: tokens size - 6) last = $s) ifTrue:[
@@ -140,7 +121,9 @@
                         ].
                     ].
                 ].
-                self insertElectricBlockOpenedBy: ' [:' , eachName , ' |' closedBy: ']'. 
+                part1 := ' [:' , eachName , ' | '.
+                part2 := ' ]'.
+                self insertElectric: part1 , part2 advanceCursorBy: part1 size.
                 ^ true.
             ]. 
         ]
@@ -148,6 +131,7 @@
     ^ false.
 
     "Created: / 22-10-2013 / 03:00:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-10-2013 / 12:00:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkEditSupport methodsFor:'event handling'!
--- a/bc.mak	Tue Oct 22 12:14:07 2013 +0100
+++ b/bc.mak	Tue Oct 22 17:25:26 2013 +0100
@@ -34,7 +34,7 @@
 
 
 
-LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg -I$(INCLUDE_TOP)\stx\libhtml -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libview -I$(INCLUDE_TOP)\stx\libwidg2
+LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg -I$(INCLUDE_TOP)\stx\libhtml -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\lint -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libview -I$(INCLUDE_TOP)\stx\libwidg2
 LOCALDEFINES=
 
 STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES)  -varPrefix=$(LIBNAME)
@@ -60,7 +60,6 @@
 	pushd ..\..\stx\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\stx\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\stx\goodies\refactoryBrowser\browser & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
-	pushd ..\..\stx\goodies\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\stx\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\stx\goodies\refactoryBrowser\lint & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\stx\libhtml & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
--- a/extensions.st	Tue Oct 22 12:14:07 2013 +0100
+++ b/extensions.st	Tue Oct 22 17:25:26 2013 +0100
@@ -104,6 +104,12 @@
     "Modified: / 02-09-2013 / 12:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!EditTextView methodsFor:'accessing-behavior'!
+
+autoIndent
+    ^ autoIndent
+! !
+
 !HTMLDocumentView methodsFor:'actions'!
 
 doQuickFix: quickFixNo
--- a/jv_smallsense.st	Tue Oct 22 12:14:07 2013 +0100
+++ b/jv_smallsense.st	Tue Oct 22 17:25:26 2013 +0100
@@ -46,7 +46,6 @@
     ^ #(
         #'stx:goodies/refactoryBrowser/helpers'    "BrowserEnvironment - superclass of SmallSense::SmalltalkUnacceptedMethodEnvironment "
         #'stx:goodies/refactoryBrowser/lint'    "RBLintRule - extended "
-        #'stx:goodies/sunit'    "TestAsserter - superclass of SmallSense::TestCase "
         #'stx:libbasic'    "Autoload - superclass of SmallSense::BaseTestClass "
         #'stx:libcomp'    "AbstractSyntaxHighlighter - superclass of SmallSense::SmalltalkParser "
         #'stx:libhtml'    "HTMLDocumentFrame - extended "
@@ -255,6 +254,7 @@
         ParseNode navigateToUsing:
         MessageNode navigateToUsing:
         VariableNode navigateToUsing:
+        EditTextView autoIndent
     )
 ! !
 
--- a/smallsense.rc	Tue Oct 22 12:14:07 2013 +0100
+++ b/smallsense.rc	Tue Oct 22 17:25:26 2013 +0100
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Tue, 22 Oct 2013 02:26:13 GMT\0"
+      VALUE "ProductDate", "Tue, 22 Oct 2013 16:24:20 GMT\0"
     END
 
   END