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