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