VT100TerminalView.st
changeset 4269 edb108492a92
parent 4221 78dfbf10887b
child 4270 d109ce8a73a8
--- a/VT100TerminalView.st	Tue Jul 09 11:31:39 2013 +0200
+++ b/VT100TerminalView.st	Tue Jul 09 11:32:30 2013 +0200
@@ -13,7 +13,7 @@
 
 TerminalView subclass:#VT100TerminalView
 	instanceVariableNames:'currentParam parameters lastCursorLine'
-	classVariableNames:''
+	classVariableNames:'TraceCSI'
 	poolDictionaries:''
 	category:'Views-TerminalViews'
 !
@@ -432,6 +432,31 @@
     "Created: / 10.6.1998 / 15:12:32 / cg"
 ! !
 
+!VT100TerminalView methodsFor:'misc'!
+
+traceCSI:char
+    state infoPrint. '-' infoPrint. 
+    char asciiValue > 32 ifTrue:[
+        char infoPrint. 
+    ] ifFalse:[
+        '0x' infoPrint. char codePoint hexPrintString infoPrint. 
+    ].
+    currentParam > 1 ifTrue:[
+        ' ' infoPrint. 
+        (parameters at:1) infoPrintCR.
+
+        currentParam > 2 ifTrue:[
+            ' ' infoPrint. 
+            (parameters at:2) infoPrintCR.
+
+            currentParam > 3 ifTrue:[
+                ' ' infoPrint. 
+                (parameters at:3) infoPrintCR.
+            ].
+        ].
+    ].
+! !
+
 !VT100TerminalView methodsFor:'os functions (xterm)'!
 
 osCommand
@@ -439,6 +464,7 @@
 
     cmdKey := parameters at:1.
     cmdValue := parameters at:2.
+
     cmdKey == 0 ifTrue:[
         "/ change icon name and window title
         masterWindow notNil ifTrue:[
@@ -503,7 +529,7 @@
     "Modified: / 10.6.1998 / 14:30:57 / cg"
 !
 
-evaluateProcessCharacterReturn:aSymbol
+evaluateProcessCharacter:char return:aSymbol
     " evaluate the return value of the process state methods except for state 0
     "
 
@@ -511,6 +537,9 @@
         ^ self.
     ].
     aSymbol == #unknown ifTrue:[
+        ('VT100TerminalView [info]: unknown character %1 ins state %2'
+            bindWith:(char codePoint hexPrintString)
+            with:state) infoPrintCR.
         self doNothing.
         ^ self
     ].
@@ -518,6 +547,7 @@
         self endOfSequence.
         ^ self.
     ].
+    self halt:'unexpected return value from state processing'
 !
 
 nextPut:char 
@@ -538,45 +568,41 @@
             self endOfSequence.
             ^ self.
         ].
+        ^ self
     ].
     state == 0 ifTrue:[
         processCharacterReturn := self processState0:char.
-        processCharacterReturn == #waitForNextChar ifTrue:[
-            ^ self.
-        ].
-        processCharacterReturn == #unknown ifTrue:[
-            super nextPut:char.
-            ^ self.
-        ].
+        self evaluateProcessCharacter:char return:processCharacterReturn.
+        ^ self
     ].
     state == #gotESC ifTrue:[
         processCharacterReturn := self processStateGotESC:char.
-        self evaluateProcessCharacterReturn:processCharacterReturn.
+        self evaluateProcessCharacter:char return:processCharacterReturn.
         ^ self.
     ].
     state == #gotCSI ifTrue:[
         processCharacterReturn := self processStateGotCSI:char.
-        self evaluateProcessCharacterReturn:processCharacterReturn.
+        self evaluateProcessCharacter:char return:processCharacterReturn.
         ^ self.
     ].
     state == #gotCSI2 ifTrue:[
         processCharacterReturn := self processStateGotCSI2:char.
-        self evaluateProcessCharacterReturn:processCharacterReturn.
+        self evaluateProcessCharacter:char return:processCharacterReturn.
         ^ self.
     ].
     state == #gotCSI3 ifTrue:[
         processCharacterReturn := self processStateGotCSI3:char.
-        self evaluateProcessCharacterReturn:processCharacterReturn.
+        self evaluateProcessCharacter:char return:processCharacterReturn.
         ^ self.
     ].
     state == #gotXTERMCSI ifTrue:[
         processCharacterReturn := self processStateGotXTERMCSI:char.
