class: TerminalView
authorClaus Gittinger <cg@exept.de>
Sun, 08 Jun 2014 09:20:18 +0200
changeset 4612 e05d68f2d152
parent 4611 8c77f5d5a201
child 4613 73e2facef522
class: TerminalView added utf8 decoding flag
TerminalView.st
--- a/TerminalView.st	Sat Jun 07 17:13:04 2014 +0200
+++ b/TerminalView.st	Sun Jun 08 09:20:18 2014 +0200
@@ -21,7 +21,7 @@
 		inputTranslateBackspaceToDelete autoWrapFlag masterWindow
 		alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
 		lineEditMode lineBuffer lineBufferCursorPosition
-		lineBufferHistory lineBufferHistoryPosition maxHistorySize'
+		lineBufferHistory lineBufferHistoryPosition maxHistorySize doUTF'
 	classVariableNames:'Debug DebugKeyboard DefaultMaxHistorySize'
 	poolDictionaries:''
 	category:'Views-TerminalViews'
@@ -1315,6 +1315,7 @@
     inputTranslateBackspaceToDelete := false.
     autoWrapFlag := true.
     noColors := false.
+    doUTF := UserPreferences current terminalOutputIsUTF8.
     lineEditMode := OperatingSystem isMSWINDOWSlike.
     maxHistorySize := maxHistorySize ? DefaultMaxHistorySize.
 
@@ -1901,7 +1902,9 @@
      proceed in single-character mode (processState0:) until the sequence is finished, and continue
      collecting.
      This makes this terminalView's speed usable and actually competitive with some existing
-     console applications (it is *much* faster than the MSWindows command.com window, btw.)"
+     console applications. 
+     BTW: It is *much* faster than the MSWindows command.com window,
+     - so much for the 'slow' Smalltalk ;-)"
 
     |sensor|
 
@@ -1978,6 +1981,9 @@
             ].
 
             stringWithOutControl notNil ifTrue:[
+                doUTF ifTrue:[ 
+                    stringWithOutControl := stringWithOutControl utf8Decoded
+                ].
                 (cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[
                     "/ characterwise, for correct wrap handling at line end
                     stringWithOutControl do:[:eachCharacter |
@@ -2183,7 +2189,7 @@
             ] do:[
                 |n sensor|
 
-                Delay waitForSeconds:0.01.
+                "/ Delay waitForSeconds:0.01.
                 outStream readWait.
                 sensor := self sensor.
                 (sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[
@@ -2203,7 +2209,7 @@
                         n == 0 ifTrue:[
                             "/ Windows IPC has a bug - it always
                             "/ returns 0 (when the command is idle)
-                            "/ and says its at the end (sigh)
+                            "/ and says it's at the end (sigh)
 
                             OperatingSystem isMSWINDOWSlike ifTrue:[
                                 Delay waitForSeconds:0.01
@@ -2213,7 +2219,6 @@
                                     Processor activeProcess terminate.
                                 ] ifFalse:[
                                     "/ this should not happen.
-
                                     Delay waitForSeconds:0.05
                                 ]
                             ].
@@ -2246,16 +2251,7 @@
     "Start a reader process, which looks for the commands output,
      and sends me #processInput:n: events whenever something arrives."
 
-    readerProcess isNil ifTrue:[
-        readerProcess := [
-            [
-                self readerProcessLoop.
-            ] ifCurtailed:[
-                readerProcess := nil    
-            ]
-        ] fork. "/ forkAt:9.
-        readerProcess name:'pty reader'.
-    ]
+    self startReaderProcessWhenVisible:false
 
     "
      VT100TerminalView openShell
@@ -2269,10 +2265,24 @@
     "Start a reader process, which looks for the commands output,
      and sends me #processInput:n: events whenever something arrives."
 
+    self startReaderProcessWhenVisible:true
+
+    "
+     VT100TerminalView openShell
+    "
+
+    "Modified: / 5.5.1999 / 17:58:02 / cg"
+    "Modified: / 28.1.2002 / 21:10:13 / micha"
+!
+
+startReaderProcessWhenVisible:whenVisible
+    "Start a reader process, which looks for the commands output,
+     and sends me #processInput:n: events whenever something arrives."
+
     readerProcess isNil ifTrue:[
         readerProcess := [
             [
-                self waitUntilVisible.
+                whenVisible ifTrue:[self waitUntilVisible].
                 self readerProcessLoop.
             ] ifCurtailed:[
                 readerProcess := nil    
@@ -2465,11 +2475,11 @@
 !TerminalView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.187 2014-06-03 07:55:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.188 2014-06-08 07:20:18 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.187 2014-06-03 07:55:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.188 2014-06-08 07:20:18 cg Exp $'
 ! !