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