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