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