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