author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 30 May 2018 09:34:26 +0100 | |
branch | jv |
changeset 5814 | 70d07365a2d4 |
parent 5568 | a44d0289bfbf |
child 6066 | fc59a1fcfdcd |
permissions | -rw-r--r-- |
1361 | 1 |
" |
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
5814 | 3 |
COPYRIGHT (c) 2017 Jan Vrany |
1361 | 4 |
All Rights Reserved |
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
2076 | 13 |
"{ Package: 'stx:libwidg2' }" |
14 |
||
4800 | 15 |
"{ NameSpace: Smalltalk }" |
16 |
||
930 | 17 |
TerminalView subclass:#VT100TerminalView |
998 | 18 |
instanceVariableNames:'currentParam parameters lastCursorLine' |
4269 | 19 |
classVariableNames:'TraceCSI' |
920 | 20 |
poolDictionaries:'' |
21 |
category:'Views-TerminalViews' |
|
22 |
! |
|
23 |
||
927 | 24 |
!VT100TerminalView class methodsFor:'documentation'! |
25 |
||
2116 | 26 |
ansiEscapes |
27 |
" |
|
4291 | 28 |
see also: http://www.vt100.net/docs/vt100-ug/chapter3.html |
29 |
||
2116 | 30 |
ANSI ESCAPE SEQUENCES |
31 |
=============================================================================== |
|
32 |
Wherever you see '#', that should be replaced by the appropriate number. |
|
33 |
||
34 |
ESC code sequence Function |
|
35 |
------------------- --------------------------- |
|
36 |
Cursor Controls: |
|
37 |
ESC[#;#H or ESC[#;#f Moves cusor to line #, column # |
|
38 |
ESC[#A Moves cursor up # lines |
|
39 |
ESC[#B Moves cursor down # lines |
|
40 |
ESC[#C Moves cursor forward # spaces |
|
41 |
ESC[#D Moves cursor back # spaces |
|
42 |
ESC[#;#R Reports current cursor line & column |
|
43 |
ESC[s Saves cursor position for recall later |
|
44 |
ESC[u Return to saved cursor position |
|
45 |
||
46 |
Erase Functions: |
|
47 |
ESC[2J Clear screen and home cursor |
|
48 |
ESC[K Clear to end of line |
|
49 |
||
50 |
Set Graphics Rendition: |
|
51 |
ESC[#;#;....;#m Set display attributes where # is |
|
52 |
0 for normal display |
|
53 |
1 for bold on |
|
54 |
4 underline (mono only) |
|
55 |
5 blink on |
|
56 |
7 reverse video on |
|
57 |
8 nondisplayed (invisible) |
|
4801 | 58 |
|
2116 | 59 |
30 black foreground |
4801 | 60 |
31 faint red foreground |
61 |
32 faint green foreground |
|
62 |
33 faint yellow foreground |
|
63 |
34 faint blue foreground |
|
64 |
35 faint magenta foreground |
|
65 |
36 faint cyan foreground |
|
66 |
37 faint white (grey) foreground |
|
4800 | 67 |
39 reset to default foreground |
4801 | 68 |
|
2116 | 69 |
40 black background |
70 |
41 red background |
|
71 |
42 green background |
|
72 |
43 yellow background |
|
73 |
44 blue background |
|
74 |
45 magenta background |
|
75 |
46 cyan background |
|
76 |
47 white background |
|
4800 | 77 |
49 reset to default background |
2116 | 78 |
|
4801 | 79 |
90 grey foreground |
80 |
91 bright red foreground |
|
81 |
92 bright green foreground |
|
82 |
99 bright yellow foreground |
|
83 |
94 bright blue foreground |
|
84 |
95 bright magenta foreground |
|
85 |
96 bright cyan foreground |
|
86 |
97 bright white foreground |
|
87 |
||
88 |
100 grey background |
|
89 |
101 bright red background |
|
90 |
102 bright green background |
|
91 |
109 bright yellow background |
|
92 |
104 bright blue background |
|
93 |
105 bright magenta background |
|
94 |
106 bright cyan background |
|
95 |
107 bright white background |
|
96 |
||
2116 | 97 |
ESC[=#;7h or Put screen in indicated mode where # is |
98 |
ESC[=h or 0 for 40 x 25 black & white |
|
99 |
ESC[=0h or 1 for 40 x 25 color |
|
100 |
ESC[?7h 2 for 80 x 25 b&w |
|
101 |
3 for 80 x 25 color |
|
102 |
4 for 320 x 200 color graphics |
|
103 |
5 for 320 x 200 b & w graphics |
|
104 |
6 for 640 x 200 b & w graphics |
|
105 |
7 to wrap at end of line |
|
106 |
||
107 |
ESC[=#;7l or ESC[=l or Resets mode # set with above command |
|
108 |
ESC[=0l or ESC[?7l |
|
109 |
||
110 |
Keyboard Reassignments: |
|
111 |
ESC[#;#;...p Keyboard reassignment. The first ASCII |
|
112 |
or ESC[""string""p code defines which code is to be |
|
113 |
or ESC[#;""string"";#; changed. The remaining codes define |
|
114 |
#;""string"";#p what it is to be changed to. |
|
115 |
||
116 |
E.g. Reassign the Q and q keys to the A and a keys (and vice versa). |
|
117 |
ESC [65;81p A becomes Q |
|
118 |
ESC [97;113p a becomes q |
|
119 |
ESC [81;65p Q becomes A |
|
120 |
ESC [113;97p q becomes a |
|
121 |
||
122 |
E.g. Reassign the F10 key to a DIR command. |
|
123 |
ESC [0;68;""dir"";13p The 0;68 is the extended ASCII code |
|
124 |
for the F10 key and 13 is the ASCII |
|
125 |
code for a carriage return. |
|
126 |
||
127 |
Other function key codes F1=59,F2=60,F3=61,F4=62,F5=63 |
|
128 |
F6=64,F7=65,F8=66,F9=67,F10=68 |
|
129 |
" |
|
130 |
! |
|
131 |
||
1361 | 132 |
copyright |
133 |
" |
|
134 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
5814 | 135 |
COPYRIGHT (c) 2017 Jan Vrany |
1361 | 136 |
All Rights Reserved |
137 |
||
138 |
This software is furnished under a license and may be used |
|
139 |
only in accordance with the terms of that license and with the |
|
140 |
inclusion of the above copyright notice. This software may not |
|
141 |
be provided or otherwise made available to, or used by, any |
|
142 |
other person. No title to or ownership of the software is |
|
143 |
hereby transferred. |
|
144 |
" |
|
145 |
||
146 |
||
147 |
! |
|
148 |
||
927 | 149 |
documentation |
150 |
" |
|
5568
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
151 |
A VT100 / XTerm terminal emulator. |
1418 | 152 |
Most of the functionality is inherited from my superclass, |
5568
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
153 |
I redefine/specialize certain methods for VT100 / XTerm escape sequences |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
154 |
and VT100 / XTerm keyboard codes |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
155 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
156 |
== Keyboard Debugging == |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
157 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
158 |
In case some keys does not work as expected, do the folowing: |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
159 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
160 |
1. Turn on keyboard debugging by evaluating: |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
161 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
162 |
DebugKeyboard := false |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
163 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
164 |
2. Check what it actually sends to the program. |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
165 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
166 |
3. Open proper XTerm and run: |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
167 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
168 |
export TERM=xterm |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
169 |
tput smkx; cat |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
170 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
171 |
Then press desired key and see what is its keycode. |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
172 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
173 |
4. Update #vt100KeyCodes / #xtermKeyCodes accordingly |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
174 |
|
927 | 175 |
|
1419 | 176 |
BUGS: |
177 |
VT100 wrapMode (at right margin) is not supported |
|
178 |
this may lead to wrong display when a vi is started in a small window. |
|
179 |
||
927 | 180 |
[start with:] |
181 |
VT100TerminalView openShell |
|
1418 | 182 |
|
183 |
[see also:] |
|
184 |
VT52TerminalView |
|
185 |
TelnetTool |
|
5245 | 186 |
http://vt100.net/docs/vt220-rm/chapter4.html |
927 | 187 |
" |
188 |
! ! |
|
920 | 189 |
|
932 | 190 |
!VT100TerminalView methodsFor:'defaults'! |
927 | 191 |
|
4303 | 192 |
colorAtIndex:idx bright:bright |
193 |
|rgb| |
|
194 |
||
195 |
rgb := #( |
|
4800 | 196 |
#( 0 0 0 ) "/ black fg: ESC[30m / bg: ESC[40m |
197 |
#(170 0 0) "/ dark red |
|
198 |
#(0 170 0) "/ dark green |
|
199 |
#(170 85 0) "/ dark yellow |
|
200 |
#(0 0 170) "/ dark blue |
|
201 |
#(170 0 170) "/ dark magenta |
|
202 |
#(0 170 170 ) "/ dark cyan |
|
203 |
#(170 170 170) "/ dark white eg. light grey). |
|
4297 | 204 |
|
4800 | 205 |
#( 85 85 85 ) "/ bright black eg. darkGray fg: ESC[90m / bg: ESC[100m |
206 |
#(255 85 85) "/ bright red |
|
207 |
#(85 255 85) "/ bright green |
|
208 |
#(255 255 85) "/ bright yellow |
|
209 |
#(85 85 255) "/ bright blue |
|
210 |
#(255 85 255) "/ bright magenta |
|
211 |
#(85 255 255 ) "/ bright cyan |
|
4303 | 212 |
#(255 255 255) "/ white |
213 |
). |
|
214 |
||
215 |
^ Color |
|
4305 | 216 |
perform: #'redByte:greenByte:blueByte:' |
4303 | 217 |
withArguments:(rgb at:(idx + (bright ifTrue:[8] ifFalse:[0]))). |
4297 | 218 |
! |
219 |
||
4293 | 220 |
vt100AlternativeKeyCodes |
221 |
"return the alternative vt100 keyCode table" |
|
222 |
||
223 |
^ IdentityDictionary withKeysAndValues: |
|
224 |
#( |
|
225 |
#CursorUp '\eOA' |
|
226 |
#CursorDown '\eOB' |
|
227 |
#CursorRight '\eOC' |
|
228 |
#CursorLeft '\eOD' |
|
229 |
#Home '\eOH' |
|
230 |
#Escape '\e' |
|
231 |
#BackSpace '\b' |
|
232 |
#Return '\r' |
|
233 |
#Delete '\0177' |
|
234 |
#Tab '\t' |
|
235 |
||
236 |
#F1 '\eOP' |
|
237 |
#F2 '\eOQ' |
|
238 |
#F3 '\eOR' |
|
239 |
#F4 '\eOS' |
|
240 |
#F5 '\eOt' |
|
241 |
#F6 '\eOu' |
|
242 |
#F7 '\eOv' |
|
243 |
#F8 '\eOl' |
|
244 |
#F9 '\eOw' |
|
245 |
) |
|
246 |
! |
|
247 |
||
927 | 248 |
vt100KeyCodes |
1420 | 249 |
"return a vt100 keyCode table" |
250 |
||
927 | 251 |
^ IdentityDictionary withKeysAndValues: |
252 |
#( |
|
253 |
#CursorUp '\e[A' |
|
254 |
#CursorDown '\e[B' |
|
255 |
#CursorRight '\e[C' |
|
256 |
#CursorLeft '\e[D' |
|
4293 | 257 |
|
927 | 258 |
#Home '\e[H' |
5568
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
259 |
#End '\e[F' |
927 | 260 |
#Escape '\e' |
261 |
#BackSpace '\b' |
|
262 |
#Return '\r' |
|
5568
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
263 |
#Delete '\e[3~' |
1357 | 264 |
#Tab '\t' |
1352 | 265 |
|
266 |
#F1 '\eOP' |
|
267 |
#F2 '\eOQ' |
|
268 |
#F3 '\eOR' |
|
269 |
#F4 '\eOS' |
|
270 |
#F5 '\eOt' |
|
271 |
#F6 '\eOu' |
|
272 |
#F7 '\eOv' |
|
273 |
#F8 '\eOl' |
|
274 |
#F9 '\eOw' |
|
927 | 275 |
) |
276 |
||
5568
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
277 |
"Created: / 10-06-1998 / 15:13:01 / cg" |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
278 |
"Modified: / 05-05-1999 / 15:01:32 / cg" |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
279 |
"Modified (comment): / 20-06-2017 / 21:25:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
927 | 280 |
! ! |
281 |
||
282 |
!VT100TerminalView methodsFor:'functions'! |
|
283 |
||
284 |
addLines |
|
1420 | 285 |
"Add the appropriate number of blank lines (param 1) |
286 |
at the cursor position." |
|
927 | 287 |
|
1420 | 288 |
self addLines:((parameters at:1) max:1). |
927 | 289 |
self endOfSequence |
290 |
||
291 |
"Created: / 10.6.1998 / 14:48:03 / cg" |
|
292 |
! |
|
293 |
||
1420 | 294 |
addLines:aNumber |
927 | 295 |
"Add aNumber blank lines at the position indicated by the cursor." |
296 |
||
1420 | 297 |
aNumber timesRepeat:[ |
927 | 298 |
self insertLine:'' before:cursorLine |
299 |
] |
|
300 |
||
301 |
"Created: / 10.6.1998 / 14:49:30 / cg" |
|
302 |
! |
|
303 |
||
2192 | 304 |
clearLines:arg |
1420 | 305 |
"Clear some part of the current line, as indicated by the first parameter: |
306 |
0 - clear to EOL |
|
307 |
1 - clear from beginning to cursorCol |
|
308 |
2 - clear entire line |
|
309 |
" |
|
927 | 310 |
|
1001
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
311 |
arg = 0 ifTrue: [^self doClearToEndOfLine]. |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
312 |
arg = 1 ifTrue: [^self doClearFromBeginningOfLine]. |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
313 |
arg = 2 ifTrue: [^self doClearEntireLine] |
927 | 314 |
|
315 |
"Created: / 10.6.1998 / 14:44:22 / cg" |
|
1001
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
316 |
"Modified: / 21.7.1998 / 20:07:42 / cg" |
927 | 317 |
! |
318 |
||
949 | 319 |
deleteCharacters |
1420 | 320 |
"Delete the appropriate number of characters (param 1) |
321 |
at the cursor position." |
|
949 | 322 |
|
323 |
|n| |
|
324 |
||
4863 | 325 |
n := parameters at: 1. |
326 |
n isNil ifTrue:[^ self]. |
|
327 |
n := n max: 1. |
|
949 | 328 |
self deleteFromLine:cursorLine col:cursorCol toLine:cursorLine col:cursorCol+n-1. |
329 |
||
330 |
"Created: / 12.6.1998 / 21:19:02 / cg" |
|
331 |
"Modified: / 12.6.1998 / 21:19:15 / cg" |
|
332 |
! |
|
333 |
||
4296 | 334 |
deleteLines |
335 |
"Delete the appropriate number of lines (param 1) |
|
336 |
at the cursor position." |
|
337 |
||
338 |
|n| |
|
339 |
||
340 |
n := ((parameters at: 1) max: 1). |
|
341 |
self halt:'untested code'. |
|
342 |
self deleteFromLine:cursorLine toLine:cursorLine+n-1. |
|
343 |
! |
|
344 |
||
2192 | 345 |
displayMode:p1 |
1420 | 346 |
"Set the current display mode (emphasis) as specified by param 1." |
927 | 347 |
|
4297 | 348 |
"/ self endEntry. -- not needed (does not affect characters on screen or buffered or cursor position |
349 |
p1 == 0 ifTrue:[ |
|
350 |
self normal. |
|
351 |
^ self. |
|
352 |
]. |
|
1352 | 353 |
|
354 |
p1 == 1 ifTrue:[ |
|
951 | 355 |
"/ ESC-[-1-m -> bold |
356 |
||
1287
48e6c847a554
use red color instead of bold
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
357 |
"/ workaround: windows bold fonts are |
48e6c847a554
use red color instead of bold
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
358 |
"/ wider, leading to ugly looking output |
48e6c847a554
use red color instead of bold
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
359 |
"/ Therefore, use red color instead of bold |
5005 | 360 |
device isWindowsPlatform ifTrue:[ |
4298 | 361 |
self color:(Color red:80). |
1287
48e6c847a554
use red color instead of bold
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
362 |
] ifFalse:[ |
48e6c847a554
use red color instead of bold
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
363 |
self bold. |
48e6c847a554
use red color instead of bold
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
364 |
]. |
951 | 365 |
^ self. |
366 |
]. |
|
4303 | 367 |
p1 == 2 ifTrue:[ |
368 |
"/ faint - unsupported |
|
369 |
^ self. |
|
370 |
]. |
|
371 |
p1 == 3 ifTrue:[ |
|
372 |
"/ ESC-[-3-m -> italic |
|
373 |
||
374 |
self italic. |
|
375 |
^ self. |
|
376 |
]. |
|
1352 | 377 |
p1 == 4 ifTrue:[ |
378 |
"/ ESC-[-4-m -> underline |
|
379 |
||
380 |
self underline. |
|
381 |
^ self. |
|
382 |
]. |
|
383 |
p1 == 5 ifTrue:[ |
|
384 |
"/ ESC-[-5-m -> blink |
|
385 |
||
386 |
self color:Color blue. |
|
387 |
^ self. |
|
388 |
]. |
|
4303 | 389 |
p1 == 6 ifTrue:[ |
390 |
"/ ESC-[-5-m -> blink rapid - unsupported |
|
391 |
^ self. |
|
392 |
]. |
|
1352 | 393 |
p1 == 7 ifTrue:[ |
394 |
"/ ESC-[-7-m -> reverse |
|
951 | 395 |
|
978 | 396 |
self reverse. |
397 |
^ self. |
|
398 |
]. |
|
2116 | 399 |
p1 == 8 ifTrue:[ |
400 |
"/ ESC-[-8-m -> invisible |
|
401 |
^ self. |
|
402 |
]. |
|
4303 | 403 |
p1 == 9 ifTrue:[ |
404 |
"/ ESC-[-9-m -> crossed out - unsupported |
|
405 |
^ self. |
|
406 |
]. |
|
407 |
p1 == 10 ifTrue:[ |
|
408 |
"/ ESC-[-10-m -> primary font - unsupported |
|
409 |
^ self. |
|
410 |
]. |
|
411 |
(p1 between:11 and:19) ifTrue:[ |
|
412 |
"/ alternate fonts - unsupported |
|
413 |
^ self. |
|
414 |
]. |
|
415 |
p1 == 20 ifTrue:[ |
|
416 |
"/ fraktur - unsupported |
|
417 |
^ self. |
|
418 |
]. |
|
419 |
p1 == 21 ifTrue:[ |
|
420 |
"/ ESC-[-21-m -> not bold |
|
421 |
self notBold. |
|
422 |
^ self. |
|
423 |
]. |
|
424 |
p1 == 23 ifTrue:[ |
|
425 |
"/ ESC-[-23-m -> not italic |
|
426 |
self notItalic. |
|
427 |
^ self. |
|
428 |
]. |
|
429 |
p1 == 24 ifTrue:[ |
|
430 |
"/ ESC-[-24-m -> not underline |
|
431 |
self notUnderline. |
|
432 |
^ self. |
|
433 |
]. |
|
434 |
p1 == 25 ifTrue:[ |
|
435 |
"/ ESC-[-25-m -> not blinking - unsupported |
|
436 |
^ self. |
|
437 |
]. |
|
438 |
p1 == 28 ifTrue:[ |
|
439 |
"/ ESC-[-28-m -> not invisible/reveal - unsupported |
|
440 |
^ self. |
|
441 |
]. |
|
442 |
p1 == 29 ifTrue:[ |
|
443 |
"/ ESC-[-29-m -> not crossed out - unsupported |
|
444 |
^ self. |
|
445 |
]. |
|
2116 | 446 |
(p1 between:30 and:37) ifTrue:[ |
447 |
"/ ESC-[-30-m -> black fg color |
|
448 |
"/ ESC-[-31-m -> red fg color |
|
449 |
"/ ... |
|
450 |
"/ ESC-[-37-m -> white fg color |
|
4298 | 451 |
noColors ifFalse:[ |
4303 | 452 |
self color:(self colorAtIndex:(p1-30+1) bright:false). |
4298 | 453 |
]. |
2116 | 454 |
^ self. |
455 |
]. |
|
4303 | 456 |
p1 == 38 ifTrue:[ |
457 |
"/ xterm 256 color - unsupported |
|
458 |
^ self |
|
459 |
]. |
|
4296 | 460 |
p1 == 39 ifTrue:[ |
461 |
"/ normal fg color |
|
462 |
self color:nil. |
|
463 |
^ self |
|
464 |
]. |
|
2116 | 465 |
(p1 between:40 and:47) ifTrue:[ |
466 |
"/ ESC-[-40-m -> black bg color |
|
467 |
"/ ... |
|
468 |
"/ ESC-[-47-m -> white bg color |
|
4298 | 469 |
noColors ifFalse:[ |
4303 | 470 |
self bgColor:(self colorAtIndex:(p1-40+1) bright:false). |
4298 | 471 |
]. |
2116 | 472 |
^ self. |
473 |
]. |
|
4303 | 474 |
p1 == 48 ifTrue:[ |
475 |
"/ xterm 256 bg color - unsupported |
|
476 |
^ self |
|
477 |
]. |
|
4296 | 478 |
p1 == 49 ifTrue:[ |
4303 | 479 |
"/ normal bg color |
4296 | 480 |
self bgColor:nil. |
481 |
^ self |
|
482 |
]. |
|
483 |
||
484 |
(p1 between:90 and:97) ifTrue:[ |
|
4303 | 485 |
"/ fg color high intensity |
4298 | 486 |
noColors ifFalse:[ |
4303 | 487 |
self color:(self colorAtIndex:(p1-90+1) bright:true). |
4298 | 488 |
]. |
4296 | 489 |
^ self. |
490 |
]. |
|
491 |
(p1 between:100 and:107) ifTrue:[ |
|
4303 | 492 |
"/ bg color high intensity |
4298 | 493 |
noColors ifFalse:[ |
4303 | 494 |
self bgColor:(self colorAtIndex:(p1-100+1) bright:true). |
4298 | 495 |
]. |
4296 | 496 |
^ self. |
497 |
]. |
|
1020 | 498 |
|
978 | 499 |
"/ ESC-[-any-m -> normal |
500 |
self normal. |
|
927 | 501 |
|
502 |
"Created: / 10.6.1998 / 15:01:16 / cg" |
|
1352 | 503 |
"Modified: / 5.5.1999 / 00:53:15 / cg" |
927 | 504 |
! |
505 |
||
2192 | 506 |
doClearDisplay:arg |
1420 | 507 |
"Clear some part of the current screen, as indicated by the first parameter. |
508 |
0 - clear to endOfScreen |
|
509 |
1 - clear from beginning of screen to cursorCol |
|
510 |
2 - clear entire screen |
|
511 |
" |
|
1001
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
512 |
|
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
513 |
arg = 0 ifTrue: [^self doClearToEndOfScreen]. |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
514 |
arg = 1 ifTrue: [^self doClearFromBeginningOfScreen]. |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
515 |
arg = 2 ifTrue: [^self doClearEntireScreen] |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
516 |
|
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
517 |
"Created: / 21.7.1998 / 20:05:07 / cg" |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
518 |
"Modified: / 21.7.1998 / 20:07:36 / cg" |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
519 |
! |
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
520 |
|
4296 | 521 |
doCursorNextLine:n |
522 |
self halt:'unimplemented function'. |
|
523 |
! |
|
524 |
||
525 |
doCursorPreviousLine:n |
|
526 |
self halt:'unimplemented function'. |
|
527 |
! |
|
528 |
||
1020 | 529 |
insertCharacters |
1420 | 530 |
"Insert the appropriate number of spaces (param 1) at the cursor position." |
949 | 531 |
|
532 |
|s| |
|
533 |
||
534 |
s := String new:((parameters at: 1) max: 1). |
|
1420 | 535 |
self insertStringWithoutCRs:s atLine:cursorLine col:cursorCol. |
949 | 536 |
|
537 |
"Modified: / 12.6.1998 / 21:14:25 / cg" |
|
1020 | 538 |
"Created: / 28.7.1998 / 00:53:51 / cg" |
949 | 539 |
! |
540 |
||
4296 | 541 |
insertLines |
542 |
"Insert the appropriate number of lines (param 1) at the cursor position." |
|
543 |
||
544 |
|n| |
|
545 |
||
546 |
n := (parameters at: 1) max: 1. |
|
547 |
self halt:'untested code'. |
|
548 |
self insertLines:(Array new:n) before:cursorLine |
|
549 |
! |
|
550 |
||
927 | 551 |
move |
552 |
"Move to the locations indicated by the first and second parameters." |
|
553 |
||
2217 | 554 |
| row column | |
555 |
||
556 |
row := (self getParameter:1 withDefault:1). |
|
557 |
column := (self getParameter:2 withDefault:1). |
|
2202 | 558 |
Debug ifTrue:[ |
2217 | 559 |
Transcript show:'move to column/row:'; show:column; show:'/'; showCR:row. |
560 |
]. |
|
561 |
self moveToX:column y:row. |
|
927 | 562 |
|
563 |
"Created: / 10.6.1998 / 14:40:01 / cg" |
|
978 | 564 |
"Modified: / 20.6.1998 / 18:49:12 / cg" |
927 | 565 |
! |
566 |
||
4296 | 567 |
moveToColumn |
568 |
"Move to the column indicated by the first." |
|
569 |
||
570 |
| column | |
|
571 |
||
572 |
column := (self getParameter:1 withDefault:1). |
|
573 |
Debug ifTrue:[ |
|
574 |
Transcript show:'move to column:'; showCR:column. |
|
575 |
]. |
|
576 |
self cursorVisibleLine:cursorLine col:column. |
|
577 |
! |
|
578 |
||
579 |
moveToLine |
|
580 |
"Move to the line indicated by the first param." |
|
581 |
||
582 |
| row | |
|
583 |
||
584 |
row := (self getParameter:1 withDefault:1). |
|
585 |
Debug ifTrue:[ |
|
586 |
Transcript show:'move to row:'; showCR:row. |
|
587 |
]. |
|
588 |
self cursorVisibleLine:row col:cursorCol. |
|
589 |
! |
|
590 |
||
927 | 591 |
moveToX: xLocation y: yLocation |
592 |
"Position the cursor at the location given by xLocation and yLocation. |
|
593 |
Ignore the command if the parameters are outside the allowable range." |
|
594 |
||
2192 | 595 |
Debug ifTrue:[ |
596 |
Transcript show:'numberOfColumns '; showCR:numberOfColumns. |
|
597 |
Transcript show:'numberOfLines '; showCR:numberOfLines. |
|
598 |
]. |
|
978 | 599 |
"/ (xLocation < 1 or: [xLocation > numberOfColumns]) ifTrue: [^self]. |
600 |
"/ (yLocation < 1 or: [yLocation > numberOfLines]) ifTrue: [^self]. |
|
952 | 601 |
|
949 | 602 |
self cursorVisibleLine:yLocation col:xLocation. |
927 | 603 |
|
604 |
"Created: / 10.6.1998 / 14:40:49 / cg" |
|
978 | 605 |
"Modified: / 20.6.1998 / 20:27:11 / cg" |
927 | 606 |
! |
607 |
||
4296 | 608 |
report |
609 |
self halt:'unimplemented function' |
|
610 |
! |
|
611 |
||
944 | 612 |
reportTerminalType |
1420 | 613 |
"currently, only cursor position is supported (param 6)" |
614 |
||
944 | 615 |
(parameters at: 1) == 6 ifTrue:[ |
616 |
"/ report position |
|
1020 | 617 |
self endEntry. |
4286 | 618 |
Debug ifTrue:[ |
619 |
Transcript showCR:'report terminal type' |
|
620 |
]. |
|
944 | 621 |
inStream nextPut:(Character esc). |
622 |
inStream nextPutAll:'[' |
|
623 |
, cursorLine printString |
|
624 |
, ';' |
|
625 |
, cursorCol printString |
|
626 |
, 'R'. |
|
627 |
^ self |
|
628 |
]. |
|
629 |
(parameters at: 1) == 7 ifTrue:[ |
|
630 |
"/ display name |
|
631 |
]. |
|
632 |
||
633 |
"Created: / 11.6.1998 / 23:05:50 / cg" |
|
1020 | 634 |
"Modified: / 28.7.1998 / 00:54:30 / cg" |
944 | 635 |
! |
636 |
||
927 | 637 |
resetDefaults |
638 |
"Reset the default parameters" |
|
639 |
||
2192 | 640 |
|l1 l2| |
949 | 641 |
|
978 | 642 |
|
949 | 643 |
l1 := (parameters at: 1). |
644 |
l2 := (parameters at: 2). |
|
2192 | 645 |
Debug ifTrue:[ |
646 |
Transcript show:'resetDefaults:'; show:l1;show:' ';showCR:l2. |
|
647 |
]. |
|
949 | 648 |
(l1 ~~ 0 and:[l2 ~~ 0]) ifTrue:[ |
649 |
rangeStartLine := l1. |
|
650 |
rangeEndLine := l2. |
|
651 |
] ifFalse:[ |
|
978 | 652 |
"/ self halt. |
949 | 653 |
]. |
654 |
||
978 | 655 |
"/ (rangeStartLine == 1 and:[rangeEndLine == numberOfLines]) ifTrue:[ |
656 |
"/ rangeEndLine := rangeStartLine := nil. |
|
657 |
"/ ]. |
|
658 |
||
4291 | 659 |
alternateKeypadMode := false. |
978 | 660 |
"/ autoLineFeed := false. |
661 |
"/ autoMargin := true. |
|
662 |
"/ displayMode := 0. "Normal display"!! !! |
|
927 | 663 |
|
664 |
"Created: / 10.6.1998 / 14:50:53 / cg" |
|
978 | 665 |
"Modified: / 20.6.1998 / 20:28:26 / cg" |
920 | 666 |
! ! |
667 |
||
668 |
!VT100TerminalView methodsFor:'initialization'! |
|
669 |
||
927 | 670 |
initialize |
671 |
super initialize. |
|
949 | 672 |
|
2268 | 673 |
autoWrapFlag := true. |
4291 | 674 |
alternateKeypadMode := false. |
2192 | 675 |
parameters := Array new:8. |
927 | 676 |
self endOfSequence |
677 |
||
678 |
"Created: / 10.6.1998 / 14:46:07 / cg" |
|
953 | 679 |
"Modified: / 13.6.1998 / 13:58:01 / cg" |
927 | 680 |
! |
681 |
||
682 |
initializeKeyboardSequences |
|
1420 | 683 |
"setup my keyboard sequences for a vt100" |
684 |
||
927 | 685 |
kbdSequences := (self vt100KeyCodes) |
686 |
||
687 |
"Modified: / 9.6.1998 / 20:49:21 / cg" |
|
688 |
"Created: / 10.6.1998 / 15:12:32 / cg" |
|
689 |
! ! |
|
690 |
||
4269 | 691 |
!VT100TerminalView methodsFor:'misc'! |
692 |
||
693 |
traceCSI:char |
|
694 |
state infoPrint. '-' infoPrint. |
|
5155 | 695 |
char codePoint > 32 ifTrue:[ |
4269 | 696 |
char infoPrint. |
697 |
] ifFalse:[ |
|
698 |
'0x' infoPrint. char codePoint hexPrintString infoPrint. |
|
699 |
]. |
|
700 |
currentParam > 1 ifTrue:[ |
|
701 |
' ' infoPrint. |
|
702 |
(parameters at:1) infoPrintCR. |
|
703 |
||
704 |
currentParam > 2 ifTrue:[ |
|
705 |
' ' infoPrint. |
|
706 |
(parameters at:2) infoPrintCR. |
|
707 |
||
708 |
currentParam > 3 ifTrue:[ |
|
709 |
' ' infoPrint. |
|
710 |
(parameters at:3) infoPrintCR. |
|
711 |
]. |
|
712 |
]. |
|
713 |
]. |
|
714 |
! ! |
|
715 |
||
4221 | 716 |
!VT100TerminalView methodsFor:'os functions (xterm)'! |
717 |
||
718 |
osCommand |
|
4804 | 719 |
"this is an xterm escape sequence, which controls |
720 |
the window's title, icon, or other property" |
|
721 |
||
4221 | 722 |
|cmdKey cmdValue| |
723 |
||
724 |
cmdKey := parameters at:1. |
|
725 |
cmdValue := parameters at:2. |
|
4269 | 726 |
|
4221 | 727 |
cmdKey == 0 ifTrue:[ |
728 |
"/ change icon name and window title |
|
729 |
masterWindow notNil ifTrue:[ |
|
730 |
masterWindow label:cmdValue. |
|
731 |
masterWindow iconLabel:cmdValue. |
|
732 |
]. |
|
733 |
self endOfSequence. |
|
734 |
^ self. |
|
735 |
]. |
|
736 |
cmdKey == 1 ifTrue:[ |
|
737 |
"/ change icon name |
|
738 |
masterWindow notNil ifTrue:[ |
|
739 |
masterWindow iconLabel:cmdValue. |
|
740 |
]. |
|
741 |
self endOfSequence. |
|
742 |
^ self. |
|
743 |
]. |
|
744 |
cmdKey == 2 ifTrue:[ |
|
745 |
"/ change window title |
|
746 |
masterWindow notNil ifTrue:[ |
|
747 |
masterWindow label:cmdValue. |
|
748 |
]. |
|
749 |
self endOfSequence. |
|
750 |
^ self. |
|
751 |
]. |
|
752 |
cmdKey == 3 ifTrue:[ |
|
753 |
"/ set x property |
|
754 |
self endOfSequence. |
|
755 |
^ self. |
|
756 |
]. |
|
757 |
cmdKey == 4 ifTrue:[ |
|
758 |
"/ change color |
|
759 |
self endOfSequence. |
|
760 |
^ self. |
|
761 |
]. |
|
762 |
self breakPoint:#cg. |
|
763 |
self endOfSequence |
|
764 |
! ! |
|
765 |
||
2498 | 766 |
!VT100TerminalView methodsFor:'processing-input'! |
927 | 767 |
|
2194 | 768 |
addToParameter:char |
927 | 769 |
"The parameter char is a digit. Add it to the current parameter." |
770 |
||
771 |
| param | |
|
772 |
||
2192 | 773 |
param := (parameters at:currentParam) ? 0. |
927 | 774 |
parameters at:currentParam put:(param * 10 + char digitValue) |
775 |
||
776 |
"Created: / 10.6.1998 / 14:39:00 / cg" |
|
777 |
! |
|
778 |
||
1420 | 779 |
endOfSequence |
780 |
"private - reset state-machine at end of escape-sequence" |
|
927 | 781 |
|
782 |
state := 0. |
|
783 |
currentParam := 1. |
|
2192 | 784 |
"/ parameters := Array new:8 withAll:0. |
785 |
parameters atAllPut:nil. |
|
927 | 786 |
|
787 |
"Created: / 10.6.1998 / 14:30:40 / cg" |
|
788 |
"Modified: / 10.6.1998 / 14:30:57 / cg" |
|
789 |
! |
|
790 |
||
4269 | 791 |
evaluateProcessCharacter:char return:aSymbol |
4447
1ea9b1d38a4b
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4320
diff
changeset
|
792 |
" evaluate the return value of the process state method except for state 0 |
2207 | 793 |
" |
794 |
||
4271 | 795 |
aSymbol isNil ifTrue:[ |
796 |
^ self. |
|
797 |
]. |
|
2207 | 798 |
aSymbol == #waitForNextChar ifTrue:[ |
799 |
^ self. |
|
800 |
]. |
|
801 |
aSymbol == #unknown ifTrue:[ |
|
4270 | 802 |
('VT100TerminalView [info]: unknown character %1 in state %2' |
4269 | 803 |
bindWith:(char codePoint hexPrintString) |
804 |
with:state) infoPrintCR. |
|
2207 | 805 |
self doNothing. |
806 |
^ self |
|
807 |
]. |
|
808 |
aSymbol == #sequenceComplete ifTrue:[ |
|
809 |
self endOfSequence. |
|
810 |
^ self. |
|
811 |
]. |
|
4269 | 812 |
self halt:'unexpected return value from state processing' |
2207 | 813 |
! |
814 |
||
815 |
nextPut:char |
|
4286 | 816 |
" process a character (i.e. from the shell's output)" |
937 | 817 |
|
2202 | 818 |
|processCharacterReturn| |
932 | 819 |
|
2192 | 820 |
Debug ifTrue:[ |
2202 | 821 |
Transcript |
4286 | 822 |
show:'VT100: nextPut - state: '; show:state; |
823 |
show:' got: '; |
|
2202 | 824 |
showCR:char storeString |
2192 | 825 |
]. |
4291 | 826 |
"/ char == Character return ifTrue:[self halt]. |
4289 | 827 |
state == 0 ifTrue:[ |
828 |
processCharacterReturn := self processState0:char. |
|
829 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
|
830 |
^ self |
|
831 |
]. |
|
2207 | 832 |
state == #gotReturn ifTrue:[ |
833 |
processCharacterReturn := self processStateGotReturn:char. |
|
834 |
processCharacterReturn == #sequenceComplete ifTrue:[ |
|
2350
0f9ca9ecf77a
the state have to be reset if sequence is complete in #gotReturn
penk
parents:
2268
diff
changeset
|
835 |
self endOfSequence. |
2207 | 836 |
^ self. |
837 |
]. |
|
4269 | 838 |
^ self |
2207 | 839 |
]. |
840 |
state == #gotESC ifTrue:[ |
|
841 |
processCharacterReturn := self processStateGotESC:char. |
|
4269 | 842 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 843 |
^ self. |
927 | 844 |
]. |
2207 | 845 |
state == #gotCSI ifTrue:[ |
846 |
processCharacterReturn := self processStateGotCSI:char. |
|
4269 | 847 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 848 |
^ self. |
2202 | 849 |
]. |
2207 | 850 |
state == #gotCSI2 ifTrue:[ |
851 |
processCharacterReturn := self processStateGotCSI2:char. |
|
4269 | 852 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 853 |
^ self. |
2192 | 854 |
]. |
2207 | 855 |
state == #gotCSI3 ifTrue:[ |
856 |
processCharacterReturn := self processStateGotCSI3:char. |
|
4269 | 857 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 858 |
^ self. |
2192 | 859 |
]. |
2207 | 860 |
state == #gotXTERMCSI ifTrue:[ |
861 |
processCharacterReturn := self processStateGotXTERMCSI:char. |
|
4269 | 862 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 863 |
^ self. |
927 | 864 |
]. |
4221 | 865 |
state == #gotXTERMCSI2 ifTrue:[ |
866 |
processCharacterReturn := self processStateGotXTERMCSI2:char. |
|
4269 | 867 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
4221 | 868 |
^ self. |
869 |
]. |
|
870 |
self halt:'unknown state'. |
|
2192 | 871 |
self doNothing. |
872 |
^ self |
|
2202 | 873 |
! |
874 |
||
2207 | 875 |
processState0:char |
5245 | 876 |
"next char in initial state |
877 |
change state or processing character; |
|
878 |
return |
|
879 |
#waitForNextChar - state was changed and wait for next characters |
|
880 |
#sequenceComplete - command processed |
|
881 |
#unknown - unknown character for this state |
|
882 |
" |
|
2202 | 883 |
|
5155 | 884 |
char codePoint < 32 ifTrue:[ |
2207 | 885 |
(char == Character esc) ifTrue:[ |
886 |
state := #gotESC. |
|
887 |
^ #waitForNextChar |
|
888 |
]. |
|
4269 | 889 |
|
2202 | 890 |
( char == Character nl "nl or '\n'" |
4283 | 891 |
or:[(char == (Character value:16r0b))]) ifTrue:[ |
2207 | 892 |
translateNLToCRNL == true ifTrue:[ |
893 |
self endEntry. |
|
894 |
self cursorToBeginOfLine. |
|
895 |
]. |
|
2202 | 896 |
self endEntry. |
897 |
self doCursorDown:1. |
|
2207 | 898 |
^ #waitForNextChar. |
2202 | 899 |
]. |
4269 | 900 |
|
2202 | 901 |
(char == Character return) ifTrue:[ |
4291 | 902 |
(rangeEndLine notNil and:[rangeEndLine ~~ numberOfLines]) ifTrue:[ |
2202 | 903 |
self endEntry. |
904 |
self cursorToBeginOfLine. |
|
905 |
] ifFalse:[ |
|
906 |
state := #gotReturn. |
|
907 |
]. |
|
2207 | 908 |
^ #waitForNextChar. |
2202 | 909 |
]. |
4269 | 910 |
|
2202 | 911 |
(char == Character backspace) ifTrue:[ |
912 |
self endEntry. |
|
913 |
self cursorLeft. |
|
2207 | 914 |
^ #waitForNextChar "/ doBackspace |
2202 | 915 |
]. |
4269 | 916 |
|
2202 | 917 |
(char == Character bell) ifTrue:[ |
2782 | 918 |
self shown ifTrue:[ |
919 |
self beep. |
|
920 |
]. |
|
2207 | 921 |
^ #waitForNextChar |
2202 | 922 |
]. |
4269 | 923 |
|
2202 | 924 |
(char == (Character value:5)) ifTrue:[ |
925 |
"/ Transmission answerback message |
|
926 |
self reportTerminalType. |
|
2207 | 927 |
^ #waitForNextChar |
2202 | 928 |
]. |
4269 | 929 |
|
2202 | 930 |
( char == (Character value:16r18) "/Cancel |
931 |
or:[ char == (Character value:16r1A) "/Substitute |
|
932 |
]) ifTrue:[ |
|
933 |
self nextPut:(Character value:16r2). |
|
2207 | 934 |
^ #waitForNextChar |
2202 | 935 |
] |
4269 | 936 |
|
2207 | 937 |
" |
4269 | 938 |
all unsupported control characters (also vt102): |
2207 | 939 |
Character value:16r3 ->End of text |
940 |
Character value:16r4 ->End of transmission |
|
941 |
Character tab ->Horizontal tab |
|
942 |
Character value:16rc ->Form feed |
|
943 |
Character value:16re ->SO shift out |
|
944 |
Character value:16rf ->SI shift in |
|
945 |
Character value:16r11 ->Device control 1 |
|
946 |
Character value:16r13 ->Device control 3 |
|
947 |
". |
|
948 |
char ~~ Character tab ifTrue:[ |
|
5155 | 949 |
char codePoint ~~ 0 ifTrue:[ |
2207 | 950 |
('VT100 [info]: unhandled control key: ' , char storeString) infoPrintCR. |
951 |
]. |
|
952 |
^ #waitForNextChar. |
|
953 |
] |
|
2202 | 954 |
]. |
4447
1ea9b1d38a4b
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4320
diff
changeset
|
955 |
self show:char. |
4271 | 956 |
^ nil |
2192 | 957 |
! |
958 |
||
959 |
processStateGotCSI2:char |
|
5245 | 960 |
"next char after 'ESC [ ?' (CSI ?) |
961 |
change state or processing character; |
|
962 |
return |
|
963 |
#waitForNextChar - state was changed and wait for next characters |
|
964 |
#sequenceComplete - command processed |
|
965 |
#unknown - unknown character for this state |
|
966 |
" |
|
2192 | 967 |
|
968 |
char == $; ifTrue: [ |
|
969 |
currentParam := (currentParam + 1) min: 8. |
|
970 |
^ #waitForNextChar |
|
971 |
]. |
|
972 |
char isDigit ifTrue: [ |
|
2194 | 973 |
self addToParameter:char. |
2192 | 974 |
^ #waitForNextChar |
975 |
]. |
|
4269 | 976 |
|
977 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
|
978 |
(char == $l or:[char == $h]) ifTrue: [ |
|
5245 | 979 |
"/ (parameters at: 1) = 1 ifTrue: [app_cur_keys:(char == $h) "DECCKM"]. |
980 |
"/ (parameters at: 1) = 2 ifTrue: [vt52mode:(char == $l) "DECANM"]. |
|
981 |
"/ (parameters at: 1) = 3 ifTrue: [mode132:(char == $h) "DECCOLM"]. |
|
982 |
"/ (parameters at: 1) = 4 ifTrue: [smoothScroll:(char == $h) "DECSCLM"]. |
|
983 |
"/ (parameters at: 1) = 5 ifTrue: [reverseVideo:(char == $h) "DECSCNM"]. |
|
984 |
"/ (parameters at: 1) = 6 ifTrue: [originMode:(char == $h) "DECOM"]. |
|
985 |
"/ (parameters at: 1) = 8 ifTrue: [autoKbdRepeat:(char == $h) "DECARM"]. |
|
986 |
"/ (parameters at: 1) = 25 ifTrue: [cursorVisible:(char == $h) "DECTCEM"]. |
|
2192 | 987 |
self endEntry. |
5245 | 988 |
(parameters at: 1) = 7 ifTrue: [self autoMargin:(char == $h) "DECAWM"]. |
2192 | 989 |
^ #sequenceComplete |
990 |
]. |
|
5245 | 991 |
(char == $n) ifTrue: [ |
992 |
"/ (parameters at: 1) = 15 ifTrue: [ ... ]. -- What is the printer status? |
|
993 |
"/ (parameters at: 1) = 25 ifTrue: [ ... ]. -- Are user-defined keys locked or unlocked? |
|
994 |
"/ (parameters at: 1) = 26 ifTrue: [ ... ]. -- What is the keyboard language? |
|
995 |
]. |
|
2192 | 996 |
^ #unknown |
997 |
! |
|
998 |
||
999 |
processStateGotCSI3:char |
|
5245 | 1000 |
"next char after 'ESC (' |
1001 |
change state or processing character; |
|
1002 |
return |
|
1003 |
#waitForNextChar - state was changed and wait for next characters |
|
1004 |
#sequenceComplete - command processed |
|
1005 |
#unknown - unknown character for this state |
|
1006 |
" |
|
2192 | 1007 |
|
4269 | 1008 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
2192 | 1009 |
^ #unknown |
1010 |
! |
|
1011 |
||
1012 |
processStateGotCSI:char |
|
5245 | 1013 |
"next char after 'ESC> [' (CSI) |
1014 |
change state or processing character; |
|
1015 |
return |
|
1016 |
#waitForNextChar - state was changed and wait for next characters |
|
1017 |
#sequenceComplete - command processed |
|
1018 |
#unknown - unknown character for this state |
|
1019 |
" |
|
2192 | 1020 |
|
1021 |
char == $? ifTrue: [ |
|
1022 |
state := #gotCSI2. |
|
1023 |
^ #waitForNextChar |
|
1024 |
]. |
|
1025 |
char == $; ifTrue:[ |
|
1026 |
currentParam := (currentParam + 1) min: 8. |
|
1027 |
^ #waitForNextChar |
|
1028 |
]. |
|
1029 |
char isDigit ifTrue: [ |
|
1030 |
self addToParameter:char. |
|
1031 |
^ #waitForNextChar |
|
1032 |
]. |
|
4269 | 1033 |
|
1034 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
|
2192 | 1035 |
char == $@ ifTrue: [ |
1036 |
self endEntry. |
|
1037 |
self insertCharacters. |
|
1038 |
^ #sequenceComplete |
|
1039 |
]. |
|
1040 |
char == $A ifTrue: [ |
|
1041 |
"/ ESC[#A - Moves cursor up # lines |
|
1042 |
self endEntry. |
|
2202 | 1043 |
self doCursorUp:(self getParameter:1 withDefault:1). |
2192 | 1044 |
^ #sequenceComplete |
1045 |
]. |
|
1046 |
char == $B ifTrue: [ |
|
1047 |
"/ ESC[#B - Moves cursor down # lines |
|
1048 |
self endEntry. |
|
2202 | 1049 |
self doCursorDown:(self getParameter:1 withDefault:1). |
2192 | 1050 |
^ #sequenceComplete |
1051 |
]. |
|
1052 |
char == $C ifTrue: [ |
|
1053 |
"/ ESC[#C - Moves cursor forward # spaces |
|
1054 |
self endEntry. |
|
2202 | 1055 |
self doCursorRight:(self getParameter:1 withDefault:1). |
2192 | 1056 |
^ #sequenceComplete |
1057 |
]. |
|
1058 |
char == $D ifTrue: [ |
|
1059 |
"/ ESC[#D - Moves cursor back # spaces |
|
1060 |
self endEntry. |
|
2202 | 1061 |
self doCursorLeft:(self getParameter:1 withDefault:1). |
2192 | 1062 |
^ #sequenceComplete |
1063 |
]. |
|
4296 | 1064 |
char == $E ifTrue: [ |
1065 |
"/ ESC[#E |
|
1066 |
self endEntry. |
|
1067 |
self doCursorNextLine:(self getParameter:1 withDefault:1). |
|
1068 |
^ #sequenceComplete |
|
1069 |
]. |
|
1070 |
char == $F ifTrue: [ |
|
1071 |
"/ ESC[#F |
|
1072 |
self endEntry. |
|
1073 |
self doCursorPreviousLine:(self getParameter:1 withDefault:1). |
|
1074 |
^ #sequenceComplete |
|
1075 |
]. |
|
1076 |
(char == $G) ifTrue: [ |
|
1077 |
"/ ESC[#;#G - Moves cusor to column # in current line |
|
1078 |
self endEntry. |
|
1079 |
self moveToColumn. |
|
1080 |
^ #sequenceComplete |
|
1081 |
]. |
|
2202 | 1082 |
(char == $H or:[char == $f]) ifTrue: [ |
2192 | 1083 |
"/ ESC[#;#H or ESC[#;#f - Moves cusor to line #, column # |
1084 |
self endEntry. |
|
2202 | 1085 |
self move. |
2192 | 1086 |
^ #sequenceComplete |
1087 |
]. |
|
1088 |
char == $J ifTrue: [ |
|
2217 | 1089 |
"/ ESC[0J - Clear screen to end |
1090 |
"/ ESC[1J - Clear screen from beginning |
|
2192 | 1091 |
"/ ESC[2J - Clear entire screen and home cursor |
1092 |
self endEntry. |
|
2207 | 1093 |
self doClearDisplay:(self getParameter:1 withDefault:0). |
2192 | 1094 |
^ #sequenceComplete |
1095 |
]. |
|
1096 |
char == $K ifTrue: [ |
|
1097 |
"/ ESC[K - Clear to end of line |
|
1098 |
self endEntry. |
|
2207 | 1099 |
self clearLines:(self getParameter:1 withDefault:0). |
2192 | 1100 |
Debug ifTrue:[ |
1101 |
Transcript showCR:'clear to EOL'. |
|
1102 |
]. |
|
1103 |
^ #sequenceComplete |
|
1104 |
]. |
|
1105 |
char == $L ifTrue: [ |
|
1106 |
self endEntry. |
|
1107 |
self insertLines. |
|
1108 |
^ #sequenceComplete |
|
1109 |
]. |
|
1110 |
char == $M ifTrue: [ |
|
1111 |
self endEntry. |
|
1112 |
self deleteLines. |
|
1113 |
^ #sequenceComplete |
|
1114 |
]. |
|
1115 |
char == $P ifTrue: [ |
|
1116 |
self endEntry. |
|
1117 |
self deleteCharacters. |
|
1118 |
^ #sequenceComplete |
|
1119 |
]. |
|
2202 | 1120 |
char == $R ifTrue: [ |
2192 | 1121 |
"/ ESC[#;#R - Reports current cursor line & column |
2207 | 1122 |
^ #unknown |
2192 | 1123 |
]. |
4296 | 1124 |
|
1125 |
char == $c ifTrue:[ |
|
2192 | 1126 |
"/ terminal-type query 3 |
1127 |
self reportTerminalType. |
|
1128 |
^ #sequenceComplete |
|
1129 |
]. |
|
4296 | 1130 |
char == $d ifTrue:[ |
1131 |
self endEntry. |
|
1132 |
self moveToLine. |
|
1133 |
^ #sequenceComplete |
|
1134 |
]. |
|
2192 | 1135 |
char == $n ifTrue: [ |
1136 |
self report. |
|
1137 |
^ #sequenceComplete |
|
1138 |
]. |
|
1139 |
char == $m ifTrue: [ |
|
4296 | 1140 |
"/ character attributes (SGR) |
4297 | 1141 |
1 to:currentParam do:[:pI | |
1142 |
self displayMode:(self getParameter:pI withDefault:0). |
|
1143 |
]. |
|
2192 | 1144 |
^ #sequenceComplete |
1145 |
]. |
|
1146 |
char == $r ifTrue: [ |
|
1147 |
self endEntry. |
|
1148 |
self resetDefaults. |
|
1149 |
^ #sequenceComplete |
|
1150 |
]. |
|
1151 |
char == $s ifTrue: [ |
|
1152 |
"/ ESC[s - Saves cursor position for recall later |
|
1153 |
self endEntry. |
|
1154 |
^ #sequenceComplete |
|
1155 |
]. |
|
1156 |
char == $u ifTrue: [ |
|
1157 |
"/ ESC[u - Return to saved cursor position |
|
1158 |
self endEntry. |
|
1159 |
^ #sequenceComplete |
|
1160 |
]. |
|
1161 |
^ #unknown |
|
1162 |
! |
|
1163 |
||
1164 |
processStateGotESC:char |
|
5245 | 1165 |
"next char after ESC |
1166 |
change state or processing character; |
|
1167 |
return |
|
1168 |
#waitForNextChar - state was changed and wait for next characters |
|
1169 |
#sequenceComplete - command processed |
|
1170 |
#unknown - unknown character for this state |
|
1171 |
" |
|
2192 | 1172 |
|
1173 |
char == $[ ifTrue: [ |
|
1174 |
"/ ESC-[ |
|
1175 |
state := #gotCSI. |
|
1176 |
^ #waitForNextChar |
|
1177 |
]. |
|
1178 |
char == $] ifTrue: [ |
|
1179 |
"/ ESC-] |
|
1180 |
"/xterm sequence |
|
1181 |
state := #gotXTERMCSI. |
|
1182 |
^ #waitForNextChar |
|
1183 |
]. |
|
1184 |
char == $( ifTrue: [ |
|
1185 |
"/ ESC-( |
|
1186 |
"/ todo: set-charset 0 ... |
|
1187 |
state := #gotCSI3. |
|
1188 |
^ #waitForNextChar |
|
1189 |
]. |
|
4269 | 1190 |
|
1191 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
|
2192 | 1192 |
char == $) ifTrue: [ |
1193 |
"/ ESC-( |
|
1194 |
"/ todo: set-charset 1 ... |
|
2207 | 1195 |
^ #unknown |
2192 | 1196 |
]. |
1197 |
char == $7 ifTrue:[ |
|
1198 |
"/ ESC-7 |
|
1199 |
self endEntry. |
|
1200 |
self saveCursor. |
|
1201 |
^ #sequenceComplete |
|
1202 |
]. |
|
1203 |
char == $8 ifTrue:[ |
|
1204 |
"/ ESC-7 |
|
1205 |
self endEntry. |
|
1206 |
self restoreCursor. |
|
1207 |
^ #sequenceComplete |
|
1208 |
]. |
|
1209 |
char == $M ifTrue:[ |
|
2217 | 1210 |
"/ ESC-M cursor up |
2192 | 1211 |
self endEntry. |
1212 |
self doCursorUp:1. |
|
1213 |
^ #sequenceComplete |
|
1214 |
]. |
|
1215 |
char == $D ifTrue:[ |
|
2217 | 1216 |
"/ ESC-D Index cursor down one line in same column |
2192 | 1217 |
self endEntry. |
1218 |
self doCursorDown:1. |
|
1219 |
^ #sequenceComplete |
|
1220 |
]. |
|
1221 |
char == $E ifTrue:[ |
|
1222 |
"/ ESC-E |
|
1223 |
"/ TODO add_lines |
|
2217 | 1224 |
self endEntry. |
1225 |
self cursorReturn. |
|
2192 | 1226 |
^ #sequenceComplete |
1227 |
]. |
|
1228 |
(char == $Z) ifTrue:[ |
|
1229 |
"/ terminal-type query 2 |
|
1230 |
self reportTerminalType. |
|
1231 |
^ #sequenceComplete |
|
1232 |
]. |
|
1233 |
char == $= ifTrue: [ |
|
4291 | 1234 |
"/ enter application keypad mode |
2192 | 1235 |
"/ ESC-= |
4291 | 1236 |
alternateKeypadMode := true. |
4293 | 1237 |
kbdSequences := (self vt100AlternativeKeyCodes). |
4291 | 1238 |
^ #sequenceComplete |
2192 | 1239 |
]. |
1240 |
char == $> ifTrue: [ |
|
4291 | 1241 |
"/ exit application keypad mode |
2192 | 1242 |
"/ ESC-< |
4291 | 1243 |
alternateKeypadMode := false. |
4293 | 1244 |
kbdSequences := (self vt100KeyCodes). |
4291 | 1245 |
^ #sequenceComplete |
2192 | 1246 |
]. |
1247 |
^ #unknown |
|
1248 |
! |
|
1249 |
||
2202 | 1250 |
processStateGotReturn:char |
5245 | 1251 |
"next char after CR |
1252 |
change state or processing character; |
|
1253 |
return |
|
1254 |
#waitForNextChar - state was changed and wait for next characters |
|
1255 |
#sequenceComplete - command processed |
|
1256 |
#unknown - unknown character for this state |
|
1257 |
" |
|
2202 | 1258 |
|
2207 | 1259 |
state := 0. |
2202 | 1260 |
char == Character nl ifTrue:[ |
1261 |
"/ cr-nl |
|
1262 |
"/ stay in buffering mode. |
|
4448 | 1263 |
self cr. |
2207 | 1264 |
^ #sequenceComplete. |
2202 | 1265 |
]. |
4291 | 1266 |
|
2202 | 1267 |
self endEntry. |
1268 |
self cursorToBeginOfLine. |
|
4448 | 1269 |
|
1270 |
(char == Character esc) ifTrue:[ |
|
1271 |
state := #gotESC. |
|
1272 |
]. |
|
1273 |
"/ continue in initial state |
|
1274 |
^ #waitForNextChar |
|
2202 | 1275 |
! |
1276 |
||
4221 | 1277 |
processStateGotXTERMCSI2:char |
5245 | 1278 |
"next char after 'ESC ] ;' |
1279 |
change state or processing character; |
|
1280 |
return |
|
1281 |
#waitForNextChar - state was changed and wait for next characters |
|
1282 |
#sequenceComplete - command processed |
|
1283 |
#unknown - unknown character for this state |
|
1284 |
" |
|
4221 | 1285 |
|
1286 |
char == (Character value:7) ifTrue: [ |
|
4269 | 1287 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
4221 | 1288 |
parameters at:currentParam put:(parameters at:currentParam) contents. |
1289 |
self osCommand. |
|
1290 |
^ #sequenceComplete |
|
1291 |
]. |
|
1292 |
"/ add to parameter |
|
1293 |
(parameters at:currentParam) nextPut:char. |
|
1294 |
^ #waitForNextChar |
|
1295 |
! |
|
1296 |
||
2192 | 1297 |
processStateGotXTERMCSI:char |
5245 | 1298 |
"next char after 'ESC ]' |
1299 |
change state or processing character; |
|
1300 |
return |
|
1301 |
#waitForNextChar - state was changed and wait for next characters |
|
1302 |
#sequenceComplete - command processed |
|
1303 |
#unknown - unknown character for this state |
|
1304 |
" |
|
2192 | 1305 |
|
4221 | 1306 |
char == $; ifTrue:[ |
1307 |
currentParam := (currentParam + 1) min: 8. |
|
1308 |
parameters at:currentParam put:(WriteStream on:''). |
|
1309 |
state := #gotXTERMCSI2. |
|
1310 |
^ #waitForNextChar |
|
1311 |
]. |
|
4269 | 1312 |
|
4221 | 1313 |
char isDigit ifTrue: [ |
1314 |
self addToParameter:char. |
|
1315 |
^ #waitForNextChar |
|
1316 |
]. |
|
2192 | 1317 |
^ #unknown |
920 | 1318 |
! ! |
1319 |
||
930 | 1320 |
!VT100TerminalView methodsFor:'queries'! |
1321 |
||
2202 | 1322 |
getParameter:para withDefault:default |
1323 |
||
1324 |
|parameter| |
|
1325 |
||
1326 |
parameter := (parameters at:para). |
|
1327 |
^ ((parameter isNil or:[parameter = 0]) ifTrue:[default] ifFalse:[parameter]). |
|
1328 |
! |
|
1329 |
||
930 | 1330 |
terminalType |
1420 | 1331 |
"returns a string describing this terminal (usually, this is |
1332 |
passed down to the shell as TERM environment variable). |
|
1333 |
Here, 'vt100' is returned." |
|
1334 |
||
4296 | 1335 |
"/ ^ 'xterm'. |
1355 | 1336 |
^ 'vt100' |
930 | 1337 |
|
1338 |
"Created: / 10.6.1998 / 16:22:39 / cg" |
|
1355 | 1339 |
"Modified: / 5.5.1999 / 11:22:40 / cg" |
930 | 1340 |
! ! |
1341 |
||
920 | 1342 |
!VT100TerminalView class methodsFor:'documentation'! |
1343 |
||
1344 |
version |
|
4800 | 1345 |
^ '$Header$' |
4286 | 1346 |
! |
1347 |
||
1348 |
version_CVS |
|
4800 | 1349 |
^ '$Header$' |
5568
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
1350 |
! |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
1351 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
1352 |
version_HG |
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
1353 |
|
a44d0289bfbf
`TerminalView`: added (XTerm) keycodes for 'Del' and 'End' keys
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5245
diff
changeset
|
1354 |
^ '$Changeset: <not expanded> $' |
920 | 1355 |
! ! |
4221 | 1356 |