class: TerminalView
authorClaus Gittinger <cg@exept.de>
Mon, 02 Jun 2014 15:09:33 +0200
changeset 4601 7a5e33b7f079
parent 4600 2be94e93233b
child 4602 a5c14fbf63cf
class: TerminalView added: #sendLineEnd #shouldProcessInputInLineEditMode comment/format in: #keyPressInLineEditMode: changed: #keyPress:x:y: #paste: #sendLine: paste in readline mode
TerminalView.st
--- a/TerminalView.st	Mon Jun 02 13:38:31 2014 +0200
+++ b/TerminalView.st	Mon Jun 02 15:09:33 2014 +0200
@@ -689,7 +689,7 @@
                           #Meta #Meta_L #Meta_R
                           #Return)>
 
-    |rest event rawKey seq termiosInfo doLine|
+    |rest event rawKey seq|
 
     "/ somewhat complicated, since some characters
     "/ should go untranslated (CTRL-key),
@@ -700,16 +700,8 @@
     DebugKeyboard ifTrue:[
         Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString.
     ].
-    (doLine := lineEditMode) == true ifTrue:[
-        "/ check if tty is in raw mode - then don't do lineEditMode
-        (OperatingSystem isUNIXlike
-        and:[ inStream isExternalStream ]) ifTrue:[
-            termiosInfo := inStream tcgetattr.
-            doLine := (termiosInfo at:#lflags) at:#icanon.
-        ].
-        doLine ifTrue:[
-            (self keyPressInLineEditMode:aKey) ifTrue:[^ self].
-        ].
+    self shouldProcessInputInLineEditMode ifTrue:[
+        (self keyPressInLineEditMode:aKey) ifTrue:[^ self].
     ].
 
     aKey isCharacter ifTrue:[
@@ -861,6 +853,7 @@
         lineBufferCursorPosition := lineBufferCursorPosition + 1.
         ^ true.
     ].
+
     aKey == #Return ifTrue:[
         "/ as the pty is in echo mode,
         "/ we should either disable echo for the following,
@@ -974,6 +967,24 @@
     "Modified: / 5.5.1999 / 18:43:22 / cg"
 !
 
+shouldProcessInputInLineEditMode
+    "should input be processed in the readline edit mode?"
+
+    |termiosInfo|
+
+    lineEditMode == true ifFalse:[^ false].
+
+    "/ check if tty is in raw mode - then don't do lineEditMode
+    (OperatingSystem isUNIXlike
+    and:[ inStream isExternalStream ]) ifTrue:[
+        termiosInfo := inStream tcgetattr.
+        ((termiosInfo at:#lflags) at:#icanon) ifFalse:[^ false].
+    ].
+
+    "/ don't know how to do that on non-unix systems
+    ^ true
+!
+
 sizeChanged:how
     super sizeChanged:how.
     self defineWindowSize.
@@ -2120,10 +2131,14 @@
     ].
 
     self send:aString.
+    self sendLineEnd
+!
+
+sendLineEnd
     OperatingSystem isMSDOSlike ifTrue:[
-        self send:String crlf
+        self send:String crlf.
     ] ifFalse:[
-        self send:String cr
+        self send:String cr.
     ].
 !
 
@@ -2404,10 +2419,16 @@
                 Transcript showCR:'send paste line: ',line asByteArray hexPrintString
             ].
         ].
-        idx ~~ nLines ifTrue:[
-            self sendLine:line
+        self shouldProcessInputInLineEditMode ifTrue:[
+            line do:[:ch | self keyPressInLineEditMode:ch ].
+            idx ~~ nLines ifTrue:[
+                self keyPressInLineEditMode:#Return
+            ]
         ] ifFalse:[
-            self send:line
+            self send:line.
+            idx ~~ nLines ifTrue:[
+                self sendLineEnd
+            ]
         ]
     ].
 
@@ -2434,11 +2455,11 @@
 !TerminalView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.183 2014-06-02 11:38:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.184 2014-06-02 13:09:33 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.183 2014-06-02 11:38:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.184 2014-06-02 13:09:33 cg Exp $'
 ! !