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