author | Claus Gittinger <cg@exept.de> |
Wed, 10 Jun 1998 20:06:57 +0200 | |
changeset 937 | 9823aad16498 |
parent 934 | b450dbaeedac |
child 939 | 54698a16b65c |
permissions | -rw-r--r-- |
930 | 1 |
TerminalView subclass:#VT100TerminalView |
927 | 2 |
instanceVariableNames:'state currentParam parameters' |
920 | 3 |
classVariableNames:'' |
4 |
poolDictionaries:'' |
|
5 |
category:'Views-TerminalViews' |
|
6 |
! |
|
7 |
||
927 | 8 |
!VT100TerminalView class methodsFor:'documentation'! |
9 |
||
10 |
documentation |
|
11 |
" |
|
12 |
VT100 terminal |
|
13 |
||
14 |
[start with:] |
|
15 |
VT100TerminalView openShell |
|
16 |
" |
|
17 |
||
18 |
||
19 |
! ! |
|
920 | 20 |
|
932 | 21 |
!VT100TerminalView methodsFor:'defaults'! |
927 | 22 |
|
23 |
vt100KeyCodes |
|
24 |
^ IdentityDictionary withKeysAndValues: |
|
25 |
#( |
|
26 |
#CursorUp '\e[A' |
|
27 |
#CursorDown '\e[B' |
|
28 |
#CursorRight '\e[C' |
|
29 |
#CursorLeft '\e[D' |
|
30 |
#Home '\e[H' |
|
31 |
#Escape '\e' |
|
32 |
#BackSpace '\b' |
|
33 |
#Return '\r' |
|
34 |
#Delete '\0377' |
|
35 |
) |
|
36 |
||
37 |
"Modified: / 10.6.1998 / 14:19:27 / cg" |
|
38 |
"Created: / 10.6.1998 / 15:13:01 / cg" |
|
39 |
! ! |
|
40 |
||
41 |
!VT100TerminalView methodsFor:'functions'! |
|
42 |
||
43 |
addLines |
|
44 |
"Add the appropriate number of blank lines at the position |
|
45 |
indicated by the cursor." |
|
46 |
||
47 |
self addLines: ((parameters at: 1) max: 1). |
|
48 |
self endOfSequence |
|
49 |
||
50 |
"Created: / 10.6.1998 / 14:48:03 / cg" |
|
51 |
! |
|
52 |
||
53 |
addLines: aNumber |
|
54 |
"Add aNumber blank lines at the position indicated by the cursor." |
|
55 |
||
56 |
aNumber timesRepeat: [ |
|
57 |
self insertLine:'' before:cursorLine |
|
58 |
] |
|
59 |
||
60 |
"Created: / 10.6.1998 / 14:49:30 / cg" |
|
61 |
! |
|
62 |
||
63 |
clearLines |
|
64 |
"Clear some part of the current line, as indicated by the first parameter." |
|
65 |
||
66 |
(parameters at: 1) = 0 ifTrue: [^self doClearToEndOfLine]. |
|
67 |
(parameters at: 1) = 1 ifTrue: [^self doClearFromBeginningOfLine]. |
|
68 |
(parameters at: 1) = 2 ifTrue: [^self doClearEntireLine] |
|
69 |
||
70 |
"Created: / 10.6.1998 / 14:44:22 / cg" |
|
71 |
! |
|
72 |
||
73 |
displayMode: anInteger |
|
74 |
"Set the current display mode." |
|
75 |
||
76 |
"/ displayMode _ anInteger!! |
|
77 |
||
78 |
"Created: / 10.6.1998 / 15:01:16 / cg" |
|
79 |
! |
|
80 |
||
81 |
move |
|
82 |
"Move to the locations indicated by the first and second parameters." |
|
83 |
||
84 |
self moveToX: ((parameters at: 2) max: 1) y: ((parameters at: 1) max: 1). |
|
85 |
self endOfSequence |
|
86 |
||
87 |
"Created: / 10.6.1998 / 14:40:01 / cg" |
|
88 |
! |
|
89 |
||
90 |
moveToX: xLocation y: yLocation |
|
91 |
"Position the cursor at the location given by xLocation and yLocation. |
|
92 |
Ignore the command if the parameters are outside the allowable range." |
|
93 |
||
94 |
(xLocation < 1 or: [xLocation > numberOfColumns]) ifTrue: [^self]. |
|
95 |
(yLocation < 1 or: [yLocation > numberOfLines]) ifTrue: [^self]. |
|
96 |
"/ self changed: y. |
|
97 |
self cursorLine:yLocation col:xLocation. |
|
98 |
||
99 |
"Created: / 10.6.1998 / 14:40:49 / cg" |
|
100 |
"Modified: / 10.6.1998 / 14:53:02 / cg" |
|
101 |
! |
|
102 |
||
103 |
resetDefaults |
|
104 |
"Reset the default parameters" |
|
105 |
||
106 |
"/ autoLineFeed _ false. |
|
107 |
"/ autoMargin _ true. |
|
108 |
"/ displayMode _ 0. "Normal display"!! !! |
|
109 |
||
110 |
"Created: / 10.6.1998 / 14:50:53 / cg" |
|
111 |
"Modified: / 10.6.1998 / 15:02:58 / cg" |
|
920 | 112 |
! ! |
113 |
||
114 |
!VT100TerminalView methodsFor:'initialization'! |
|
115 |
||
927 | 116 |
initialize |
117 |
super initialize. |
|
118 |
self endOfSequence |
|
119 |
||
120 |
"Created: / 10.6.1998 / 14:46:07 / cg" |
|
121 |
"Modified: / 10.6.1998 / 14:46:30 / cg" |
|
122 |
! |
|
123 |
||
920 | 124 |
initializeEscapeSequences |
932 | 125 |
^ self |
920 | 126 |
|
127 |
"Modified: / 9.6.1998 / 20:49:21 / cg" |
|
932 | 128 |
"Created: / 10.6.1998 / 16:29:31 / cg" |
927 | 129 |
! |
130 |
||
131 |
initializeKeyboardSequences |
|
132 |
kbdSequences := (self vt100KeyCodes) |
|
133 |
||
134 |
"Modified: / 9.6.1998 / 20:49:21 / cg" |
|
135 |
"Created: / 10.6.1998 / 15:12:32 / cg" |
|
136 |
! ! |
|
137 |
||
138 |
!VT100TerminalView methodsFor:'processing - input'! |
|
139 |
||
140 |
addToParameter: char |
|
141 |
"The parameter char is a digit. Add it to the current parameter." |
|
142 |
||
143 |
| param | |
|
144 |
||
145 |
param := parameters at:currentParam. |
|
146 |
parameters at:currentParam put:(param * 10 + char digitValue) |
|
147 |
||
148 |
"Created: / 10.6.1998 / 14:39:00 / cg" |
|
149 |
! |
|
150 |
||
151 |
doNothing |
|
152 |
self endOfSequence |
|
153 |
||
154 |
"Created: / 10.6.1998 / 14:31:56 / cg" |
|
155 |
! |
|
156 |
||
157 |
endOfSequence |
|
158 |
state := 0. |
|
159 |
currentParam := 1. |
|
160 |
parameters := Array new:8 withAll:0. |
|
161 |
||
162 |
"Created: / 10.6.1998 / 14:30:40 / cg" |
|
163 |
"Modified: / 10.6.1998 / 14:30:57 / cg" |
|
164 |
! |
|
165 |
||
166 |
nextPut:char |
|
937 | 167 |
"process a character (i.e. the shells output)" |
168 |
||
932 | 169 |
"/ Transcript show:state; show:' '; showCR:char asciiValue. |
170 |
||
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
171 |
state == #gotReturn ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
172 |
state := 0. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
173 |
char == Character nl ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
174 |
"/ cr-nl |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
175 |
"/ stay in buffering mode. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
176 |
super nextPut:Character cr. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
177 |
^ self. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
178 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
179 |
self endEntry. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
180 |
self cursorToBeginOfLine. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
181 |
"/ continue in initial state |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
182 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
183 |
|
927 | 184 |
state == 0 ifTrue:[ |
185 |
"/ Currently, we are in initial state. |
|
186 |
"/ Decide what to do on the basis of the parameter char. |
|
187 |
||
188 |
(char == Character esc) ifTrue:[ |
|
189 |
self endEntry. |
|
190 |
state := 1. ^ self |
|
191 |
]. |
|
192 |
(char == Character nl) ifTrue:[ |
|
193 |
self endEntry. |
|
932 | 194 |
^ self cursorDown:1 |
195 |
]. |
|
196 |
(char == Character return) ifTrue:[ |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
197 |
state := #gotReturn. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
198 |
^ self. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
199 |
"/ self endEntry. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
200 |
"/ ^ self cursorToBeginOfLine |
927 | 201 |
]. |
202 |
(char == Character backspace) ifTrue:[ |
|
203 |
self endEntry. |
|
932 | 204 |
^ self doBackspace |
927 | 205 |
]. |
932 | 206 |
(char == Character bell) ifTrue:[ |
207 |
self beep. |
|
208 |
^ self |
|
209 |
]. |
|
937 | 210 |
"/ (char == Character tab) ifTrue:[ |
211 |
"/ self endEntry. |
|
212 |
"/ super nextPut:char. |
|
213 |
"/ self endEntry. |
|
214 |
"/ ^ self. |
|
215 |
"/ ]. |
|
934 | 216 |
^ super nextPut:char |
927 | 217 |
]. |
218 |
||
219 |
state == 1 ifTrue:[ |
|
220 |
"/ Currently, we are in ESC state. |
|
221 |
"/ Decide what to do on the basis of the parameter char. |
|
222 |
||
223 |
char == $[ ifTrue: [ |
|
224 |
"/ ESC-[ |
|
225 |
state := 2. |
|
226 |
^ self |
|
227 |
]. |
|
228 |
char == $M ifTrue:[ |
|
229 |
"/ ESC-M |
|
230 |
self cursorUp:1. |
|
231 |
^ self endOfSequence |
|
232 |
]. |
|
233 |
char == $D ifTrue:[ |
|
234 |
"/ ESC-D |
|
235 |
self cursorDown:1. |
|
236 |
^ self endOfSequence |
|
237 |
]. |
|
238 |
^ self doNothing |
|
239 |
]. |
|
240 |
||
241 |
state == 2 ifTrue:[ |
|
242 |
"/ Currently, we are in ESC-[ state. |
|
243 |
"/ Decide what to do on the basis of the parameter char. |
|
244 |
||
245 |
char == $; ifTrue:[ |
|
246 |
currentParam := (currentParam + 1) min: 8. |
|
247 |
^ self |
|
248 |
]. |
|
249 |
char isDigit ifTrue: [ |
|
250 |
^ self addToParameter:char |
|
251 |
]. |
|
252 |
char == $@ ifTrue: [ |
|
253 |
^ self insertCharacters |
|
254 |
]. |
|
255 |
char == $A ifTrue: [ |
|
256 |
self doCursorUp:((parameters at: 1) max: 1). |
|
257 |
^ self endOfSequence |
|
258 |
]. |
|
259 |
char == $B ifTrue: [ |
|
260 |
self doCursorLeft:((parameters at: 1) max: 1). |
|
261 |
^ self endOfSequence |
|
262 |
]. |
|
263 |
char == $C ifTrue: [ |
|
264 |
self doCursorRight:((parameters at: 1) max: 1). |
|
265 |
^ self endOfSequence |
|
266 |
]. |
|
267 |
char == $D ifTrue: [ |
|
268 |
self doCursorDown:((parameters at: 1) max: 1). |
|
269 |
^ self endOfSequence |
|
270 |
]. |
|
271 |
char == $H ifTrue: [ |
|
272 |
self move. |
|
273 |
^ self endOfSequence |
|
274 |
]. |
|
275 |
char == $J ifTrue: [ |
|
276 |
self doClearDisplay. |
|
277 |
^ self endOfSequence |
|
278 |
]. |
|
279 |
char == $K ifTrue: [ |
|
280 |
self clearLines. |
|
281 |
^ self endOfSequence |
|
282 |
]. |
|
283 |
char == $L ifTrue: [ |
|
284 |
self addLines. |
|
285 |
^ self endOfSequence |
|
286 |
]. |
|
287 |
char == $M ifTrue: [ |
|
288 |
self deleteLines. |
|
289 |
^ self endOfSequence |
|
290 |
]. |
|
291 |
char == $P ifTrue: [ |
|
292 |
self deleteCharacters. |
|
293 |
^ self endOfSequence |
|
294 |
]. |
|
295 |
char == $m ifTrue: [ |
|
296 |
self displayMode: (parameters at: 1). |
|
297 |
^ self endOfSequence |
|
298 |
]. |
|
299 |
char == $r ifTrue: [ |
|
300 |
self resetDefaults. |
|
301 |
^ self endOfSequence |
|
302 |
]. |
|
303 |
char == $? ifTrue: [ |
|
304 |
state := 3. |
|
305 |
^ self |
|
306 |
]. |
|
307 |
self doNothing |
|
308 |
]. |
|
309 |
||
310 |
state == 3 ifTrue:[ |
|
311 |
"/ Currently, we are in ESC-[-? state. |
|
312 |
"/ Decide what to do on the basis of the parameter char. |
|
313 |
||
314 |
char == $; ifTrue: [ |
|
315 |
currentParam := (currentParam + 1) min: 8. |
|
316 |
^ self |
|
317 |
]. |
|
318 |
char isDigit ifTrue: [ |
|
319 |
self addToParameter: char. |
|
320 |
^ self |
|
321 |
]. |
|
322 |
char == $l ifTrue: [ |
|
323 |
(parameters at: 1) = 7 ifTrue: [self autoMargin: false]. |
|
324 |
^ self doNothing |
|
325 |
]. |
|
326 |
char == $h ifTrue: [ |
|
327 |
(parameters at: 1) = 7 ifTrue: [self autoMargin: true]. |
|
328 |
^ self doNothing |
|
329 |
]. |
|
330 |
^self doNothing |
|
331 |
]. |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
332 |
|
927 | 333 |
self doNothing |
334 |
||
937 | 335 |
"Modified: / 10.6.1998 / 20:01:13 / cg" |
920 | 336 |
! ! |
337 |
||
930 | 338 |
!VT100TerminalView methodsFor:'queries'! |
339 |
||
340 |
terminalType |
|
341 |
^ #vt100 |
|
342 |
||
343 |
"Created: / 10.6.1998 / 16:22:39 / cg" |
|
344 |
! ! |
|
345 |
||
920 | 346 |
!VT100TerminalView class methodsFor:'documentation'! |
347 |
||
348 |
version |
|
937 | 349 |
^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.7 1998-06-10 18:06:57 cg Exp $' |
920 | 350 |
! ! |