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