914
|
1 |
TerminalView subclass:#VT52TerminalView
|
956
|
2 |
instanceVariableNames:'state param1 param2'
|
914
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Views-TerminalViews'
|
|
6 |
!
|
|
7 |
|
|
8 |
!VT52TerminalView class methodsFor:'documentation'!
|
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
VT52 terminal
|
|
13 |
|
|
14 |
[start with:]
|
916
|
15 |
VT52TerminalView openShell
|
914
|
16 |
"
|
|
17 |
|
|
18 |
! !
|
|
19 |
|
|
20 |
!VT52TerminalView methodsFor:'defaults'!
|
|
21 |
|
|
22 |
vt52KeyCodes
|
|
23 |
^ IdentityDictionary withKeysAndValues:
|
|
24 |
#(
|
|
25 |
#CursorUp '\eA'
|
|
26 |
#CursorDown '\eB'
|
927
|
27 |
#CursorRight '\eC'
|
|
28 |
#CursorLeft '\eD'
|
914
|
29 |
#Home '\eH'
|
|
30 |
#Escape '\e'
|
927
|
31 |
#BackSpace '\b'
|
914
|
32 |
#Return '\r'
|
976
|
33 |
#Delete '\0177'
|
914
|
34 |
)
|
927
|
35 |
|
976
|
36 |
"Modified: / 20.6.1998 / 17:36:39 / cg"
|
914
|
37 |
! !
|
|
38 |
|
956
|
39 |
!VT52TerminalView methodsFor:'events'!
|
|
40 |
|
|
41 |
defineWindowSize
|
|
42 |
super defineWindowSize.
|
980
|
43 |
rangeEndLine := numberOfLines
|
956
|
44 |
|
|
45 |
"Created: / 13.6.1998 / 18:15:43 / cg"
|
980
|
46 |
"Modified: / 20.6.1998 / 20:33:29 / cg"
|
956
|
47 |
! !
|
|
48 |
|
914
|
49 |
!VT52TerminalView methodsFor:'initialization'!
|
|
50 |
|
|
51 |
initialize
|
|
52 |
super initialize.
|
949
|
53 |
self endOfSequence.
|
914
|
54 |
|
980
|
55 |
"Modified: / 20.6.1998 / 20:34:18 / cg"
|
914
|
56 |
!
|
|
57 |
|
|
58 |
initializeKeyboardSequences
|
|
59 |
kbdSequences := (self vt52KeyCodes)
|
|
60 |
|
|
61 |
|
|
62 |
! !
|
|
63 |
|
932
|
64 |
!VT52TerminalView methodsFor:'processing - input'!
|
|
65 |
|
949
|
66 |
doNothing
|
|
67 |
self endOfSequence
|
|
68 |
|
|
69 |
"Created: / 12.6.1998 / 20:40:43 / cg"
|
|
70 |
!
|
932
|
71 |
|
949
|
72 |
endOfSequence
|
|
73 |
state := 0.
|
932
|
74 |
|
949
|
75 |
"Created: / 12.6.1998 / 20:39:52 / cg"
|
|
76 |
!
|
932
|
77 |
|
949
|
78 |
nextPut:char
|
|
79 |
"process a character (i.e. the shells output)"
|
|
80 |
|
|
81 |
"/ Transcript show:state; show:' '; showCR:char storeString.
|
|
82 |
|
|
83 |
state == #gotReturn ifTrue:[
|
|
84 |
state := 0.
|
|
85 |
char == Character nl ifTrue:[
|
|
86 |
"/ cr-nl
|
|
87 |
"/ stay in buffering mode.
|
|
88 |
super nextPut:Character cr.
|
|
89 |
^ self.
|
932
|
90 |
].
|
949
|
91 |
self endEntry.
|
|
92 |
self cursorToBeginOfLine.
|
|
93 |
"/ continue in initial state
|
932
|
94 |
].
|
|
95 |
|
949
|
96 |
state == 0 ifTrue:[
|
|
97 |
"/ Currently, we are in initial state.
|
|
98 |
"/ Decide what to do on the basis of the parameter char.
|
|
99 |
|
|
100 |
(char == Character esc) ifTrue:[
|
|
101 |
self endEntry.
|
|
102 |
state := #gotESC.
|
|
103 |
^ self
|
|
104 |
].
|
|
105 |
(char == Character nl) ifTrue:[
|
956
|
106 |
self doCursorDown:1.
|
|
107 |
^ self endEntry.
|
949
|
108 |
].
|
|
109 |
(char == Character return) ifTrue:[
|
980
|
110 |
(rangeEndLine notNil and:[rangeEndLine ~~ numberOfLines]) ifTrue:[
|
956
|
111 |
self endEntry.
|
|
112 |
self cursorToBeginOfLine.
|
|
113 |
] ifFalse:[
|
|
114 |
state := #gotReturn.
|
|
115 |
].
|
949
|
116 |
^ self.
|
|
117 |
].
|
|
118 |
(char == Character backspace) ifTrue:[
|
956
|
119 |
self doCursorLeft. "/ doBackspace
|
|
120 |
^ self endEntry.
|
949
|
121 |
].
|
|
122 |
(char == Character bell) ifTrue:[
|
|
123 |
self beep.
|
|
124 |
^ self
|
|
125 |
].
|
|
126 |
char asciiValue < 32 ifTrue:[
|
956
|
127 |
char ~~ Character tab ifTrue:[
|
980
|
128 |
char asciiValue ~~ 0 ifTrue:[
|
|
129 |
Transcript show:'unhandled control key: '; showCR:char storeString.
|
|
130 |
].
|
|
131 |
^ self.
|
956
|
132 |
]
|
949
|
133 |
].
|
|
134 |
^ super nextPut:char
|
932
|
135 |
].
|
949
|
136 |
|
|
137 |
state == #gotESC ifTrue:[
|
|
138 |
"/ Currently, we are in ESC state.
|
|
139 |
"/ Decide what to do on the basis of the parameter char.
|
932
|
140 |
|
949
|
141 |
char == $A ifTrue:[
|
|
142 |
"/ ESC-A
|
956
|
143 |
self doCursorUp:1.
|
949
|
144 |
^ self endOfSequence
|
|
145 |
].
|
|
146 |
char == $B ifTrue:[
|
|
147 |
"/ ESC-B
|
956
|
148 |
self doCursorDown:1.
|
949
|
149 |
^ self endOfSequence
|
|
150 |
].
|
|
151 |
char == $C ifTrue:[
|
|
152 |
"/ ESC-C
|
956
|
153 |
self doCursorRight:1.
|
949
|
154 |
^ self endOfSequence
|
|
155 |
].
|
|
156 |
char == $D ifTrue:[
|
|
157 |
"/ ESC-D
|
956
|
158 |
self doCursorLeft:1.
|
949
|
159 |
^ self endOfSequence
|
|
160 |
].
|
|
161 |
char == $H ifTrue: [
|
|
162 |
"/ ESC-H
|
|
163 |
self doCursorHome.
|
|
164 |
^ self endOfSequence
|
|
165 |
].
|
|
166 |
char == $J ifTrue: [
|
|
167 |
"/ ESC-J
|
|
168 |
self doClearToEnd.
|
|
169 |
^ self endOfSequence
|
|
170 |
].
|
956
|
171 |
char == $K ifTrue: [
|
|
172 |
"/ ESC-J
|
|
173 |
self doClearToEndOfLine.
|
|
174 |
^ self endOfSequence
|
|
175 |
].
|
|
176 |
char == $Y ifTrue: [
|
|
177 |
"/ ESC-Y - cursor positioning
|
|
178 |
state := #motion1.
|
|
179 |
^ self
|
|
180 |
].
|
949
|
181 |
Transcript show:'unhandled esc-key: '; showCR:char storeString.
|
|
182 |
].
|
|
183 |
|
956
|
184 |
state == #motion1 ifTrue:[
|
|
185 |
"/ char-value - 32 is line
|
|
186 |
param1 := (char asciiValue - 32).
|
|
187 |
state := #motion2.
|
|
188 |
^ self.
|
|
189 |
].
|
|
190 |
state == #motion2 ifTrue:[
|
|
191 |
"/ char-value - 32 is col
|
|
192 |
param2 := (char asciiValue - 32).
|
|
193 |
"/ Transcript show:'motion '; show:param1+1; show:' '; showCR:param2+1.
|
|
194 |
self cursorVisibleLine:param1+1 col:param2+1.
|
|
195 |
^ self endOfSequence
|
|
196 |
].
|
|
197 |
|
949
|
198 |
self doNothing
|
|
199 |
|
980
|
200 |
"Modified: / 20.6.1998 / 19:51:48 / cg"
|
932
|
201 |
! !
|
|
202 |
|
|
203 |
!VT52TerminalView methodsFor:'queries'!
|
|
204 |
|
|
205 |
terminalType
|
|
206 |
^ #vt52
|
|
207 |
|
|
208 |
"Created: / 10.6.1998 / 16:22:46 / cg"
|
|
209 |
! !
|
|
210 |
|
914
|
211 |
!VT52TerminalView class methodsFor:'documentation'!
|
|
212 |
|
|
213 |
version
|
980
|
214 |
^ '$Header: /cvs/stx/stx/libwidg2/VT52TerminalView.st,v 1.9 1998-06-20 18:34:25 cg Exp $'
|
914
|
215 |
! !
|