author | Claus Gittinger <cg@exept.de> |
Thu, 24 Jun 1999 11:56:09 +0200 | |
changeset 1420 | 7564d09aa1b2 |
parent 1419 | 55972fc3268f |
child 2192 | 5f3bf896d334 |
permissions | -rw-r--r-- |
1362 | 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 |
" |
|
12 |
||
13 |
||
14 |
||
914 | 15 |
TerminalView subclass:#VT52TerminalView |
998 | 16 |
instanceVariableNames:'param1 param2' |
914 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Views-TerminalViews' |
|
20 |
! |
|
21 |
||
22 |
!VT52TerminalView class methodsFor:'documentation'! |
|
23 |
||
1362 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
914 | 40 |
documentation |
41 |
" |
|
1419 | 42 |
A VT52 terminal emulator. |
43 |
Most of the functionality is inherited from my superclass, |
|
44 |
I redefine/specialize certain methods for VT52 escape sequences |
|
45 |
and vt52 keyboard codes |
|
46 |
||
47 |
[start with:] |
|
48 |
VT52TerminalView openShell |
|
49 |
||
50 |
[see also:] |
|
51 |
VT100TerminalView |
|
52 |
TelnetTool |
|
914 | 53 |
|
54 |
[start with:] |
|
916 | 55 |
VT52TerminalView openShell |
914 | 56 |
" |
57 |
||
58 |
! ! |
|
59 |
||
60 |
!VT52TerminalView methodsFor:'defaults'! |
|
61 |
||
62 |
vt52KeyCodes |
|
1420 | 63 |
"return a vt52 keyCode table" |
64 |
||
914 | 65 |
^ IdentityDictionary withKeysAndValues: |
66 |
#( |
|
67 |
#CursorUp '\eA' |
|
68 |
#CursorDown '\eB' |
|
927 | 69 |
#CursorRight '\eC' |
70 |
#CursorLeft '\eD' |
|
914 | 71 |
#Home '\eH' |
72 |
#Escape '\e' |
|
927 | 73 |
#BackSpace '\b' |
914 | 74 |
#Return '\r' |
976 | 75 |
#Delete '\0177' |
1356 | 76 |
#Tab '\t' |
914 | 77 |
) |
927 | 78 |
|
1356 | 79 |
"Modified: / 5.5.1999 / 15:01:37 / cg" |
914 | 80 |
! ! |
81 |
||
956 | 82 |
!VT52TerminalView methodsFor:'events'! |
83 |
||
84 |
defineWindowSize |
|
85 |
super defineWindowSize. |
|
980 | 86 |
rangeEndLine := numberOfLines |
956 | 87 |
|
88 |
"Created: / 13.6.1998 / 18:15:43 / cg" |
|
980 | 89 |
"Modified: / 20.6.1998 / 20:33:29 / cg" |
956 | 90 |
! ! |
91 |
||
914 | 92 |
!VT52TerminalView methodsFor:'initialization'! |
93 |
||
94 |
initialize |
|
95 |
super initialize. |
|
949 | 96 |
self endOfSequence. |
914 | 97 |
|
980 | 98 |
"Modified: / 20.6.1998 / 20:34:18 / cg" |
914 | 99 |
! |
100 |
||
101 |
initializeKeyboardSequences |
|
1420 | 102 |
"setup my keyboard sequences for a vt52" |
103 |
||
914 | 104 |
kbdSequences := (self vt52KeyCodes) |
105 |
||
106 |
||
107 |
! ! |
|
108 |
||
932 | 109 |
!VT52TerminalView methodsFor:'processing - input'! |
110 |
||
949 | 111 |
nextPut:char |
112 |
"process a character (i.e. the shells output)" |
|
113 |
||
114 |
"/ Transcript show:state; show:' '; showCR:char storeString. |
|
115 |
||
116 |
state == #gotReturn ifTrue:[ |
|
117 |
state := 0. |
|
118 |
char == Character nl ifTrue:[ |
|
119 |
"/ cr-nl |
|
120 |
"/ stay in buffering mode. |
|
121 |
super nextPut:Character cr. |
|
122 |
^ self. |
|
932 | 123 |
]. |
949 | 124 |
self endEntry. |
125 |
self cursorToBeginOfLine. |
|
126 |
"/ continue in initial state |
|
932 | 127 |
]. |
128 |
||
949 | 129 |
state == 0 ifTrue:[ |
130 |
"/ Currently, we are in initial state. |
|
131 |
"/ Decide what to do on the basis of the parameter char. |
|
132 |
||
133 |
(char == Character esc) ifTrue:[ |
|
134 |
self endEntry. |
|
135 |
state := #gotESC. |
|
136 |
^ self |
|
137 |
]. |
|
138 |
(char == Character nl) ifTrue:[ |
|
956 | 139 |
self doCursorDown:1. |
140 |
^ self endEntry. |
|
949 | 141 |
]. |
142 |
(char == Character return) ifTrue:[ |
|
980 | 143 |
(rangeEndLine notNil and:[rangeEndLine ~~ numberOfLines]) ifTrue:[ |
956 | 144 |
self endEntry. |
145 |
self cursorToBeginOfLine. |
|
146 |
] ifFalse:[ |
|
147 |
state := #gotReturn. |
|
148 |
]. |
|
949 | 149 |
^ self. |
150 |
]. |
|
151 |
(char == Character backspace) ifTrue:[ |
|
956 | 152 |
self doCursorLeft. "/ doBackspace |
153 |
^ self endEntry. |
|
949 | 154 |
]. |
155 |
(char == Character bell) ifTrue:[ |
|
156 |
self beep. |
|
157 |
^ self |
|
158 |
]. |
|
159 |
char asciiValue < 32 ifTrue:[ |
|
956 | 160 |
char ~~ Character tab ifTrue:[ |
980 | 161 |
char asciiValue ~~ 0 ifTrue:[ |
162 |
Transcript show:'unhandled control key: '; showCR:char storeString. |
|
163 |
]. |
|
164 |
^ self. |
|
956 | 165 |
] |
949 | 166 |
]. |
167 |
^ super nextPut:char |
|
932 | 168 |
]. |
949 | 169 |
|
170 |
state == #gotESC ifTrue:[ |
|
171 |
"/ Currently, we are in ESC state. |
|
172 |
"/ Decide what to do on the basis of the parameter char. |
|
932 | 173 |
|
949 | 174 |
char == $A ifTrue:[ |
175 |
"/ ESC-A |
|
956 | 176 |
self doCursorUp:1. |
949 | 177 |
^ self endOfSequence |
178 |
]. |
|
179 |
char == $B ifTrue:[ |
|
180 |
"/ ESC-B |
|
956 | 181 |
self doCursorDown:1. |
949 | 182 |
^ self endOfSequence |
183 |
]. |
|
184 |
char == $C ifTrue:[ |
|
185 |
"/ ESC-C |
|
956 | 186 |
self doCursorRight:1. |
949 | 187 |
^ self endOfSequence |
188 |
]. |
|
189 |
char == $D ifTrue:[ |
|
190 |
"/ ESC-D |
|
956 | 191 |
self doCursorLeft:1. |
949 | 192 |
^ self endOfSequence |
193 |
]. |
|
194 |
char == $H ifTrue: [ |
|
195 |
"/ ESC-H |
|
196 |
self doCursorHome. |
|
197 |
^ self endOfSequence |
|
198 |
]. |
|
199 |
char == $J ifTrue: [ |
|
200 |
"/ ESC-J |
|
1001
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
201 |
self doClearToEndOfScreen. |
949 | 202 |
^ self endOfSequence |
203 |
]. |
|
956 | 204 |
char == $K ifTrue: [ |
205 |
"/ ESC-J |
|
206 |
self doClearToEndOfLine. |
|
207 |
^ self endOfSequence |
|
208 |
]. |
|
209 |
char == $Y ifTrue: [ |
|
210 |
"/ ESC-Y - cursor positioning |
|
211 |
state := #motion1. |
|
212 |
^ self |
|
213 |
]. |
|
949 | 214 |
Transcript show:'unhandled esc-key: '; showCR:char storeString. |
215 |
]. |
|
216 |
||
956 | 217 |
state == #motion1 ifTrue:[ |
218 |
"/ char-value - 32 is line |
|
219 |
param1 := (char asciiValue - 32). |
|
220 |
state := #motion2. |
|
221 |
^ self. |
|
222 |
]. |
|
223 |
state == #motion2 ifTrue:[ |
|
224 |
"/ char-value - 32 is col |
|
225 |
param2 := (char asciiValue - 32). |
|
226 |
"/ Transcript show:'motion '; show:param1+1; show:' '; showCR:param2+1. |
|
227 |
self cursorVisibleLine:param1+1 col:param2+1. |
|
228 |
^ self endOfSequence |
|
229 |
]. |
|
230 |
||
949 | 231 |
self doNothing |
232 |
||
1001
7fe14ad43ae3
fixed clear-to-end-of-screen function.
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
233 |
"Modified: / 21.7.1998 / 20:06:04 / cg" |
932 | 234 |
! ! |
235 |
||
236 |
!VT52TerminalView methodsFor:'queries'! |
|
237 |
||
238 |
terminalType |
|
1420 | 239 |
"returns a string describing this terminal (usually, this is |
240 |
passed down to the shell as TERM environment variable). |
|
241 |
Here, 'vt52' is returned." |
|
242 |
||
1353 | 243 |
^ 'vt52' |
932 | 244 |
|
245 |
"Created: / 10.6.1998 / 16:22:46 / cg" |
|
1353 | 246 |
"Modified: / 5.5.1999 / 11:22:50 / cg" |
932 | 247 |
! ! |
248 |
||
914 | 249 |
!VT52TerminalView class methodsFor:'documentation'! |
250 |
||
251 |
version |
|
1420 | 252 |
^ '$Header: /cvs/stx/stx/libwidg2/VT52TerminalView.st,v 1.16 1999-06-24 09:56:09 cg Exp $' |
914 | 253 |
! ! |