VT100TerminalView.st
changeset 6113 129313185a4b
parent 6112 de050a54008a
child 6123 864d5890f58e
--- a/VT100TerminalView.st	Fri Aug 16 23:10:04 2019 +0200
+++ b/VT100TerminalView.st	Sat Aug 17 00:04:26 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1998 by eXept Software AG
               All Rights Reserved
@@ -586,18 +588,27 @@
 !
 
 report
-    self halt:'unimplemented function'
-!
+    "ESC[<p1>n
+     currently, only cursor position is supported (param 6)"
+
+    |p1|
 
-reportTerminalType
-    "currently, only cursor position is supported (param 6)"
+    p1 := parameters at: 1.
+    p1 == 5 ifTrue:[
+        "/ report device status
+        self endEntry.
+        Debug ifTrue:[ Transcript showCR:'report device status'].
+        inStream nextPut:(Character esc).
+        inStream nextPut:$[. 
+        inStream nextPut:$0. 
+        inStream nextPut:$n. 
+        ^ self
+    ].
 
-    (parameters at: 1) == 6 ifTrue:[
+    p1 == 6 ifTrue:[
         "/ report position
         self endEntry.
-        Debug ifTrue:[
-            Transcript showCR:'report terminal type'
-        ].
+        Debug ifTrue:[ Transcript showCR:'report position'].
         inStream nextPut:(Character esc).
         inStream nextPutAll:'[' 
                             , cursorLine printString 
@@ -606,10 +617,52 @@
                             , 'R'.
         ^ self
     ].
-    (parameters at: 1) == 7 ifTrue:[
-        "/ display name 
+
+    "Created: / 11.6.1998 / 23:05:50 / cg"
+    "Modified: / 28.7.1998 / 00:54:30 / cg"
+!
+
+reportTerminalType
+    "ESC[<p1>c
+     currently, only cursor position is supported (param 6)"
+
+    |p1|
+
+    p1 := parameters at: 1.
+    p1 == 0 ifTrue:[
+        "/ report terminal type
+        self endEntry.
+        Debug ifTrue:[ Transcript showCR:'report terminal type'].
+        inStream nextPut:(Character esc).
+        inStream nextPut:$[. 
+        inStream nextPut:$?. 
+        inStream nextPut:$1. 
+        inStream nextPut:$;. 
+        inStream nextPut:$1. 
+        inStream nextPut:$0. 
+        inStream nextPut:$c. 
+        ^ self
     ].
 
+"/    p1 == 6 ifTrue:[
+"/        "/ report position
+"/        self endEntry.
+"/        Debug ifTrue:[ Transcript showCR:'report position'].
+"/        inStream nextPut:(Character esc).
+"/        inStream nextPutAll:'[' 
+"/                            , cursorLine printString 
+"/                            , ';' 
+"/                            , cursorCol printString
+"/                            , 'R'.
+"/        ^ self
+"/    ].
+"/    p1 == 7 ifTrue:[
+"/        "/ display name 
+"/        self endEntry.
+"/        Debug ifTrue:[ Transcript showCR:'report display name'].
+"/        ^ self
+"/    ].
+
     "Created: / 11.6.1998 / 23:05:50 / cg"
     "Modified: / 28.7.1998 / 00:54:30 / cg"
 !
@@ -617,17 +670,15 @@
 resetDefaults
     "Reset the default parameters"
 
-    |l1 l2|
+    |p1 p2|
 
 
-    l1 := (parameters at: 1).
-    l2 := (parameters at: 2).
-    Debug ifTrue:[
-        Transcript show:'resetDefaults:'; show:l1;show:' ';showCR:l2.
-    ].
-    (l1 ~~ 0 and:[l2 ~~ 0]) ifTrue:[
-        rangeStartLine := l1.
-        rangeEndLine := l2.
+    p1 := (parameters at:1) ? 0.
+    p2 := (parameters at:2) ? 0.
+    Debug ifTrue:[ Transcript show:'resetDefaults:'; show:p1;show:' ';showCR:p2 ].
+    (p1 ~~ 0 and:[p2 ~~ 0]) ifTrue:[
+        rangeStartLine := p1.
+        rangeEndLine := p2.
     ] ifFalse:[
 "/        self halt.
     ].
@@ -1029,25 +1080,25 @@
     char == $A ifTrue:[
         "/ ESC[#A                         - Moves cursor up # lines
         Debug ifTrue:[ Transcript showCR:'cursor up' ].
-        self doCursorUp:n.
+        self doCursorUp:(n max:1).
         ^ #sequenceComplete
     ].
     char == $B ifTrue: [
         "/ ESC[#B                         - Moves cursor down # lines
         Debug ifTrue:[ Transcript showCR:'cursor down' ].
-        self doCursorDown:n.
+        self doCursorDown:(n max:1).
         ^ #sequenceComplete
     ].
     char == $C ifTrue: [
         "/ ESC[#C                         - Moves cursor forward # spaces
         Debug ifTrue:[ Transcript showCR:'cursor right' ].
-        self doCursorRight:n.
+        self doCursorRight:(n max:1).
         ^ #sequenceComplete
     ].
     char == $D ifTrue: [
         "/ ESC[#D                         - Moves cursor back # spaces
         Debug ifTrue:[ Transcript showCR:'cursor left' ].
-        self doCursorLeft:n.
+        self doCursorLeft:(n max:1).
         ^ #sequenceComplete
     ].
     char == $E ifTrue: [
@@ -1084,9 +1135,7 @@
         "/ ESC[K                          - Clear to end of line
         self endEntry.
         self clearLines:(self getParameter:1 withDefault:0).
-        Debug ifTrue:[
-            Transcript showCR:'clear to EOL'.
-        ].
+        Debug ifTrue:[ Transcript showCR:'clear to EOL' ].
         ^ #sequenceComplete
     ].
     char == $L ifTrue: [