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