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