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