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