author | Claus Gittinger <cg@exept.de> |
Fri, 02 Oct 1998 18:52:09 +0200 | |
changeset 1161 | 42796d8e6544 |
parent 1077 | 49525bbae21c |
child 1182 | c3809bedfd32 |
permissions | -rw-r--r-- |
914 | 1 |
TextCollector subclass:#TerminalView |
943 | 2 |
instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences |
3 |
escapeSequenceTree currentSequence currentTree kbdMap |
|
946 | 4 |
escapeLeadingChars numberOfColumns numberOfLines |
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
5 |
shellTerminateAction rangeStartLine rangeEndLine state |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
6 |
savedCursor' |
943 | 7 |
classVariableNames:'' |
8 |
poolDictionaries:'' |
|
9 |
category:'Views-TerminalViews' |
|
914 | 10 |
! |
11 |
||
12 |
!TerminalView class methodsFor:'documentation'! |
|
13 |
||
14 |
documentation |
|
15 |
" |
|
916 | 16 |
I provide terminal functionality, by forking a command interpreter |
17 |
and comunicating with it via a pty. |
|
18 |
I am abstract - concrete terminal characteristics are defined |
|
19 |
by concrete subclasses (see VT52TerminalView). |
|
914 | 20 |
|
21 |
[author:] |
|
22 |
Claus Gittinger |
|
915 | 23 |
|
24 |
[start with:] |
|
25 |
VT52TerminalView openShell |
|
919 | 26 |
VT100TerminalView openShell |
914 | 27 |
" |
28 |
! ! |
|
29 |
||
1052 | 30 |
!TerminalView class methodsFor:'defaults'! |
31 |
||
32 |
defaultIcon |
|
33 |
^ Image fromFile:'bitmaps/xpmBitmaps/terminal_images/xterm-icon.xpm' |
|
34 |
||
35 |
"Created: / 4.8.1998 / 17:48:18 / cg" |
|
36 |
"Modified: / 4.8.1998 / 17:48:31 / cg" |
|
37 |
! ! |
|
38 |
||
972 | 39 |
!TerminalView class methodsFor:'opening'! |
914 | 40 |
|
928 | 41 |
open |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
42 |
^ self openShell |
928 | 43 |
|
44 |
" |
|
45 |
VT100TerminalView open |
|
46 |
" |
|
47 |
||
48 |
"Created: / 10.6.1998 / 15:47:25 / cg" |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
49 |
"Modified: / 9.7.1998 / 17:55:37 / cg" |
928 | 50 |
! |
51 |
||
914 | 52 |
openDummy |
972 | 53 |
"for testing purposes only - opens a dummy tty-view, which simply |
54 |
echoes whatever is typed in" |
|
55 |
||
914 | 56 |
|in vt52| |
57 |
||
58 |
vt52 := self new. |
|
59 |
in := ForwardingStream on:''. |
|
60 |
||
61 |
in fwdStream:vt52. |
|
62 |
vt52 inStream:in. |
|
63 |
vt52 outStream:in. |
|
64 |
vt52 open |
|
65 |
||
66 |
" |
|
67 |
self openDummy |
|
68 |
" |
|
69 |
! |
|
70 |
||
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
71 |
openOnCommand:aCommandString |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
72 |
"start a command on a pseudo-TTY, open a terminalView on it |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
73 |
(i.e. this is kind of an xterm)" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
74 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
75 |
^ self openOnCommand:aCommandString onExit:[] |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
76 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
77 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
78 |
VT100TerminalView openOnCommand:'ls -l' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
79 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
80 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
81 |
"Created: / 9.7.1998 / 17:50:53 / cg" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
82 |
"Modified: / 9.7.1998 / 17:57:41 / cg" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
83 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
84 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
85 |
openOnCommand:aCommandString onExit:aBlock |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
86 |
"start a command on a pseudo-TTY, open a terminalView on its output |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
87 |
(i.e. this is kind of an xterm). |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
88 |
When the command finishes, evaluate aBlock." |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
89 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
90 |
|in top scr vt52| |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
91 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
92 |
top := StandardSystemView new. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
93 |
scr := ScrollableView for:self in:top. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
94 |
scr origin:0.0@0.0 corner:1.0@1.0. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
95 |
vt52 := scr scrolledView. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
96 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
97 |
vt52 startCommand:aCommandString. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
98 |
vt52 shellTerminateAction:[ |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
99 |
top label:('finished: "' , aCommandString , '"'). aBlock value |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
100 |
]. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
101 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
102 |
top extent:(scr preferredExtent). |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
103 |
top label:('executing: "' , aCommandString , '"'). |
1014 | 104 |
top iconLabel:'command'. |
1052 | 105 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
106 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
107 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
108 |
^ vt52 |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
109 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
110 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
111 |
VT100TerminalView openOnCommand:'ls -lR' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
112 |
VT100TerminalView openOnCommand:'vi /etc/hosts' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
113 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
114 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
115 |
"Created: / 9.7.1998 / 17:54:34 / cg" |
1052 | 116 |
"Modified: / 4.8.1998 / 17:49:02 / cg" |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
117 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
118 |
|
1014 | 119 |
openOnInput:inStream output:outStream |
972 | 120 |
"open a terminalView on the given streams (which are typically some |
121 |
kind of socket). Keys pressed are sent to inStream, text appearing |
|
122 |
from outStream are displayed in the terminal view. |
|
123 |
This can be used to implement things like rlogin |
|
124 |
or telnet views (if connected to a modem, a call-unix can also be |
|
125 |
implemented this way)." |
|
126 |
||
127 |
|in top scr vt52| |
|
128 |
||
129 |
top := StandardSystemView new. |
|
130 |
scr := ScrollableView for:self in:top. |
|
131 |
scr origin:0.0@0.0 corner:1.0@1.0. |
|
132 |
vt52 := scr scrolledView. |
|
133 |
||
134 |
vt52 inStream:inStream. |
|
135 |
vt52 outStream:outStream. |
|
974 | 136 |
vt52 startReaderProcess. |
972 | 137 |
|
138 |
top extent:(scr preferredExtent). |
|
139 |
top label:'shell'. |
|
1014 | 140 |
top iconLabel:'shell'. |
1052 | 141 |
top icon:(self defaultIcon). |
972 | 142 |
top open. |
143 |
^ top |
|
974 | 144 |
|
1052 | 145 |
"Modified: / 4.8.1998 / 17:48:59 / cg" |
972 | 146 |
! |
147 |
||
914 | 148 |
openShell |
972 | 149 |
"start a shell on a pseudo-TTY, open a terminalView on it |
150 |
(i.e. this is kind of an xterm)" |
|
151 |
||
997 | 152 |
^ self openShellIn:nil |
992 | 153 |
|
154 |
" |
|
155 |
VT100TerminalView openShell |
|
156 |
" |
|
157 |
||
997 | 158 |
"Modified: / 21.7.1998 / 18:24:55 / cg" |
992 | 159 |
! |
160 |
||
161 |
openShellIn:aDirectory |
|
162 |
"start a shell on a pseudo-TTY, open a terminalView on it |
|
163 |
(i.e. this is kind of an xterm)" |
|
164 |
||
914 | 165 |
|in top scr vt52| |
166 |
||
167 |
top := StandardSystemView new. |
|
948 | 168 |
scr := ScrollableView for:self in:top. |
914 | 169 |
scr origin:0.0@0.0 corner:1.0@1.0. |
170 |
vt52 := scr scrolledView. |
|
171 |
||
992 | 172 |
vt52 startShellIn:aDirectory. |
946 | 173 |
vt52 shellTerminateAction:[top destroy]. |
174 |
||
940 | 175 |
top extent:(scr preferredExtent). |
176 |
top label:'shell'. |
|
1014 | 177 |
top iconLabel:'shell'. |
1052 | 178 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
179 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
180 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
181 |
^ vt52 |
914 | 182 |
|
183 |
" |
|
992 | 184 |
VT100TerminalView openShellIn:'/etc' |
914 | 185 |
" |
946 | 186 |
|
992 | 187 |
"Created: / 20.7.1998 / 18:28:15 / cg" |
1052 | 188 |
"Modified: / 4.8.1998 / 17:48:54 / cg" |
914 | 189 |
! ! |
190 |
||
972 | 191 |
!TerminalView class methodsFor:'queries'! |
192 |
||
193 |
isVisualStartable |
|
194 |
"returns whether this application class can be started via #open" |
|
195 |
||
196 |
self == TerminalView ifTrue:[^ false]. |
|
197 |
^ true |
|
198 |
||
199 |
"Created: / 10.6.1998 / 15:48:43 / cg" |
|
200 |
! ! |
|
201 |
||
914 | 202 |
!TerminalView methodsFor:'accessing'! |
203 |
||
204 |
inStream |
|
205 |
"return the value of the instance variable 'inStream' (automatically generated)" |
|
206 |
||
207 |
^ inStream! |
|
208 |
||
209 |
inStream:something |
|
210 |
"set the value of the instance variable 'inStream' (automatically generated)" |
|
211 |
||
212 |
inStream := something.! |
|
213 |
||
214 |
outStream |
|
215 |
"return the value of the instance variable 'outStream' (automatically generated)" |
|
216 |
||
217 |
^ outStream! |
|
218 |
||
219 |
outStream:something |
|
220 |
"set the value of the instance variable 'outStream' (automatically generated)" |
|
221 |
||
946 | 222 |
outStream := something.! |
223 |
||
1004 | 224 |
readerProcess |
225 |
"return the value of the instance variable 'readerProcess' (automatically generated)" |
|
226 |
||
227 |
^ readerProcess |
|
228 |
! |
|
229 |
||
946 | 230 |
shellTerminateAction:aBlock |
231 |
"set the block which is evaluated when the shell terminates. |
|
232 |
Can be used to close down the application in this case." |
|
233 |
||
234 |
shellTerminateAction := aBlock. |
|
235 |
||
236 |
"Created: / 12.6.1998 / 17:02:58 / cg" |
|
237 |
! ! |
|
914 | 238 |
|
239 |
!TerminalView methodsFor:'cursor handling'! |
|
240 |
||
241 |
cursorCol:col |
|
242 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
243 |
Here, the linelength is enforced" |
|
244 |
||
926 | 245 |
^ super cursorCol:(col min:numberOfColumns) |
914 | 246 |
|
926 | 247 |
"Modified: / 10.6.1998 / 15:09:34 / cg" |
914 | 248 |
! |
249 |
||
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
250 |
cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
251 |
cursorLine + n > list size ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
252 |
list := list , (Array new:n). |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
253 |
self textChanged. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
254 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
255 |
super cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
256 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
257 |
"Modified: / 10.6.1998 / 17:18:41 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
258 |
"Created: / 10.6.1998 / 17:18:50 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
259 |
! |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
260 |
|
914 | 261 |
cursorLine:l col:col |
262 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
263 |
Here, the linelength is enforced" |
|
264 |
||
926 | 265 |
^ super cursorLine:l col:(col min:numberOfColumns) |
914 | 266 |
|
926 | 267 |
"Modified: / 10.6.1998 / 15:09:38 / cg" |
914 | 268 |
! |
269 |
||
968
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
270 |
cursorMovementAllowed |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
271 |
"return true, if the user may move the cursor around |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
272 |
(via button-click, or cursor-key with selection). |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
273 |
Here false is returned - the cursor is only moved by |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
274 |
cursor positioning escape sequences arriving from the |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
275 |
stream." |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
276 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
277 |
^ false |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
278 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
279 |
"Created: / 18.6.1998 / 14:12:02 / cg" |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
280 |
! |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
281 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
282 |
restoreCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
283 |
|l c| |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
284 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
285 |
l := savedCursor y. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
286 |
c := savedCursor x. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
287 |
self cursorLine:l col:c. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
288 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
289 |
"Created: / 14.8.1998 / 13:49:24 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
290 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
291 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
292 |
saveCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
293 |
savedCursor := cursorCol @ cursorLine |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
294 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
295 |
"Created: / 14.8.1998 / 13:48:45 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
296 |
"Modified: / 14.8.1998 / 13:49:32 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
297 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
298 |
|
914 | 299 |
validateCursorCol:col inLine:line |
300 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
301 |
Here, the linelength is enforced" |
|
302 |
||
926 | 303 |
^ col min:numberOfColumns |
914 | 304 |
|
926 | 305 |
"Modified: / 10.6.1998 / 15:09:41 / cg" |
914 | 306 |
! ! |
307 |
||
308 |
!TerminalView methodsFor:'event handling'! |
|
309 |
||
951 | 310 |
computeNumberOfLinesShown |
311 |
|prevNLines prevNCols| |
|
312 |
||
313 |
prevNCols := (innerWidth // font width). |
|
314 |
prevNLines := nFullLinesShown. |
|
315 |
||
316 |
super computeNumberOfLinesShown. |
|
317 |
||
318 |
((innerWidth // font width) ~~ prevNCols |
|
319 |
or:[prevNLines ~~ nFullLinesShown]) ifTrue:[ |
|
320 |
self defineWindowSize. |
|
321 |
] |
|
322 |
||
323 |
"Created: / 12.6.1998 / 22:34:39 / cg" |
|
979 | 324 |
"Modified: / 20.6.1998 / 19:45:28 / cg" |
951 | 325 |
! |
326 |
||
943 | 327 |
defineWindowSize |
1161 | 328 |
|fd| |
329 |
||
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
330 |
(inStream notNil |
1161 | 331 |
and:[inStream isExternalStream |
332 |
and:[inStream isOpen]]) ifTrue:[ |
|
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
333 |
(OperatingSystem |
1161 | 334 |
setWindowSizeOnFileDescriptor:inStream fileDescriptor |
943 | 335 |
width:(innerWidth // font width) |
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
336 |
height:(nFullLinesShown)) ifFalse:[ |
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
337 |
"/ Transcript showCR:'VT100: cannot change windowSize'. |
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
338 |
]. |
951 | 339 |
numberOfLines := nFullLinesShown. |
979 | 340 |
"/ Transcript showCR:'VT100: changed len to ', numberOfLines printString. |
943 | 341 |
]. |
342 |
shellPid notNil ifTrue:[ |
|
343 |
OperatingSystem sendSignal:OperatingSystem sigWINCH to:shellPid |
|
344 |
] |
|
345 |
||
346 |
"Created: / 11.6.1998 / 22:51:39 / cg" |
|
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
347 |
"Modified: / 27.7.1998 / 16:07:18 / cg" |
943 | 348 |
! |
349 |
||
914 | 350 |
keyPress:aKey x:x y:y |
351 |
|rest rawKey seq| |
|
352 |
||
353 |
inStream isNil ifTrue:[^ self]. |
|
354 |
||
931 | 355 |
"/ Transcript showCR:'----'; show:'key:' ; showCR:aKey printString. |
914 | 356 |
|
357 |
aKey isCharacter ifTrue:[ |
|
358 |
"/ send it down to inStream ... |
|
359 |
inStream nextPut:aKey. |
|
360 |
^ self |
|
361 |
]. |
|
362 |
||
921 | 363 |
aKey == #Tab ifTrue:[ |
931 | 364 |
"/ Transcript show:'->' ; showCR:Character tab storeString. |
921 | 365 |
inStream nextPut:Character tab. |
366 |
^ self |
|
367 |
]. |
|
368 |
||
914 | 369 |
seq := kbdSequences at:aKey ifAbsent:nil. |
370 |
seq notNil ifTrue:[ |
|
931 | 371 |
"/ Transcript show:'->' ; showCR:seq storeString. |
914 | 372 |
inStream nextPutAll:(seq withEscapes). |
373 |
^ self |
|
374 |
]. |
|
375 |
||
376 |
rawKey := device keyboardMap keyAtValue:aKey ifAbsent:aKey. |
|
377 |
seq := kbdSequences at:rawKey ifAbsent:nil. |
|
378 |
seq notNil ifTrue:[ |
|
931 | 379 |
"/ Transcript show:'->' ; showCR:seq storeString. |
914 | 380 |
inStream nextPutAll:(seq withEscapes). |
381 |
^ self |
|
382 |
]. |
|
383 |
||
384 |
(rawKey startsWith:'Ctrl') ifTrue:[ |
|
385 |
rest := rawKey copyFrom:5. |
|
386 |
rest size == 1 ifTrue:[ |
|
387 |
rest := rest at:1. |
|
388 |
(rest >= $a and:[rest <= $z]) ifTrue:[ |
|
931 | 389 |
"/ Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
914 | 390 |
inStream nextPut:(Character value:(rest - $a + 1)). |
391 |
^ self |
|
392 |
]. |
|
393 |
(rest >= $A and:[rest <= $Z]) ifTrue:[ |
|
931 | 394 |
"/ Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
914 | 395 |
inStream nextPut:(Character value:(rest - $A + 1)). |
396 |
^ self |
|
397 |
]. |
|
398 |
] |
|
399 |
]. |
|
400 |
||
934 | 401 |
(rawKey startsWith:'Control') ifTrue:[ |
402 |
^ self |
|
403 |
]. |
|
404 |
(rawKey startsWith:'Shift') ifTrue:[ |
|
405 |
^ self |
|
406 |
]. |
|
407 |
(rawKey startsWith:'Alt') ifTrue:[ |
|
408 |
^ self |
|
409 |
]. |
|
410 |
(rawKey startsWith:'Cmd') ifTrue:[ |
|
950 | 411 |
^ super keyPress:aKey x:x y:y |
934 | 412 |
]. |
413 |
||
414 |
Transcript show:'unhandled: '; showCR:rawKey. |
|
914 | 415 |
|
950 | 416 |
"Modified: / 12.6.1998 / 22:16:50 / cg" |
914 | 417 |
! |
418 |
||
419 |
shellTerminated |
|
420 |
self closeDownShell. |
|
946 | 421 |
shellTerminateAction notNil ifTrue:[ |
422 |
shellTerminateAction value |
|
423 |
] ifFalse:[ |
|
424 |
"/ may be removed ... |
|
425 |
self warn:'shell terminated'. |
|
426 |
] |
|
427 |
||
428 |
"Modified: / 12.6.1998 / 17:03:26 / cg" |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
429 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
430 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
431 |
sizeChanged:how |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
432 |
super sizeChanged:how. |
943 | 433 |
self defineWindowSize. |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
434 |
|
943 | 435 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
914 | 436 |
! ! |
437 |
||
438 |
!TerminalView methodsFor:'functions'! |
|
439 |
||
440 |
doBackspace |
|
441 |
self cursorLeft. |
|
442 |
self replaceCharAtCursor:(Character space). |
|
443 |
self cursorLeft. |
|
444 |
||
931 | 445 |
"Modified: / 10.6.1998 / 17:09:12 / cg" |
914 | 446 |
! |
447 |
||
926 | 448 |
doClearDisplay |
1000 | 449 |
self doClearEntireScreen. |
450 |
||
451 |
"Modified: / 21.7.1998 / 20:05:35 / cg" |
|
452 |
! |
|
453 |
||
454 |
doClearEntireScreen |
|
926 | 455 |
firstLineShown to:(list size) do:[:l | |
456 |
self at:l put:'' |
|
457 |
]. |
|
922 | 458 |
|
1000 | 459 |
"Modified: / 21.7.1998 / 20:00:19 / cg" |
460 |
"Created: / 21.7.1998 / 20:05:24 / cg" |
|
926 | 461 |
! |
462 |
||
1000 | 463 |
doClearFromBeginningOfLine |
464 |
|l| |
|
465 |
||
466 |
l := self listAt:cursorLine. |
|
467 |
l notNil ifTrue:[ |
|
468 |
(l size >= (cursorCol-1)) ifTrue:[ |
|
469 |
l := l copy from:1 to:cursorCol-1 put:(Character space). |
|
470 |
] ifFalse:[ |
|
471 |
l := nil. |
|
472 |
]. |
|
473 |
self withoutRedrawAt:cursorLine put:l. |
|
474 |
self invalidateLine:cursorLine |
|
475 |
"/ self at:cursorLine put:l. |
|
476 |
] |
|
477 |
||
478 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
|
479 |
"Created: / 21.7.1998 / 20:10:58 / cg" |
|
480 |
! |
|
481 |
||
482 |
doClearFromBeginningOfScreen |
|
483 |
self doClearFromBeginningOfLine. |
|
484 |
cursorLine-1 to:firstLineShown do:[:l | |
|
922 | 485 |
self at:l put:'' |
486 |
]. |
|
487 |
||
926 | 488 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
1000 | 489 |
"Created: / 21.7.1998 / 20:08:29 / cg" |
926 | 490 |
! |
491 |
||
492 |
doClearToEndOfLine |
|
493 |
|l| |
|
494 |
||
495 |
l := self listAt:cursorLine. |
|
931 | 496 |
(l size >= (cursorCol-1)) ifTrue:[ |
951 | 497 |
l notNil ifTrue:[ |
498 |
l := l copyTo:cursorCol-1. |
|
979 | 499 |
self withoutRedrawAt:cursorLine put:l. |
500 |
self invalidateLine:cursorLine |
|
501 |
"/ self at:cursorLine put:l. |
|
951 | 502 |
] |
926 | 503 |
] |
504 |
||
505 |
"Created: / 10.6.1998 / 14:45:01 / cg" |
|
979 | 506 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
914 | 507 |
! |
508 |
||
1000 | 509 |
doClearToEndOfScreen |
510 |
self doClearToEndOfLine. |
|
511 |
cursorLine+1 to:(list size) do:[:l | |
|
512 |
self at:l put:'' |
|
513 |
]. |
|
514 |
||
515 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
|
516 |
"Created: / 21.7.1998 / 20:06:14 / cg" |
|
517 |
! |
|
518 |
||
926 | 519 |
doCursorDown:n |
979 | 520 |
|wasOn rEnd| |
926 | 521 |
|
979 | 522 |
"/ rangeEndLine == numberOfLines ifTrue:[ |
523 |
"/ ^ super cursorDown:n |
|
524 |
"/ ]. |
|
525 |
cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[ |
|
951 | 526 |
"/ no special action req'd |
527 |
^ super cursorDown:n |
|
528 |
]. |
|
979 | 529 |
|
951 | 530 |
n timesRepeat:[ |
531 |
wasOn := self hideCursor. |
|
979 | 532 |
rEnd := rangeEndLine+firstLineShown-1. |
533 |
cursorLine == rEnd ifTrue:[ |
|
534 |
self deleteLine:(rangeStartLine+firstLineShown-1). |
|
535 |
self insertLine:'' before:rEnd. |
|
951 | 536 |
] ifFalse:[ |
537 |
super cursorDown |
|
538 |
]. |
|
979 | 539 |
wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn. |
951 | 540 |
] |
541 |
||
979 | 542 |
"Modified: / 20.6.1998 / 20:29:39 / cg" |
926 | 543 |
! |
544 |
||
914 | 545 |
doCursorHome |
938 | 546 |
self cursorVisibleLine:1 col:1 |
547 |
"/ super cursorHome |
|
548 |
||
549 |
"Modified: / 10.6.1998 / 20:47:31 / cg" |
|
914 | 550 |
! |
551 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
552 |
doCursorLeft:n |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
553 |
n timesRepeat:[ |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
554 |
super cursorLeft |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
555 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
556 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
557 |
"Created: / 11.6.1998 / 22:30:00 / cg" |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
558 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
559 |
|
914 | 560 |
doCursorNewLine |
931 | 561 |
super cursorDown:1 |
562 |
||
563 |
"Modified: / 10.6.1998 / 16:55:57 / cg" |
|
914 | 564 |
! |
565 |
||
566 |
doCursorReturn |
|
567 |
super cursorToBeginOfLine |
|
568 |
! |
|
569 |
||
926 | 570 |
doCursorRight:n |
571 |
self cursorCol:(cursorCol + n) |
|
572 |
||
573 |
"Created: / 10.6.1998 / 15:10:08 / cg" |
|
574 |
! |
|
575 |
||
951 | 576 |
doCursorUp:n |
979 | 577 |
|wasOn rStart| |
926 | 578 |
|
979 | 579 |
"/ rangeStartLine == 1 ifTrue:[ |
580 |
"/ ^ super cursorUp:n |
|
581 |
"/ ]. |
|
582 |
cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[ |
|
951 | 583 |
"/ no special action req'd |
584 |
^ super cursorUp:n |
|
585 |
]. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
586 |
n timesRepeat:[ |
951 | 587 |
wasOn := self hideCursor. |
979 | 588 |
rStart := rangeStartLine+firstLineShown-1. |
589 |
cursorLine == rStart ifTrue:[ |
|
590 |
(rangeEndLine+firstLineShown-1) <= list size ifTrue:[ |
|
591 |
self deleteLine:(rangeEndLine+firstLineShown-1). |
|
592 |
self insertLine:'' before:rStart. |
|
593 |
]. |
|
951 | 594 |
] ifFalse:[ |
595 |
super cursorUp |
|
596 |
]. |
|
597 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
598 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
599 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
600 |
"Created: / 11.6.1998 / 22:29:46 / cg" |
979 | 601 |
"Modified: / 20.6.1998 / 20:30:34 / cg" |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
602 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
603 |
|
926 | 604 |
doSendInterrupt |
605 |
OperatingSystem sendSignal:(OperatingSystem sigINT) to:shellPid negated. |
|
606 |
||
934 | 607 |
"Modified: / 10.6.1998 / 17:49:49 / cg" |
914 | 608 |
! ! |
609 |
||
610 |
!TerminalView methodsFor:'initialization'! |
|
611 |
||
612 |
closeDownShell |
|
1009 | 613 |
|pid| |
926 | 614 |
|
615 |
(pid := shellPid) notNil ifTrue:[ |
|
934 | 616 |
"/ Transcript print:'killing shell pid='; showCR:pid. |
617 |
||
926 | 618 |
OperatingSystem terminateProcessGroup:pid. |
619 |
OperatingSystem terminateProcess:pid. |
|
925 | 620 |
Delay waitForSeconds:1. |
621 |
shellPid notNil ifTrue:[ |
|
926 | 622 |
OperatingSystem killProcessGroup:pid. |
623 |
OperatingSystem killProcess:pid. |
|
925 | 624 |
shellPid := nil. |
625 |
]. |
|
926 | 626 |
OperatingSystem closePid:pid. |
914 | 627 |
]. |
628 |
||
1009 | 629 |
self stopReaderProcess. |
630 |
||
914 | 631 |
inStream notNil ifTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
632 |
inStream isStream ifTrue:[inStream close]. |
914 | 633 |
inStream := nil |
634 |
]. |
|
635 |
outStream notNil ifTrue:[ |
|
636 |
outStream close. |
|
637 |
outStream := nil |
|
638 |
]. |
|
924 | 639 |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
640 |
"Modified: / 28.7.1998 / 00:03:52 / cg" |
914 | 641 |
! |
642 |
||
643 |
destroy |
|
644 |
self closeDownShell. |
|
645 |
super destroy |
|
646 |
! |
|
647 |
||
648 |
escapeSequences:codes |
|
649 |
|tree| |
|
650 |
||
651 |
tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new]. |
|
652 |
||
653 |
codes do:[:specEntry | |
|
654 |
|sequence function| |
|
655 |
||
656 |
sequence := (specEntry at:1) withEscapes. |
|
657 |
function := specEntry at:2. |
|
658 |
||
659 |
tree := escapeSequenceTree. |
|
660 |
||
661 |
sequence keysAndValuesDo:[:idx :char | |
|
662 |
|followup| |
|
663 |
||
664 |
idx == sequence size ifTrue:[ |
|
665 |
tree at:char put:function |
|
666 |
] ifFalse:[ |
|
667 |
followup := tree at:char ifAbsent:nil. |
|
668 |
followup isNil ifTrue:[ |
|
669 |
tree at:char put:(followup := IdentityDictionary new). |
|
670 |
]. |
|
671 |
tree := followup |
|
672 |
] |
|
673 |
] |
|
674 |
]. |
|
918 | 675 |
escapeLeadingChars := escapeSequenceTree keys asSet. |
676 |
escapeLeadingChars add:(Character cr). |
|
677 |
escapeLeadingChars add:(Character return). |
|
678 |
escapeLeadingChars add:(Character backspace). |
|
679 |
||
680 |
escapeLeadingChars := escapeLeadingChars asArray |
|
681 |
||
682 |
"Modified: / 9.6.1998 / 19:43:12 / cg" |
|
914 | 683 |
! |
684 |
||
685 |
initialize |
|
686 |
super initialize. |
|
687 |
||
688 |
showMatchingParenthesis := false. |
|
689 |
insertMode := false. |
|
936 | 690 |
alwaysAppendAtEnd := false. |
944 | 691 |
collectSize := 100. |
977 | 692 |
st80Mode := false. |
693 |
trimBlankLines := true. |
|
914 | 694 |
|
926 | 695 |
numberOfColumns := 80. |
979 | 696 |
numberOfLines := 24. |
954 | 697 |
rangeStartLine := 1. |
698 |
rangeEndLine := numberOfLines. |
|
926 | 699 |
|
914 | 700 |
self initializeKeyboardSequences. |
701 |
list := OrderedCollection new:24 withAll:''. |
|
702 |
||
703 |
self initializeKeyboardMap. |
|
704 |
||
705 |
" |
|
706 |
VT52TerminalView openShell |
|
926 | 707 |
VT100TerminalView openShell |
914 | 708 |
" |
926 | 709 |
|
979 | 710 |
"Modified: / 20.6.1998 / 20:06:49 / cg" |
914 | 711 |
! |
712 |
||
713 |
initializeKeyboardMap |
|
714 |
|ctrlKeys cmdKeys| |
|
715 |
||
716 |
"/ setup my own keyboardMap, where control-keys are |
|
717 |
"/ not translated. |
|
718 |
kbdMap := device keyboardMap copy. |
|
719 |
||
720 |
ctrlKeys := kbdMap keys select:[:key | key startsWith:'Ctrl']. |
|
721 |
ctrlKeys do:[:key | kbdMap removeKey:key]. |
|
950 | 722 |
|
914 | 723 |
cmdKeys := kbdMap keys select:[:key | key startsWith:'Cmd']. |
950 | 724 |
cmdKeys do:[:key | |
725 |
(#(Copy Paste SaveAs Print) includes:(kbdMap at:key)) ifFalse:[ |
|
726 |
kbdMap removeKey:key |
|
727 |
] |
|
728 |
]. |
|
914 | 729 |
|
730 |
kbdMap removeKey:#Delete ifAbsent:[]. |
|
731 |
kbdMap removeKey:#BackSpace ifAbsent:[]. |
|
732 |
||
733 |
" |
|
734 |
VT52TerminalView openShell |
|
735 |
" |
|
950 | 736 |
|
737 |
"Modified: / 12.6.1998 / 22:18:23 / cg" |
|
914 | 738 |
! |
739 |
||
740 |
initializeKeyboardSequences |
|
741 |
self subclassResponsibility. |
|
742 |
! |
|
743 |
||
744 |
keyboardMap |
|
934 | 745 |
"return my keyboard map. This has control keys removed and |
746 |
those will be passed unchanged to the shell" |
|
747 |
||
914 | 748 |
^ kbdMap |
934 | 749 |
|
750 |
"Modified: / 10.6.1998 / 17:46:59 / cg" |
|
914 | 751 |
! |
752 |
||
753 |
startReaderProcess |
|
934 | 754 |
"Start a reader process, which looks for the commands output, |
1009 | 755 |
and sends me #processInput:n: events whenever something arrives." |
934 | 756 |
|
914 | 757 |
readerProcess isNil ifTrue:[ |
758 |
readerProcess := [ |
|
759 |
[ |
|
947 | 760 |
self waitUntilVisible. |
761 |
||
940 | 762 |
Stream streamErrorSignal handle:[:ex | |
763 |
Transcript showCR:ex errorString. |
|
764 |
Transcript showCR:OperatingSystem lastErrorString. |
|
765 |
] do:[ |
|
926 | 766 |
[true] whileTrue:[ |
767 |
Object abortSignal handle:[:ex | |
|
768 |
self showCursor. |
|
769 |
] do:[ |
|
948 | 770 |
|buffer n| |
771 |
||
926 | 772 |
outStream readWait. |
945 | 773 |
(self sensor hasKeyPressEventFor:self) ifTrue:[ |
999 | 774 |
(self sensor userEventCount > 10) ifTrue:[ |
997 | 775 |
"/ give terminalView a chance to |
776 |
"/ send out the character. |
|
777 |
Delay waitForSeconds:0.1. |
|
778 |
] |
|
926 | 779 |
] ifFalse:[ |
945 | 780 |
buffer := String new:1024. |
781 |
n := outStream nextAvailableBytes:1024 into:buffer startingAt:1. |
|
782 |
||
783 |
n > 0 ifTrue:[ |
|
784 |
self pushEvent:#processInput:n: with:buffer with:n. |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
785 |
self waitForOutputToDrain. |
945 | 786 |
] ifFalse:[ |
787 |
n == 0 ifTrue:[ |
|
788 |
outStream atEnd ifTrue:[ |
|
789 |
outStream close. outStream := nil. |
|
790 |
inStream close. inStream := nil. |
|
791 |
||
792 |
Processor activeProcess terminate. |
|
793 |
] |
|
926 | 794 |
] |
795 |
] |
|
914 | 796 |
] |
797 |
] |
|
798 |
] |
|
799 |
] |
|
800 |
] valueOnUnwindDo:[ |
|
801 |
readerProcess := nil |
|
802 |
] |
|
997 | 803 |
] fork. "/ forkAt:9. |
804 |
readerProcess name:'pty reader'. |
|
914 | 805 |
] |
806 |
||
807 |
" |
|
934 | 808 |
VT100TerminalView openShell |
914 | 809 |
" |
926 | 810 |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
811 |
"Modified: / 27.7.1998 / 23:47:55 / cg" |
1009 | 812 |
! |
813 |
||
814 |
stopReaderProcess |
|
815 |
|sensor| |
|
816 |
||
817 |
readerProcess notNil ifTrue:[ |
|
818 |
readerProcess terminate. |
|
819 |
"/ give it a chance to really terminate |
|
820 |
Processor yield. |
|
821 |
readerProcess := nil |
|
822 |
]. |
|
823 |
||
824 |
"/ flush any leftover input-processing events |
|
825 |
(sensor := self sensor) notNil ifTrue:[ |
|
826 |
sensor flushEventsFor:self withType:#processInput:n:. |
|
827 |
] |
|
828 |
"Modified: / 21.7.1998 / 19:00:13 / cg" |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
829 |
! ! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
830 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
831 |
!TerminalView methodsFor:'initialization-shell'! |
914 | 832 |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
833 |
startCommand:aCommand |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
834 |
"start a command on a pseudo terminal. If the command arg is nil, |
992 | 835 |
a shell is started. The command is started in the current directory. |
836 |
Also fork a reader process, to read the shells output and |
|
837 |
tell me, whenever something arrives" |
|
838 |
||
839 |
^ self startCommand:aCommand in:nil |
|
840 |
||
841 |
"Modified: / 20.7.1998 / 18:30:24 / cg" |
|
842 |
! |
|
843 |
||
844 |
startCommand:aCommand in:aDirectory |
|
845 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
846 |
a shell is started. If aDirectory is not nil, the command is |
|
847 |
executed in that directory. |
|
934 | 848 |
Also fork a reader process, to read the shells output and |
948 | 849 |
tell me, whenever something arrives" |
934 | 850 |
|
914 | 851 |
|p slaveFD execFdArray blocked exitStatus| |
852 |
||
958
84710fbdfb28
create my view before starting a shell (to pass down windowID).
Claus Gittinger <cg@exept.de>
parents:
957
diff
changeset
|
853 |
self create. "/ need my windowID (to pass down in environment) |
84710fbdfb28
create my view before starting a shell (to pass down windowID).
Claus Gittinger <cg@exept.de>
parents:
957
diff
changeset
|
854 |
|
914 | 855 |
p := ExternalStream makePTYPair. |
856 |
p isNil ifTrue:[ |
|
915 | 857 |
self warn:'cannot open pty'. |
914 | 858 |
^ self. |
859 |
]. |
|
860 |
||
861 |
"/ p at:1 is the master; |
|
862 |
"/ p at:2 is the slave |
|
863 |
inStream := outStream := (p at:1). |
|
864 |
inStream buffered:false. |
|
865 |
||
943 | 866 |
self defineWindowSize. |
867 |
||
914 | 868 |
"/ fork a shell process on the slave-side |
869 |
slaveFD := (p at:2) fileDescriptor. |
|
870 |
||
871 |
execFdArray := Array with:slaveFD with:slaveFD with:slaveFD. |
|
872 |
||
873 |
blocked := OperatingSystem blockInterrupts. |
|
874 |
||
875 |
shellPid := Processor |
|
876 |
monitor:[ |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
877 |
|e shell cmd args| |
929 | 878 |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
879 |
e := Dictionary new. |
957
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
880 |
e at:'TERM' put:(self terminalType). |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
881 |
e at:'LINES' put:(numberOfLines printString). |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
882 |
e at:'COLUMNS' put:(numberOfColumns printString). |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
883 |
drawableId notNil ifTrue:[ |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
884 |
e at:'WINDOWID' put:(drawableId address printString). |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
885 |
]. |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
886 |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
887 |
aCommand isNil ifTrue:[ |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
888 |
shell := OperatingSystem getEnvironment:'SHELL'. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
889 |
shell size == 0 ifTrue:[ |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
890 |
shell := '/bin/sh'. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
891 |
]. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
892 |
cmd := shell asFilename baseName. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
893 |
args := (Array with:cmd). |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
894 |
] ifFalse:[ |
957
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
895 |
shell := '/bin/sh'. |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
896 |
args := (Array with:'sh' with:'-c' with:aCommand). |
957
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
897 |
]. |
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
898 |
e at:'SHELL' put:shell. |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
899 |
|
914 | 900 |
OperatingSystem |
957
8c167c9ea5c0
also pass WINDOWID (if known) and SHELL in environment.
Claus Gittinger <cg@exept.de>
parents:
955
diff
changeset
|
901 |
exec:shell |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
902 |
withArguments:args |
929 | 903 |
environment:e |
914 | 904 |
fileDescriptors:execFdArray |
905 |
closeDescriptors:#() |
|
906 |
fork:true |
|
992 | 907 |
newPgrp:true |
908 |
inDirectory:aDirectory. |
|
914 | 909 |
] |
910 |
action:[:status | |
|
935 | 911 |
"/ Transcript show:'pid:'; showCR:status pid. |
912 |
"/ Transcript show:'status:'; showCR:status status. |
|
913 |
"/ Transcript show:'code:'; showCR:status code. |
|
914 |
"/ Transcript show:'core:'; showCR:status core. |
|
914 | 915 |
status stillAlive ifFalse:[ |
916 |
exitStatus := status. |
|
917 |
OperatingSystem closePid:shellPid. |
|
918 |
shellPid := nil. |
|
919 |
self pushEvent:#shellTerminated |
|
920 |
]. |
|
921 |
]. |
|
922 |
||
923 |
shellPid isNil ifTrue:[ |
|
1161 | 924 |
self warn:'Cannot start shell'. |
914 | 925 |
(p at:1) close. |
926 |
(p at:2) close. |
|
927 |
]. |
|
928 |
||
929 |
blocked ifFalse:[ |
|
930 |
OperatingSystem unblockInterrupts |
|
931 |
]. |
|
932 |
||
933 |
self startReaderProcess. |
|
934 |
||
992 | 935 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
936 |
"Modified: / 20.7.1998 / 18:30:12 / cg" |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
937 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
938 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
939 |
startShell |
992 | 940 |
"start a shell on a pseudo terminal in the current directory. |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
941 |
Also fork a reader process, to read the shells output and |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
942 |
tell me, whenever something arrives" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
943 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
944 |
^ self startCommand:nil |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
945 |
|
914 | 946 |
" |
934 | 947 |
VT100TerminalView openShell |
914 | 948 |
" |
929 | 949 |
|
992 | 950 |
"Modified: / 20.7.1998 / 18:29:54 / cg" |
951 |
! |
|
952 |
||
953 |
startShellIn:aDirectory |
|
954 |
"start a shell on a pseudo terminal in some directory. |
|
955 |
Also fork a reader process, to read the shells output and |
|
956 |
tell me, whenever something arrives" |
|
957 |
||
958 |
^ self startCommand:nil in:aDirectory |
|
959 |
||
960 |
" |
|
961 |
VT100TerminalView openShellIn:'/etc' |
|
962 |
" |
|
963 |
||
964 |
"Modified: / 20.7.1998 / 18:29:46 / cg" |
|
914 | 965 |
! ! |
966 |
||
967 |
!TerminalView methodsFor:'menu'! |
|
968 |
||
969 |
editMenu |
|
970 |
"return the views middleButtonMenu" |
|
971 |
||
972 |
<resource: #keyboard (#Copy #Paste #Print)> |
|
973 |
<resource: #programMenu> |
|
974 |
||
975 |
|items m sub shortKeys sensor| |
|
976 |
||
977 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
|
978 |
items := #( |
|
979 |
('Interrupt' doSendInterrupt) |
|
980 |
). |
|
981 |
] ifFalse:[ |
|
982 |
items := #( |
|
983 |
('copy' copySelection Copy ) |
|
984 |
('paste' pasteOrReplace Paste ) |
|
985 |
('-' ) |
|
951 | 986 |
('font ...' changeFont ) |
987 |
('-' ) |
|
914 | 988 |
('save as ...' save SaveAs ) |
989 |
('print' doPrint Print ) |
|
990 |
). |
|
991 |
]. |
|
992 |
||
993 |
m := PopUpMenu itemList:items resources:resources. |
|
994 |
||
995 |
self hasSelection not ifTrue:[ |
|
996 |
m disable:#copySelection. |
|
997 |
]. |
|
998 |
^ m. |
|
999 |
||
951 | 1000 |
"Modified: / 12.6.1998 / 22:33:33 / cg" |
914 | 1001 |
! ! |
1002 |
||
940 | 1003 |
!TerminalView methodsFor:'misc'! |
914 | 1004 |
|
1005 |
removeTrailingBlankLines |
|
1006 |
^ self |
|
1007 |
! ! |
|
1008 |
||
1009 |
!TerminalView methodsFor:'processing - input'! |
|
1010 |
||
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1011 |
nextPutAll:aString |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1012 |
"/ self processInput:aString n:aString size |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1013 |
self pushEvent:#processInput:n: with:aString with:aString size. |
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1014 |
|
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1015 |
"Created: / 27.7.1998 / 15:10:59 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1016 |
"Modified: / 27.7.1998 / 23:16:19 / cg" |
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1017 |
! |
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1018 |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1019 |
processInput:buffer n:count |
997 | 1020 |
|sensor| |
1021 |
||
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
1022 |
"/ self hideCursor. |
997 | 1023 |
|
1015 | 1024 |
"/ the following may not be too clean, but adds a lot of speed. |
1025 |
"/ instead of passing every individual character through the |
|
1026 |
"/ escape-state machine, collect chunks of non-control text |
|
1027 |
"/ when in state 0, and add them immediately to the pendingLines |
|
1028 |
"/ collection of the textCollectors asynchronous update mechanism. |
|
1029 |
"/ This helps a lot if you do something like "ls -lR /" ... |
|
1030 |
"/ For debugging the state machine, reenable the commented lines |
|
1031 |
"/ below. |
|
1032 |
||
1033 |
"/1 to:count do:[:i| |
|
1034 |
"/ self nextPut:(buffer at:i). |
|
1035 |
"/]. |
|
1036 |
"/self showCursor. |
|
1037 |
"/^ self. |
|
1038 |
||
1039 |
access critical:[ |
|
1040 |
|i i2 s crnlFollows| |
|
997 | 1041 |
|
1015 | 1042 |
i := 1. |
1043 |
[i <= count] whileTrue:[ |
|
1044 |
(state == 0) ifTrue:[ |
|
1045 |
"/ in initial state. |
|
1046 |
"/ quick scan forward for next control character ... |
|
1047 |
i2 := buffer indexOfControlCharacterStartingAt:i. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1048 |
i2 > count ifTrue:[i2 := 0]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1049 |
|
1015 | 1050 |
i2 == 0 ifTrue:[ |
1051 |
"/ no control characters - simply append all |
|
1052 |
"/ to the outstanding lines ... |
|
1053 |
s := buffer copyFrom:i to:count. |
|
1054 |
i := count + 1. "/ leave loop. |
|
997 | 1055 |
crnlFollows := false. |
1015 | 1056 |
] ifFalse:[ |
1057 |
i2 > i ifTrue:[ |
|
1058 |
s := buffer copyFrom:i to:i2-1. |
|
1059 |
i := i2. "/ proceed withcontrol character |
|
1060 |
crnlFollows := false. |
|
1061 |
i < (count - 1) ifTrue:[ |
|
1062 |
(buffer at:i) == Character return ifTrue:[ |
|
1063 |
(buffer at:i+1) == Character nl ifTrue:[ |
|
1064 |
crnlFollows := true. |
|
1065 |
i := i + 2. |
|
1066 |
] |
|
997 | 1067 |
] |
1015 | 1068 |
]. |
1069 |
] |
|
1070 |
]. |
|
997 | 1071 |
]. |
1072 |
||
1015 | 1073 |
s notNil ifTrue:[ |
1074 |
currentEmphasis notNil ifTrue:[ |
|
1075 |
s := s emphasizeAllWith:currentEmphasis |
|
1076 |
]. |
|
1077 |
||
1078 |
outstandingLine size > 0 ifTrue:[ |
|
1079 |
outstandingLine := outstandingLine , s. |
|
997 | 1080 |
] ifFalse:[ |
1015 | 1081 |
outstandingLine := s. |
997 | 1082 |
]. |
1015 | 1083 |
crnlFollows ifTrue:[ |
1084 |
outstandingLines isNil ifTrue:[ |
|
1085 |
outstandingLines := OrderedCollection with:outstandingLine |
|
1086 |
] ifFalse:[ |
|
1087 |
outstandingLines add:outstandingLine. |
|
1088 |
]. |
|
1089 |
outstandingLine := ''. |
|
1090 |
]. |
|
1091 |
s := nil. |
|
997 | 1092 |
|
1015 | 1093 |
collecting ifTrue:[ |
1094 |
flushPending ifFalse:[ |
|
1095 |
self installDelayedUpdate |
|
1096 |
] ifTrue:[ |
|
1097 |
"/ outstandingLines size > collectSize ifTrue:[ |
|
1098 |
"/ self endEntry |
|
1099 |
"/ ] |
|
1100 |
] |
|
1101 |
] ifFalse:[ |
|
1102 |
self endEntry |
|
1103 |
]. |
|
997 | 1104 |
] ifFalse:[ |
1015 | 1105 |
"/ no chunk to append (in an escape sequence) |
1106 |
"/ must handle individual characters |
|
1107 |
"/ to update the state machine. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1108 |
|
1015 | 1109 |
self nextPut:(buffer at:i). |
1110 |
i := i + 1. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1111 |
[state ~~ 0 and:[i <= count]] whileTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1112 |
self nextPut:(buffer at:i). |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1113 |
i := i + 1. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1114 |
] |
1015 | 1115 |
] |
1116 |
]. |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1117 |
]. |
948 | 1118 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1119 |
state == 0 ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1120 |
(sensor := self sensor) notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1121 |
"/ if there is no more output pending from the shell, |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1122 |
"/ enforce update of the view (asynchronous) |
997 | 1123 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1124 |
(sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
997 | 1125 |
self endEntry. |
1126 |
self showCursor. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1127 |
"/ self makeCursorVisible. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1128 |
] ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1129 |
"/ if there is more output pending from the shell, |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1130 |
"/ and many lines have already been collected, |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1131 |
"/ also enforce update of the view (asynchronous) |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1132 |
"/ Thus, it will update at least once for every |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1133 |
"/ collectSize lines. |
1015 | 1134 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1135 |
outstandingLines size > collectSize ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1136 |
self endEntry. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1137 |
self showCursor. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1138 |
|
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1139 |
"/ make certain that things are really displayed ... |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1140 |
windowGroup notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1141 |
windowGroup processRealExposeEventsFor:self. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1142 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1143 |
]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1144 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1145 |
]. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1146 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1147 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1148 |
"Created: / 10.6.1998 / 17:26:09 / cg" |
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
1149 |
"Modified: / 14.8.1998 / 13:43:35 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1150 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1151 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1152 |
sync |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1153 |
self waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1154 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1155 |
"Created: / 27.7.1998 / 23:49:44 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1156 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1157 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1158 |
waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1159 |
|sensor| |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1160 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1161 |
sensor := self sensor. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1162 |
(sensor userEventCount > 50) ifTrue:[ |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1163 |
[sensor userEventCount > 10] whileTrue:[ |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1164 |
"/ give terminalView a chance to |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1165 |
"/ catch up. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1166 |
Delay waitForSeconds:0.1. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1167 |
] |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1168 |
]. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1169 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1170 |
"Modified: / 27.7.1998 / 23:16:19 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1171 |
"Created: / 27.7.1998 / 23:47:22 / cg" |
914 | 1172 |
! ! |
1173 |
||
1174 |
!TerminalView methodsFor:'queries'! |
|
1175 |
||
1176 |
preferredExtent |
|
951 | 1177 |
^ (fontWidth * numberOfColumns + (leftMargin * 2)) |
1178 |
@ |
|
979 | 1179 |
((self heightForLines:numberOfLines) + 8) |
926 | 1180 |
|
979 | 1181 |
"Modified: / 20.6.1998 / 20:06:57 / cg" |
929 | 1182 |
! |
1183 |
||
1184 |
terminalType |
|
1185 |
^ #dump |
|
1186 |
||
1187 |
"Modified: / 10.6.1998 / 14:47:03 / cg" |
|
1188 |
"Created: / 10.6.1998 / 16:22:30 / cg" |
|
914 | 1189 |
! ! |
1190 |
||
1191 |
!TerminalView methodsFor:'selection handling'! |
|
1192 |
||
1193 |
paste:someText |
|
1194 |
"paste - redefined to send the chars to the shell instead |
|
1195 |
of pasting into the view" |
|
1196 |
||
950 | 1197 |
|s nLines| |
1198 |
||
1199 |
s := someText. |
|
1200 |
s isString ifTrue:[ |
|
1201 |
s := s asStringCollection |
|
1202 |
] ifFalse:[ |
|
1203 |
(s isKindOf:StringCollection) ifFalse:[ |
|
1204 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
1205 |
^ self |
|
1206 |
] |
|
1207 |
]. |
|
1208 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
1209 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
|
1210 |
s keysAndValuesDo:[:idx :line | |
|
1211 |
inStream nextPutAll:line. |
|
1212 |
idx ~~ nLines ifTrue:[ |
|
1213 |
inStream nextPut:(Character return). |
|
1214 |
] |
|
1215 |
]. |
|
1216 |
||
1217 |
"Modified: / 12.6.1998 / 22:12:47 / cg" |
|
914 | 1218 |
! ! |
1219 |
||
1220 |
!TerminalView class methodsFor:'documentation'! |
|
1221 |
||
1222 |
version |
|
1161 | 1223 |
^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.59 1998-10-02 16:52:09 cg Exp $' |
914 | 1224 |
! ! |