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