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