-        self evaluateProcessCharacterReturn:processCharacterReturn.
+        self evaluateProcessCharacter:char return:processCharacterReturn.
         ^ self.
     ].
     state == #gotXTERMCSI2 ifTrue:[
         processCharacterReturn := self processStateGotXTERMCSI2:char.
-        self evaluateProcessCharacterReturn:processCharacterReturn.
+        self evaluateProcessCharacter:char return:processCharacterReturn.
         ^ self.
     ].
     self halt:'unknown state'.
@@ -596,6 +622,7 @@
             state := #gotESC.
             ^ #waitForNextChar
         ].
+
         (    char == Character nl   "nl or '\n'"
         or:[(char == (Character value:16rb))]) ifTrue:[
             translateNLToCRNL == true ifTrue:[
@@ -606,6 +633,7 @@
             self doCursorDown:1.
             ^ #waitForNextChar.
         ].
+
         (char == Character return) ifTrue:[
             (rangeEndLine notNil and:[rangeEndLine ~~ numberOfLines]) ifTrue:[
                 self endEntry.
@@ -615,30 +643,35 @@
             ].
             ^ #waitForNextChar.
         ].
+
         (char == Character backspace) ifTrue:[
             self endEntry.
             self cursorLeft.
             ^ #waitForNextChar    "/ doBackspace
         ].
+
         (char == Character bell) ifTrue:[
             self shown ifTrue:[
                 self beep.
             ].
             ^ #waitForNextChar
         ].
+
         (char == (Character value:5)) ifTrue:[
             "/ Transmission answerback message
             self reportTerminalType.
             ^ #waitForNextChar                         
         ].
+
         (    char == (Character value:16r18) "/Cancel
         or:[ char == (Character value:16r1A) "/Substitute
         ]) ifTrue:[
             self nextPut:(Character value:16r2).
             ^ #waitForNextChar                         
         ]
+
         "
-        all not suported control characters (also vt102):
+        all unsupported control characters (also vt102):
         Character value:16r3    ->End of text
         Character value:16r4    ->End of transmission
         Character tab           ->Horizontal tab
@@ -656,6 +689,9 @@
         ]
 
     ].
+    ('VT100TerminalView [info]: unknown character %1 ins state %2'
+        bindWith:(char codePoint hexPrintString)
+        with:state) infoPrintCR.
     ^ #unknown
 !
 
@@ -674,8 +710,9 @@
         self addToParameter:char.
         ^ #waitForNextChar
     ].
-    (char == $l 
-    or:[char == $h]) ifTrue: [
+
+    TraceCSI == true ifTrue:[ self traceCSI:char ].
+    (char == $l or:[char == $h]) ifTrue: [
         "/ (parameters at: 1) = 1 ifTrue: [app_cur_keys:(char == $h)].
         "/ (parameters at: 1) = 2 ifTrue: [mode132:(char == $h)].
         "/ (parameters at: 1) = 4 ifTrue: [smoothScroll:(char == $h)].
@@ -695,6 +732,7 @@
     #unknown - unknown character for this state
 "
 
+    TraceCSI == true ifTrue:[ self traceCSI:char ].
     ^ #unknown
 !
 
@@ -717,6 +755,8 @@
         self addToParameter:char.
         ^ #waitForNextChar
     ].
+
+    TraceCSI == true ifTrue:[ self traceCSI:char ].
     char == $@ ifTrue: [
         self endEntry.
         self insertCharacters.
@@ -843,6 +883,8 @@
         state := #gotCSI3.
         ^ #waitForNextChar
     ].
+
+    TraceCSI == true ifTrue:[ self traceCSI:char ].
     char == $) ifTrue: [ 
         "/ ESC-(
         "/ todo: set-charset 1 ...
@@ -925,6 +967,7 @@
 "
 
     char == (Character value:7) ifTrue: [
+        TraceCSI == true ifTrue:[ self traceCSI:char ].
         parameters at:currentParam put:(parameters at:currentParam) contents.
         self osCommand.
         ^ #sequenceComplete
@@ -947,6 +990,7 @@
         state := #gotXTERMCSI2. 
         ^ #waitForNextChar
     ].
+
     char isDigit ifTrue: [
         self addToParameter:char.
         ^ #waitForNextChar
@@ -978,6 +1022,6 @@
 !VT100TerminalView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.45 2013-05-24 14:36:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.46 2013-07-09 09:32:30 cg Exp $'
 ! !