author | Claus Gittinger <cg@exept.de> |
Wed, 26 Jun 2019 10:56:41 +0200 | |
changeset 6075 | 0c168e2e1937 |
parent 5548 | 709732bf7fad |
child 6112 | de050a54008a |
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 |
589 |
self halt:'unimplemented function' |
|
590 |
! |
|
591 |
||
944 | 592 |
reportTerminalType |
1420 | 593 |
"currently, only cursor position is supported (param 6)" |
594 |
||
944 | 595 |
(parameters at: 1) == 6 ifTrue:[ |
596 |
"/ report position |
|
1020 | 597 |
self endEntry. |
4286 | 598 |
Debug ifTrue:[ |
599 |
Transcript showCR:'report terminal type' |
|
600 |
]. |
|
944 | 601 |
inStream nextPut:(Character esc). |
602 |
inStream nextPutAll:'[' |
|
603 |
, cursorLine printString |
|
604 |
, ';' |
|
605 |
, cursorCol printString |
|
606 |
, 'R'. |
|
607 |
^ self |
|
608 |
]. |
|
609 |
(parameters at: 1) == 7 ifTrue:[ |
|
610 |
"/ display name |
|
611 |
]. |
|
612 |
||
613 |
"Created: / 11.6.1998 / 23:05:50 / cg" |
|
1020 | 614 |
"Modified: / 28.7.1998 / 00:54:30 / cg" |
944 | 615 |
! |
616 |
||
927 | 617 |
resetDefaults |
618 |
"Reset the default parameters" |
|
619 |
||
2192 | 620 |
|l1 l2| |
949 | 621 |
|
978 | 622 |
|
949 | 623 |
l1 := (parameters at: 1). |
624 |
l2 := (parameters at: 2). |
|
2192 | 625 |
Debug ifTrue:[ |
626 |
Transcript show:'resetDefaults:'; show:l1;show:' ';showCR:l2. |
|
627 |
]. |
|
949 | 628 |
(l1 ~~ 0 and:[l2 ~~ 0]) ifTrue:[ |
629 |
rangeStartLine := l1. |
|
630 |
rangeEndLine := l2. |
|
631 |
] ifFalse:[ |
|
978 | 632 |
"/ self halt. |
949 | 633 |
]. |
634 |
||
978 | 635 |
"/ (rangeStartLine == 1 and:[rangeEndLine == numberOfLines]) ifTrue:[ |
636 |
"/ rangeEndLine := rangeStartLine := nil. |
|
637 |
"/ ]. |
|
638 |
||
4291 | 639 |
alternateKeypadMode := false. |
978 | 640 |
"/ autoLineFeed := false. |
641 |
"/ autoMargin := true. |
|
642 |
"/ displayMode := 0. "Normal display"!! !! |
|
927 | 643 |
|
644 |
"Created: / 10.6.1998 / 14:50:53 / cg" |
|
978 | 645 |
"Modified: / 20.6.1998 / 20:28:26 / cg" |
920 | 646 |
! ! |
647 |
||
648 |
!VT100TerminalView methodsFor:'initialization'! |
|
649 |
||
927 | 650 |
initialize |
651 |
super initialize. |
|
949 | 652 |
|
2268 | 653 |
autoWrapFlag := true. |
4291 | 654 |
alternateKeypadMode := false. |
2192 | 655 |
parameters := Array new:8. |
927 | 656 |
self endOfSequence |
657 |
||
658 |
"Created: / 10.6.1998 / 14:46:07 / cg" |
|
953 | 659 |
"Modified: / 13.6.1998 / 13:58:01 / cg" |
927 | 660 |
! |
661 |
||
662 |
initializeKeyboardSequences |
|
1420 | 663 |
"setup my keyboard sequences for a vt100" |
664 |
||
927 | 665 |
kbdSequences := (self vt100KeyCodes) |
666 |
||
667 |
"Modified: / 9.6.1998 / 20:49:21 / cg" |
|
668 |
"Created: / 10.6.1998 / 15:12:32 / cg" |
|
669 |
! ! |
|
670 |
||
4269 | 671 |
!VT100TerminalView methodsFor:'misc'! |
672 |
||
673 |
traceCSI:char |
|
674 |
state infoPrint. '-' infoPrint. |
|
5155 | 675 |
char codePoint > 32 ifTrue:[ |
4269 | 676 |
char infoPrint. |
677 |
] ifFalse:[ |
|
678 |
'0x' infoPrint. char codePoint hexPrintString infoPrint. |
|
679 |
]. |
|
680 |
currentParam > 1 ifTrue:[ |
|
681 |
' ' infoPrint. |
|
682 |
(parameters at:1) infoPrintCR. |
|
683 |
||
684 |
currentParam > 2 ifTrue:[ |
|
685 |
' ' infoPrint. |
|
686 |
(parameters at:2) infoPrintCR. |
|
687 |
||
688 |
currentParam > 3 ifTrue:[ |
|
689 |
' ' infoPrint. |
|
690 |
(parameters at:3) infoPrintCR. |
|
691 |
]. |
|
692 |
]. |
|
693 |
]. |
|
694 |
! ! |
|
695 |
||
4221 | 696 |
!VT100TerminalView methodsFor:'os functions (xterm)'! |
697 |
||
698 |
osCommand |
|
4804 | 699 |
"this is an xterm escape sequence, which controls |
700 |
the window's title, icon, or other property" |
|
701 |
||
4221 | 702 |
|cmdKey cmdValue| |
703 |
||
704 |
cmdKey := parameters at:1. |
|
705 |
cmdValue := parameters at:2. |
|
4269 | 706 |
|
4221 | 707 |
cmdKey == 0 ifTrue:[ |
708 |
"/ change icon name and window title |
|
709 |
masterWindow notNil ifTrue:[ |
|
710 |
masterWindow label:cmdValue. |
|
711 |
masterWindow iconLabel:cmdValue. |
|
712 |
]. |
|
713 |
self endOfSequence. |
|
714 |
^ self. |
|
715 |
]. |
|
716 |
cmdKey == 1 ifTrue:[ |
|
717 |
"/ change icon name |
|
718 |
masterWindow notNil ifTrue:[ |
|
719 |
masterWindow iconLabel:cmdValue. |
|
720 |
]. |
|
721 |
self endOfSequence. |
|
722 |
^ self. |
|
723 |
]. |
|
724 |
cmdKey == 2 ifTrue:[ |
|
725 |
"/ change window title |
|
726 |
masterWindow notNil ifTrue:[ |
|
727 |
masterWindow label:cmdValue. |
|
728 |
]. |
|
729 |
self endOfSequence. |
|
730 |
^ self. |
|
731 |
]. |
|
732 |
cmdKey == 3 ifTrue:[ |
|
733 |
"/ set x property |
|
734 |
self endOfSequence. |
|
735 |
^ self. |
|
736 |
]. |
|
737 |
cmdKey == 4 ifTrue:[ |
|
738 |
"/ change color |
|
739 |
self endOfSequence. |
|
740 |
^ self. |
|
741 |
]. |
|
742 |
self breakPoint:#cg. |
|
743 |
self endOfSequence |
|
744 |
! ! |
|
745 |
||
2498 | 746 |
!VT100TerminalView methodsFor:'processing-input'! |
927 | 747 |
|
2194 | 748 |
addToParameter:char |
927 | 749 |
"The parameter char is a digit. Add it to the current parameter." |
750 |
||
751 |
| param | |
|
752 |
||
2192 | 753 |
param := (parameters at:currentParam) ? 0. |
927 | 754 |
parameters at:currentParam put:(param * 10 + char digitValue) |
755 |
||
756 |
"Created: / 10.6.1998 / 14:39:00 / cg" |
|
757 |
! |
|
758 |
||
1420 | 759 |
endOfSequence |
760 |
"private - reset state-machine at end of escape-sequence" |
|
927 | 761 |
|
762 |
state := 0. |
|
763 |
currentParam := 1. |
|
2192 | 764 |
"/ parameters := Array new:8 withAll:0. |
765 |
parameters atAllPut:nil. |
|
927 | 766 |
|
767 |
"Created: / 10.6.1998 / 14:30:40 / cg" |
|
768 |
"Modified: / 10.6.1998 / 14:30:57 / cg" |
|
769 |
! |
|
770 |
||
4269 | 771 |
evaluateProcessCharacter:char return:aSymbol |
4447
1ea9b1d38a4b
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4320
diff
changeset
|
772 |
" evaluate the return value of the process state method except for state 0 |
2207 | 773 |
" |
774 |
||
4271 | 775 |
aSymbol isNil ifTrue:[ |
776 |
^ self. |
|
777 |
]. |
|
2207 | 778 |
aSymbol == #waitForNextChar ifTrue:[ |
779 |
^ self. |
|
780 |
]. |
|
781 |
aSymbol == #unknown ifTrue:[ |
|
4270 | 782 |
('VT100TerminalView [info]: unknown character %1 in state %2' |
4269 | 783 |
bindWith:(char codePoint hexPrintString) |
784 |
with:state) infoPrintCR. |
|
2207 | 785 |
self doNothing. |
786 |
^ self |
|
787 |
]. |
|
788 |
aSymbol == #sequenceComplete ifTrue:[ |
|
789 |
self endOfSequence. |
|
790 |
^ self. |
|
791 |
]. |
|
4269 | 792 |
self halt:'unexpected return value from state processing' |
2207 | 793 |
! |
794 |
||
795 |
nextPut:char |
|
4286 | 796 |
" process a character (i.e. from the shell's output)" |
937 | 797 |
|
2202 | 798 |
|processCharacterReturn| |
932 | 799 |
|
2192 | 800 |
Debug ifTrue:[ |
2202 | 801 |
Transcript |
4286 | 802 |
show:'VT100: nextPut - state: '; show:state; |
803 |
show:' got: '; |
|
2202 | 804 |
showCR:char storeString |
2192 | 805 |
]. |
4291 | 806 |
"/ char == Character return ifTrue:[self halt]. |
4289 | 807 |
state == 0 ifTrue:[ |
808 |
processCharacterReturn := self processState0:char. |
|
809 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
|
810 |
^ self |
|
811 |
]. |
|
2207 | 812 |
state == #gotReturn ifTrue:[ |
813 |
processCharacterReturn := self processStateGotReturn:char. |
|
814 |
processCharacterReturn == #sequenceComplete ifTrue:[ |
|
2350
0f9ca9ecf77a
the state have to be reset if sequence is complete in #gotReturn
penk
parents:
2268
diff
changeset
|
815 |
self endOfSequence. |
2207 | 816 |
^ self. |
817 |
]. |
|
4269 | 818 |
^ self |
2207 | 819 |
]. |
820 |
state == #gotESC ifTrue:[ |
|
821 |
processCharacterReturn := self processStateGotESC:char. |
|
4269 | 822 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 823 |
^ self. |
927 | 824 |
]. |
2207 | 825 |
state == #gotCSI ifTrue:[ |
826 |
processCharacterReturn := self processStateGotCSI:char. |
|
4269 | 827 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 828 |
^ self. |
2202 | 829 |
]. |
2207 | 830 |
state == #gotCSI2 ifTrue:[ |
831 |
processCharacterReturn := self processStateGotCSI2:char. |
|
4269 | 832 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 833 |
^ self. |
2192 | 834 |
]. |
2207 | 835 |
state == #gotCSI3 ifTrue:[ |
836 |
processCharacterReturn := self processStateGotCSI3:char. |
|
4269 | 837 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 838 |
^ self. |
2192 | 839 |
]. |
2207 | 840 |
state == #gotXTERMCSI ifTrue:[ |
841 |
processCharacterReturn := self processStateGotXTERMCSI:char. |
|
4269 | 842 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
2207 | 843 |
^ self. |
927 | 844 |
]. |
4221 | 845 |
state == #gotXTERMCSI2 ifTrue:[ |
846 |
processCharacterReturn := self processStateGotXTERMCSI2:char. |
|
4269 | 847 |
self evaluateProcessCharacter:char return:processCharacterReturn. |
4221 | 848 |
^ self. |
849 |
]. |
|
850 |
self halt:'unknown state'. |
|
2192 | 851 |
self doNothing. |
852 |
^ self |
|
2202 | 853 |
! |
854 |
||
2207 | 855 |
processState0:char |
5245 | 856 |
"next char in initial state |
857 |
change state or processing character; |
|
858 |
return |
|
859 |
#waitForNextChar - state was changed and wait for next characters |
|
860 |
#sequenceComplete - command processed |
|
861 |
#unknown - unknown character for this state |
|
862 |
" |
|
2202 | 863 |
|
5155 | 864 |
char codePoint < 32 ifTrue:[ |
2207 | 865 |
(char == Character esc) ifTrue:[ |
866 |
state := #gotESC. |
|
867 |
^ #waitForNextChar |
|
868 |
]. |
|
4269 | 869 |
|
2202 | 870 |
( char == Character nl "nl or '\n'" |
4283 | 871 |
or:[(char == (Character value:16r0b))]) ifTrue:[ |
2207 | 872 |
translateNLToCRNL == true ifTrue:[ |
873 |
self endEntry. |
|
874 |
self cursorToBeginOfLine. |
|
875 |
]. |
|
2202 | 876 |
self endEntry. |
877 |
self doCursorDown:1. |
|
2207 | 878 |
^ #waitForNextChar. |
2202 | 879 |
]. |
4269 | 880 |
|
2202 | 881 |
(char == Character return) ifTrue:[ |
4291 | 882 |
(rangeEndLine notNil and:[rangeEndLine ~~ numberOfLines]) ifTrue:[ |
2202 | 883 |
self endEntry. |
884 |
self cursorToBeginOfLine. |
|
885 |
] ifFalse:[ |
|
886 |
state := #gotReturn. |
|
887 |
]. |
|
2207 | 888 |
^ #waitForNextChar. |
2202 | 889 |
]. |
4269 | 890 |
|
2202 | 891 |
(char == Character backspace) ifTrue:[ |
892 |
self endEntry. |
|
893 |
self cursorLeft. |
|
2207 | 894 |
^ #waitForNextChar "/ doBackspace |
2202 | 895 |
]. |
4269 | 896 |
|
2202 | 897 |
(char == Character bell) ifTrue:[ |
2782 | 898 |
self shown ifTrue:[ |
899 |
self beep. |
|
900 |
]. |
|
2207 | 901 |
^ #waitForNextChar |
2202 | 902 |
]. |
4269 | 903 |
|
2202 | 904 |
(char == (Character value:5)) ifTrue:[ |
905 |
"/ Transmission answerback message |
|
906 |
self reportTerminalType. |
|
2207 | 907 |
^ #waitForNextChar |
2202 | 908 |
]. |
4269 | 909 |
|
2202 | 910 |
( char == (Character value:16r18) "/Cancel |
911 |
or:[ char == (Character value:16r1A) "/Substitute |
|
912 |
]) ifTrue:[ |
|
913 |
self nextPut:(Character value:16r2). |
|
2207 | 914 |
^ #waitForNextChar |
2202 | 915 |
] |
4269 | 916 |
|
2207 | 917 |
" |
4269 | 918 |
all unsupported control characters (also vt102): |
2207 | 919 |
Character value:16r3 ->End of text |
920 |
Character value:16r4 ->End of transmission |
|
921 |
Character tab ->Horizontal tab |
|
922 |
Character value:16rc ->Form feed |
|
923 |
Character value:16re ->SO shift out |
|
924 |
Character value:16rf ->SI shift in |
|
925 |
Character value:16r11 ->Device control 1 |
|
926 |
Character value:16r13 ->Device control 3 |
|
927 |
". |
|
928 |
char ~~ Character tab ifTrue:[ |
|
5155 | 929 |
char codePoint ~~ 0 ifTrue:[ |
2207 | 930 |
('VT100 [info]: unhandled control key: ' , char storeString) infoPrintCR. |
931 |
]. |
|
932 |
^ #waitForNextChar. |
|
933 |
] |
|
2202 | 934 |
]. |
4447
1ea9b1d38a4b
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4320
diff
changeset
|
935 |
self show:char. |
4271 | 936 |
^ nil |
2192 | 937 |
! |
938 |
||
939 |
processStateGotCSI2:char |
|
5245 | 940 |
"next char after 'ESC [ ?' (CSI ?) |
941 |
change state or processing character; |
|
942 |
return |
|
943 |
#waitForNextChar - state was changed and wait for next characters |
|
944 |
#sequenceComplete - command processed |
|
945 |
#unknown - unknown character for this state |
|
946 |
" |
|
2192 | 947 |
|
948 |
char == $; ifTrue: [ |
|
949 |
currentParam := (currentParam + 1) min: 8. |
|
950 |
^ #waitForNextChar |
|
951 |
]. |
|
952 |
char isDigit ifTrue: [ |
|
2194 | 953 |
self addToParameter:char. |
2192 | 954 |
^ #waitForNextChar |
955 |
]. |
|
4269 | 956 |
|
957 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
|
958 |
(char == $l or:[char == $h]) ifTrue: [ |
|
5245 | 959 |
"/ (parameters at: 1) = 1 ifTrue: [app_cur_keys:(char == $h) "DECCKM"]. |
960 |
"/ (parameters at: 1) = 2 ifTrue: [vt52mode:(char == $l) "DECANM"]. |
|
961 |
"/ (parameters at: 1) = 3 ifTrue: [mode132:(char == $h) "DECCOLM"]. |
|
962 |
"/ (parameters at: 1) = 4 ifTrue: [smoothScroll:(char == $h) "DECSCLM"]. |
|
963 |
"/ (parameters at: 1) = 5 ifTrue: [reverseVideo:(char == $h) "DECSCNM"]. |
|
964 |
"/ (parameters at: 1) = 6 ifTrue: [originMode:(char == $h) "DECOM"]. |
|
965 |
"/ (parameters at: 1) = 8 ifTrue: [autoKbdRepeat:(char == $h) "DECARM"]. |
|
966 |
"/ (parameters at: 1) = 25 ifTrue: [cursorVisible:(char == $h) "DECTCEM"]. |
|
2192 | 967 |
self endEntry. |
5245 | 968 |
(parameters at: 1) = 7 ifTrue: [self autoMargin:(char == $h) "DECAWM"]. |
2192 | 969 |
^ #sequenceComplete |
970 |
]. |
|
5245 | 971 |
(char == $n) ifTrue: [ |
972 |
"/ (parameters at: 1) = 15 ifTrue: [ ... ]. -- What is the printer status? |
|
973 |
"/ (parameters at: 1) = 25 ifTrue: [ ... ]. -- Are user-defined keys locked or unlocked? |
|
974 |
"/ (parameters at: 1) = 26 ifTrue: [ ... ]. -- What is the keyboard language? |
|
975 |
]. |
|
2192 | 976 |
^ #unknown |
977 |
! |
|
978 |
||
979 |
processStateGotCSI3:char |
|
5245 | 980 |
"next char after 'ESC (' |
981 |
change state or processing character; |
|
982 |
return |
|
983 |
#waitForNextChar - state was changed and wait for next characters |
|
984 |
#sequenceComplete - command processed |
|
985 |
#unknown - unknown character for this state |
|
986 |
" |
|
2192 | 987 |
|
4269 | 988 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
2192 | 989 |
^ #unknown |
990 |
! |
|
991 |
||
992 |
processStateGotCSI:char |
|
5245 | 993 |
"next char after 'ESC> [' (CSI) |
994 |
change state or processing character; |
|
995 |
return |
|
996 |
#waitForNextChar - state was changed and wait for next characters |
|
997 |
#sequenceComplete - command processed |
|
998 |
#unknown - unknown character for this state |
|
999 |
" |
|
2192 | 1000 |
|
1001 |
char == $? ifTrue: [ |
|
1002 |
state := #gotCSI2. |
|
1003 |
^ #waitForNextChar |
|
1004 |
]. |
|
1005 |
char == $; ifTrue:[ |
|
1006 |
currentParam := (currentParam + 1) min: 8. |
|
1007 |
^ #waitForNextChar |
|
1008 |
]. |
|
1009 |
char isDigit ifTrue: [ |
|
1010 |
self addToParameter:char. |
|
1011 |
^ #waitForNextChar |
|
1012 |
]. |
|
4269 | 1013 |
|
1014 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
|
2192 | 1015 |
char == $@ ifTrue: [ |
1016 |
self endEntry. |
|
1017 |
self insertCharacters. |
|
1018 |
^ #sequenceComplete |
|
1019 |
]. |
|
1020 |
char == $A ifTrue: [ |
|
1021 |
"/ ESC[#A - Moves cursor up # lines |
|
1022 |
self endEntry. |
|
2202 | 1023 |
self doCursorUp:(self getParameter:1 withDefault:1). |
2192 | 1024 |
^ #sequenceComplete |
1025 |
]. |
|
1026 |
char == $B ifTrue: [ |
|
1027 |
"/ ESC[#B - Moves cursor down # lines |
|
1028 |
self endEntry. |
|
2202 | 1029 |
self doCursorDown:(self getParameter:1 withDefault:1). |
2192 | 1030 |
^ #sequenceComplete |
1031 |
]. |
|
1032 |
char == $C ifTrue: [ |
|
1033 |
"/ ESC[#C - Moves cursor forward # spaces |
|
1034 |
self endEntry. |
|
2202 | 1035 |
self doCursorRight:(self getParameter:1 withDefault:1). |
2192 | 1036 |
^ #sequenceComplete |
1037 |
]. |
|
1038 |
char == $D ifTrue: [ |
|
1039 |
"/ ESC[#D - Moves cursor back # spaces |
|
1040 |
self endEntry. |
|
2202 | 1041 |
self doCursorLeft:(self getParameter:1 withDefault:1). |
2192 | 1042 |
^ #sequenceComplete |
1043 |
]. |
|
4296 | 1044 |
char == $E ifTrue: [ |
1045 |
"/ ESC[#E |
|
1046 |
self endEntry. |
|
1047 |
self doCursorNextLine:(self getParameter:1 withDefault:1). |
|
1048 |
^ #sequenceComplete |
|
1049 |
]. |
|
1050 |
char == $F ifTrue: [ |
|
1051 |
"/ ESC[#F |
|
1052 |
self endEntry. |
|
1053 |
self doCursorPreviousLine:(self getParameter:1 withDefault:1). |
|
1054 |
^ #sequenceComplete |
|
1055 |
]. |
|
1056 |
(char == $G) ifTrue: [ |
|
1057 |
"/ ESC[#;#G - Moves cusor to column # in current line |
|
1058 |
self endEntry. |
|
1059 |
self moveToColumn. |
|
1060 |
^ #sequenceComplete |
|
1061 |
]. |
|
2202 | 1062 |
(char == $H or:[char == $f]) ifTrue: [ |
2192 | 1063 |
"/ ESC[#;#H or ESC[#;#f - Moves cusor to line #, column # |
1064 |
self endEntry. |
|
2202 | 1065 |
self move. |
2192 | 1066 |
^ #sequenceComplete |
1067 |
]. |
|
1068 |
char == $J ifTrue: [ |
|
2217 | 1069 |
"/ ESC[0J - Clear screen to end |
1070 |
"/ ESC[1J - Clear screen from beginning |
|
2192 | 1071 |
"/ ESC[2J - Clear entire screen and home cursor |
1072 |
self endEntry. |
|
2207 | 1073 |
self doClearDisplay:(self getParameter:1 withDefault:0). |
2192 | 1074 |
^ #sequenceComplete |
1075 |
]. |
|
1076 |
char == $K ifTrue: [ |
|
1077 |
"/ ESC[K - Clear to end of line |
|
1078 |
self endEntry. |
|
2207 | 1079 |
self clearLines:(self getParameter:1 withDefault:0). |
2192 | 1080 |
Debug ifTrue:[ |
1081 |
Transcript showCR:'clear to EOL'. |
|
1082 |
]. |
|
1083 |
^ #sequenceComplete |
|
1084 |
]. |
|
1085 |
char == $L ifTrue: [ |
|
1086 |
self endEntry. |
|
1087 |
self insertLines. |
|
1088 |
^ #sequenceComplete |
|
1089 |
]. |
|
1090 |
char == $M ifTrue: [ |
|
1091 |
self endEntry. |
|
1092 |
self deleteLines. |
|
1093 |
^ #sequenceComplete |
|
1094 |
]. |
|
1095 |
char == $P ifTrue: [ |
|
1096 |
self endEntry. |
|
1097 |
self deleteCharacters. |
|
1098 |
^ #sequenceComplete |
|
1099 |
]. |
|
2202 | 1100 |
char == $R ifTrue: [ |
2192 | 1101 |
"/ ESC[#;#R - Reports current cursor line & column |
2207 | 1102 |
^ #unknown |
2192 | 1103 |
]. |
4296 | 1104 |
|
1105 |
char == $c ifTrue:[ |
|
5548 | 1106 |
"/ ESC[c - terminal-type query 3 |
2192 | 1107 |
self reportTerminalType. |
1108 |
^ #sequenceComplete |
|
1109 |
]. |
|
4296 | 1110 |
char == $d ifTrue:[ |
5548 | 1111 |
"/ ESC[d |
4296 | 1112 |
self endEntry. |
1113 |
self moveToLine. |
|
1114 |
^ #sequenceComplete |
|
1115 |
]. |
|
2192 | 1116 |
char == $n ifTrue: [ |
5548 | 1117 |
"/ ESC[n |
2192 | 1118 |
self report. |
1119 |
^ #sequenceComplete |
|
1120 |
]. |
|
1121 |
char == $m ifTrue: [ |
|
5548 | 1122 |
"/ ESC[m - character attributes (SGR) |
1123 |
self endEntry. |
|
4297 | 1124 |
1 to:currentParam do:[:pI | |
1125 |
self displayMode:(self getParameter:pI withDefault:0). |
|
1126 |
]. |
|
2192 | 1127 |
^ #sequenceComplete |
1128 |
]. |
|
1129 |
char == $r ifTrue: [ |
|
5548 | 1130 |
"/ ESC[r |
2192 | 1131 |
self endEntry. |
1132 |
self resetDefaults. |
|
1133 |
^ #sequenceComplete |
|
1134 |
]. |
|
1135 |
char == $s ifTrue: [ |
|
1136 |
"/ ESC[s - Saves cursor position for recall later |
|
1137 |
self endEntry. |
|
1138 |
^ #sequenceComplete |
|
1139 |
]. |
|
1140 |
char == $u ifTrue: [ |
|
1141 |
"/ ESC[u - Return to saved cursor position |
|
1142 |
self endEntry. |
|
1143 |
^ #sequenceComplete |
|
1144 |
]. |
|
1145 |
^ #unknown |
|
5548 | 1146 |
|
1147 |
"Modified: / 30-05-2017 / 09:24:50 / cg" |
|
2192 | 1148 |
! |
1149 |
||
1150 |
processStateGotESC:char |
|
5245 | 1151 |
"next char after ESC |
1152 |
change state or processing character; |
|
1153 |
return |
|
1154 |
#waitForNextChar - state was changed and wait for next characters |
|
1155 |
#sequenceComplete - command processed |
|
1156 |
#unknown - unknown character for this state |
|
1157 |
" |
|
2192 | 1158 |
|
1159 |
char == $[ ifTrue: [ |
|
1160 |
"/ ESC-[ |
|
1161 |
state := #gotCSI. |
|
1162 |
^ #waitForNextChar |
|
1163 |
]. |
|
1164 |
char == $] ifTrue: [ |
|
1165 |
"/ ESC-] |
|
1166 |
"/xterm sequence |
|
1167 |
state := #gotXTERMCSI. |
|
1168 |
^ #waitForNextChar |
|
1169 |
]. |
|
1170 |
char == $( ifTrue: [ |
|
1171 |
"/ ESC-( |
|
1172 |
"/ todo: set-charset 0 ... |
|
1173 |
state := #gotCSI3. |
|
1174 |
^ #waitForNextChar |
|
1175 |
]. |
|
4269 | 1176 |
|
1177 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
|
2192 | 1178 |
char == $) ifTrue: [ |
1179 |
"/ ESC-( |
|
1180 |
"/ todo: set-charset 1 ... |
|
2207 | 1181 |
^ #unknown |
2192 | 1182 |
]. |
1183 |
char == $7 ifTrue:[ |
|
1184 |
"/ ESC-7 |
|
1185 |
self endEntry. |
|
1186 |
self saveCursor. |
|
1187 |
^ #sequenceComplete |
|
1188 |
]. |
|
1189 |
char == $8 ifTrue:[ |
|
1190 |
"/ ESC-7 |
|
1191 |
self endEntry. |
|
1192 |
self restoreCursor. |
|
1193 |
^ #sequenceComplete |
|
1194 |
]. |
|
1195 |
char == $M ifTrue:[ |
|
2217 | 1196 |
"/ ESC-M cursor up |
2192 | 1197 |
self endEntry. |
1198 |
self doCursorUp:1. |
|
1199 |
^ #sequenceComplete |
|
1200 |
]. |
|
1201 |
char == $D ifTrue:[ |
|
2217 | 1202 |
"/ ESC-D Index cursor down one line in same column |
2192 | 1203 |
self endEntry. |
1204 |
self doCursorDown:1. |
|
1205 |
^ #sequenceComplete |
|
1206 |
]. |
|
1207 |
char == $E ifTrue:[ |
|
1208 |
"/ ESC-E |
|
1209 |
"/ TODO add_lines |
|
2217 | 1210 |
self endEntry. |
1211 |
self cursorReturn. |
|
2192 | 1212 |
^ #sequenceComplete |
1213 |
]. |
|
1214 |
(char == $Z) ifTrue:[ |
|
1215 |
"/ terminal-type query 2 |
|
1216 |
self reportTerminalType. |
|
1217 |
^ #sequenceComplete |
|
1218 |
]. |
|
1219 |
char == $= ifTrue: [ |
|
4291 | 1220 |
"/ enter application keypad mode |
2192 | 1221 |
"/ ESC-= |
4291 | 1222 |
alternateKeypadMode := true. |
4293 | 1223 |
kbdSequences := (self vt100AlternativeKeyCodes). |
4291 | 1224 |
^ #sequenceComplete |
2192 | 1225 |
]. |
1226 |
char == $> ifTrue: [ |
|
4291 | 1227 |
"/ exit application keypad mode |
2192 | 1228 |
"/ ESC-< |
4291 | 1229 |
alternateKeypadMode := false. |
4293 | 1230 |
kbdSequences := (self vt100KeyCodes). |
4291 | 1231 |
^ #sequenceComplete |
2192 | 1232 |
]. |
1233 |
^ #unknown |
|
1234 |
! |
|
1235 |
||
2202 | 1236 |
processStateGotReturn:char |
5245 | 1237 |
"next char after CR |
1238 |
change state or processing character; |
|
1239 |
return |
|
1240 |
#waitForNextChar - state was changed and wait for next characters |
|
1241 |
#sequenceComplete - command processed |
|
1242 |
#unknown - unknown character for this state |
|
1243 |
" |
|
2202 | 1244 |
|
2207 | 1245 |
state := 0. |
2202 | 1246 |
char == Character nl ifTrue:[ |
1247 |
"/ cr-nl |
|
1248 |
"/ stay in buffering mode. |
|
4448 | 1249 |
self cr. |
2207 | 1250 |
^ #sequenceComplete. |
2202 | 1251 |
]. |
4291 | 1252 |
|
2202 | 1253 |
self endEntry. |
1254 |
self cursorToBeginOfLine. |
|
4448 | 1255 |
|
1256 |
(char == Character esc) ifTrue:[ |
|
1257 |
state := #gotESC. |
|
1258 |
]. |
|
1259 |
"/ continue in initial state |
|
1260 |
^ #waitForNextChar |
|
2202 | 1261 |
! |
1262 |
||
4221 | 1263 |
processStateGotXTERMCSI2:char |
5245 | 1264 |
"next char after 'ESC ] ;' |
1265 |
change state or processing character; |
|
1266 |
return |
|
1267 |
#waitForNextChar - state was changed and wait for next characters |
|
1268 |
#sequenceComplete - command processed |
|
1269 |
#unknown - unknown character for this state |
|
1270 |
" |
|
4221 | 1271 |
|
1272 |
char == (Character value:7) ifTrue: [ |
|
4269 | 1273 |
TraceCSI == true ifTrue:[ self traceCSI:char ]. |
4221 | 1274 |
parameters at:currentParam put:(parameters at:currentParam) contents. |
1275 |
self osCommand. |
|
1276 |
^ #sequenceComplete |
|
1277 |
]. |
|
1278 |
"/ add to parameter |
|
1279 |
(parameters at:currentParam) nextPut:char. |
|
1280 |
^ #waitForNextChar |
|
1281 |
! |
|
1282 |
||
2192 | 1283 |
processStateGotXTERMCSI:char |
5245 | 1284 |
"next char after 'ESC ]' |
1285 |
change state or processing character; |
|
1286 |
return |
|
1287 |
#waitForNextChar - state was changed and wait for next characters |
|
1288 |
#sequenceComplete - command processed |
|
1289 |
#unknown - unknown character for this state |
|
1290 |
" |
|
2192 | 1291 |
|
4221 | 1292 |
char == $; ifTrue:[ |
1293 |
currentParam := (currentParam + 1) min: 8. |
|
1294 |
parameters at:currentParam put:(WriteStream on:''). |
|
1295 |
state := #gotXTERMCSI2. |
|
1296 |
^ #waitForNextChar |
|
1297 |
]. |
|
4269 | 1298 |
|
4221 | 1299 |
char isDigit ifTrue: [ |
1300 |
self addToParameter:char. |
|
1301 |
^ #waitForNextChar |
|
1302 |
]. |
|
2192 | 1303 |
^ #unknown |
920 | 1304 |
! ! |
1305 |
||
930 | 1306 |
!VT100TerminalView methodsFor:'queries'! |
1307 |
||
2202 | 1308 |
getParameter:para withDefault:default |
1309 |
||
1310 |
|parameter| |
|
1311 |
||
1312 |
parameter := (parameters at:para). |
|
1313 |
^ ((parameter isNil or:[parameter = 0]) ifTrue:[default] ifFalse:[parameter]). |
|
1314 |
! |
|
1315 |
||
930 | 1316 |
terminalType |
1420 | 1317 |
"returns a string describing this terminal (usually, this is |
1318 |
passed down to the shell as TERM environment variable). |
|
1319 |
Here, 'vt100' is returned." |
|
1320 |
||
4296 | 1321 |
"/ ^ 'xterm'. |
1355 | 1322 |
^ 'vt100' |
930 | 1323 |
|
1324 |
"Created: / 10.6.1998 / 16:22:39 / cg" |
|
1355 | 1325 |
"Modified: / 5.5.1999 / 11:22:40 / cg" |
930 | 1326 |
! ! |
1327 |
||
920 | 1328 |
!VT100TerminalView class methodsFor:'documentation'! |
1329 |
||
1330 |
version |
|
4800 | 1331 |
^ '$Header$' |
4286 | 1332 |
! |
1333 |
||
1334 |
version_CVS |
|
4800 | 1335 |
^ '$Header$' |
920 | 1336 |
! ! |
4221 | 1337 |