author | Claus Gittinger <cg@exept.de> |
Wed, 05 May 1999 16:50:01 +0200 | |
changeset 1359 | c571a792c5b0 |
parent 1358 | ec94a03e4585 |
child 1360 | fb843effdaea |
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 |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
307 |
numberOfTerminalColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
308 |
^ numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
309 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
310 |
"Created: / 5.5.1999 / 11:46:25 / cg" |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
311 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
312 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
313 |
numberOfTerminalLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
314 |
"/ be careful - this is NOT called numberOfLines, |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
315 |
"/ since that would interfere with numberOfLines as defined |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
316 |
"/ in ListView ... |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
317 |
"/ ... one of the bad sides of subclassing |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
318 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
319 |
^ numberOfLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
320 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
321 |
"Created: / 5.5.1999 / 11:46:18 / cg" |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
322 |
"Modified: / 5.5.1999 / 11:47:24 / cg" |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
323 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
324 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
325 |
restoreCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
326 |
|l c| |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
327 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
328 |
l := savedCursor y. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
329 |
c := savedCursor x. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
330 |
self cursorLine:l col:c. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
331 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
332 |
"Created: / 14.8.1998 / 13:49:24 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
333 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
334 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
335 |
saveCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
336 |
savedCursor := cursorCol @ cursorLine |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
337 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
338 |
"Created: / 14.8.1998 / 13:48:45 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
339 |
"Modified: / 14.8.1998 / 13:49:32 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
340 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
341 |
|
914 | 342 |
validateCursorCol:col inLine:line |
343 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
344 |
Here, the linelength is enforced" |
|
345 |
||
926 | 346 |
^ col min:numberOfColumns |
914 | 347 |
|
926 | 348 |
"Modified: / 10.6.1998 / 15:09:41 / cg" |
914 | 349 |
! ! |
350 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
351 |
!TerminalView methodsFor:'defaults'! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
352 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
353 |
anyKeyCodes |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
354 |
^ IdentityDictionary withKeysAndValues: |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
355 |
#( |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
356 |
#Escape '\e' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
357 |
#BackSpace '\b' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
358 |
#Return '\r' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
359 |
#Delete '\0177' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
360 |
#Tab '\t' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
361 |
) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
362 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
363 |
"Created: / 5.5.1999 / 15:00:37 / cg" |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
364 |
! ! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
365 |
|
914 | 366 |
!TerminalView methodsFor:'event handling'! |
367 |
||
951 | 368 |
computeNumberOfLinesShown |
369 |
|prevNLines prevNCols| |
|
370 |
||
371 |
prevNCols := (innerWidth // font width). |
|
372 |
prevNLines := nFullLinesShown. |
|
373 |
||
374 |
super computeNumberOfLinesShown. |
|
375 |
||
376 |
((innerWidth // font width) ~~ prevNCols |
|
377 |
or:[prevNLines ~~ nFullLinesShown]) ifTrue:[ |
|
378 |
self defineWindowSize. |
|
379 |
] |
|
380 |
||
381 |
"Created: / 12.6.1998 / 22:34:39 / cg" |
|
979 | 382 |
"Modified: / 20.6.1998 / 19:45:28 / cg" |
951 | 383 |
! |
384 |
||
1359 | 385 |
contentsChanged |
386 |
super contentsChanged. |
|
387 |
self defineWindowSize. |
|
388 |
||
389 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
|
390 |
"Created: / 5.5.1999 / 16:30:15 / cg" |
|
391 |
! |
|
392 |
||
943 | 393 |
defineWindowSize |
1359 | 394 |
|fd delta prevNumCols prevNumLines| |
395 |
||
396 |
prevNumCols := numberOfColumns. |
|
397 |
prevNumLines := numberOfLines. |
|
1161 | 398 |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
399 |
numberOfColumns := (innerWidth // font width). |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
400 |
delta := numberOfLines - rangeEndLine. |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
401 |
numberOfLines := nFullLinesShown. |
1359 | 402 |
|
403 |
((prevNumCols == numberOfColumns) |
|
404 |
and:[prevNumLines == numberOfLines]) ifTrue:[ |
|
405 |
^ self |
|
406 |
]. |
|
407 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
408 |
rangeEndLine notNil ifTrue:[ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
409 |
rangeEndLine := numberOfLines - delta. |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
410 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
411 |
|
1359 | 412 |
"/ any idea, how to do this under windows ? |
413 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
414 |
OperatingSystem isUNIXlike ifTrue:[ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
415 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
416 |
"/ tell the pty; |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
417 |
"/ tell the shell; |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
418 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
419 |
(inStream notNil |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
420 |
and:[inStream isExternalStream |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
421 |
and:[inStream isOpen]]) ifTrue:[ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
422 |
"/ Transcript showCR:'VT100: changed len to ', numberOfLines printString. |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
423 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
424 |
(OperatingSystem |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
425 |
setWindowSizeOnFileDescriptor:inStream fileDescriptor |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
426 |
width:numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
427 |
height:numberOfLines) ifFalse:[ |
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
428 |
"/ Transcript showCR:'VT100: cannot change windowSize'. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
429 |
]. |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
430 |
|
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
431 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
432 |
shellPid notNil ifTrue:[ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
433 |
OperatingSystem sendSignal:OperatingSystem sigWINCH to:shellPid |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
434 |
] |
943 | 435 |
]. |
436 |
||
437 |
"Created: / 11.6.1998 / 22:51:39 / cg" |
|
1359 | 438 |
"Modified: / 5.5.1999 / 16:32:22 / cg" |
943 | 439 |
! |
440 |
||
914 | 441 |
keyPress:aKey x:x y:y |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
442 |
|rest event rawKey seq| |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
443 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
444 |
"/ somewhat complicated, since some characters |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
445 |
"/ should go untranslated (CTRL-key), |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
446 |
"/ even if defined as function keys. |
914 | 447 |
|
448 |
inStream isNil ifTrue:[^ self]. |
|
449 |
||
931 | 450 |
"/ Transcript showCR:'----'; show:'key:' ; showCR:aKey printString. |
914 | 451 |
|
452 |
aKey isCharacter ifTrue:[ |
|
453 |
"/ send it down to inStream ... |
|
454 |
inStream nextPut:aKey. |
|
455 |
^ self |
|
456 |
]. |
|
457 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
458 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
459 |
"/ common translations (Tab, Backspace, F-keys etc.) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
460 |
"/ |
914 | 461 |
seq := kbdSequences at:aKey ifAbsent:nil. |
462 |
seq notNil ifTrue:[ |
|
931 | 463 |
"/ Transcript show:'->' ; showCR:seq storeString. |
914 | 464 |
inStream nextPutAll:(seq withEscapes). |
465 |
^ self |
|
466 |
]. |
|
467 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
468 |
self sensor ctrlDown ifTrue:[ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
469 |
event := WindowGroup lastEventQuerySignal query. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
470 |
rawKey := 'Ctrl' , event rawKey. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
471 |
] ifFalse:[ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
472 |
rawKey := self keyboardMap keyAtValue:aKey ifAbsent:aKey. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
473 |
]. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
474 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
475 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
476 |
"/ care for function-keys, which are mapped to Ctrl-x; |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
477 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
478 |
"/ Transcript show:'raw ->' ; showCR:rawKey storeString. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
479 |
|
914 | 480 |
seq := kbdSequences at:rawKey ifAbsent:nil. |
481 |
seq notNil ifTrue:[ |
|
931 | 482 |
"/ Transcript show:'->' ; showCR:seq storeString. |
914 | 483 |
inStream nextPutAll:(seq withEscapes). |
484 |
^ self |
|
485 |
]. |
|
486 |
||
487 |
(rawKey startsWith:'Ctrl') ifTrue:[ |
|
488 |
rest := rawKey copyFrom:5. |
|
489 |
rest size == 1 ifTrue:[ |
|
490 |
rest := rest at:1. |
|
491 |
(rest >= $a and:[rest <= $z]) ifTrue:[ |
|
931 | 492 |
"/ Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
914 | 493 |
inStream nextPut:(Character value:(rest - $a + 1)). |
494 |
^ self |
|
495 |
]. |
|
496 |
(rest >= $A and:[rest <= $Z]) ifTrue:[ |
|
931 | 497 |
"/ Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
914 | 498 |
inStream nextPut:(Character value:(rest - $A + 1)). |
499 |
^ self |
|
500 |
]. |
|
501 |
] |
|
502 |
]. |
|
503 |
||
934 | 504 |
(rawKey startsWith:'Control') ifTrue:[ |
505 |
^ self |
|
506 |
]. |
|
507 |
(rawKey startsWith:'Shift') ifTrue:[ |
|
508 |
^ self |
|
509 |
]. |
|
510 |
(rawKey startsWith:'Alt') ifTrue:[ |
|
511 |
^ self |
|
512 |
]. |
|
513 |
(rawKey startsWith:'Cmd') ifTrue:[ |
|
950 | 514 |
^ super keyPress:aKey x:x y:y |
934 | 515 |
]. |
1345 | 516 |
(rawKey = 'Ctrl') ifTrue:[ |
517 |
^ self |
|
518 |
]. |
|
934 | 519 |
|
520 |
Transcript show:'unhandled: '; showCR:rawKey. |
|
914 | 521 |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
522 |
"Modified: / 5.5.1999 / 16:21:06 / cg" |
914 | 523 |
! |
524 |
||
525 |
shellTerminated |
|
526 |
self closeDownShell. |
|
946 | 527 |
shellTerminateAction notNil ifTrue:[ |
528 |
shellTerminateAction value |
|
529 |
] ifFalse:[ |
|
530 |
"/ may be removed ... |
|
531 |
self warn:'shell terminated'. |
|
532 |
] |
|
533 |
||
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
534 |
"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
|
535 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
536 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
537 |
sizeChanged:how |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
538 |
super sizeChanged:how. |
943 | 539 |
self defineWindowSize. |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
540 |
|
943 | 541 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
914 | 542 |
! ! |
543 |
||
544 |
!TerminalView methodsFor:'functions'! |
|
545 |
||
546 |
doBackspace |
|
547 |
self cursorLeft. |
|
548 |
self replaceCharAtCursor:(Character space). |
|
549 |
self cursorLeft. |
|
550 |
||
931 | 551 |
"Modified: / 10.6.1998 / 17:09:12 / cg" |
914 | 552 |
! |
553 |
||
926 | 554 |
doClearDisplay |
1000 | 555 |
self doClearEntireScreen. |
556 |
||
557 |
"Modified: / 21.7.1998 / 20:05:35 / cg" |
|
558 |
! |
|
559 |
||
560 |
doClearEntireScreen |
|
926 | 561 |
firstLineShown to:(list size) do:[:l | |
562 |
self at:l put:'' |
|
563 |
]. |
|
922 | 564 |
|
1000 | 565 |
"Modified: / 21.7.1998 / 20:00:19 / cg" |
566 |
"Created: / 21.7.1998 / 20:05:24 / cg" |
|
926 | 567 |
! |
568 |
||
1000 | 569 |
doClearFromBeginningOfLine |
570 |
|l| |
|
571 |
||
572 |
l := self listAt:cursorLine. |
|
573 |
l notNil ifTrue:[ |
|
574 |
(l size >= (cursorCol-1)) ifTrue:[ |
|
575 |
l := l copy from:1 to:cursorCol-1 put:(Character space). |
|
576 |
] ifFalse:[ |
|
577 |
l := nil. |
|
578 |
]. |
|
579 |
self withoutRedrawAt:cursorLine put:l. |
|
580 |
self invalidateLine:cursorLine |
|
581 |
"/ self at:cursorLine put:l. |
|
582 |
] |
|
583 |
||
584 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
|
585 |
"Created: / 21.7.1998 / 20:10:58 / cg" |
|
586 |
! |
|
587 |
||
588 |
doClearFromBeginningOfScreen |
|
589 |
self doClearFromBeginningOfLine. |
|
590 |
cursorLine-1 to:firstLineShown do:[:l | |
|
922 | 591 |
self at:l put:'' |
592 |
]. |
|
593 |
||
926 | 594 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
1000 | 595 |
"Created: / 21.7.1998 / 20:08:29 / cg" |
926 | 596 |
! |
597 |
||
598 |
doClearToEndOfLine |
|
599 |
|l| |
|
600 |
||
601 |
l := self listAt:cursorLine. |
|
931 | 602 |
(l size >= (cursorCol-1)) ifTrue:[ |
951 | 603 |
l notNil ifTrue:[ |
604 |
l := l copyTo:cursorCol-1. |
|
979 | 605 |
self withoutRedrawAt:cursorLine put:l. |
606 |
self invalidateLine:cursorLine |
|
607 |
"/ self at:cursorLine put:l. |
|
951 | 608 |
] |
926 | 609 |
] |
610 |
||
611 |
"Created: / 10.6.1998 / 14:45:01 / cg" |
|
979 | 612 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
914 | 613 |
! |
614 |
||
1000 | 615 |
doClearToEndOfScreen |
616 |
self doClearToEndOfLine. |
|
617 |
cursorLine+1 to:(list size) do:[:l | |
|
618 |
self at:l put:'' |
|
619 |
]. |
|
620 |
||
621 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
|
622 |
"Created: / 21.7.1998 / 20:06:14 / cg" |
|
623 |
! |
|
624 |
||
926 | 625 |
doCursorDown:n |
979 | 626 |
|wasOn rEnd| |
926 | 627 |
|
979 | 628 |
"/ rangeEndLine == numberOfLines ifTrue:[ |
629 |
"/ ^ super cursorDown:n |
|
630 |
"/ ]. |
|
631 |
cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[ |
|
951 | 632 |
"/ no special action req'd |
633 |
^ super cursorDown:n |
|
634 |
]. |
|
979 | 635 |
|
951 | 636 |
n timesRepeat:[ |
637 |
wasOn := self hideCursor. |
|
979 | 638 |
rEnd := rangeEndLine+firstLineShown-1. |
639 |
cursorLine == rEnd ifTrue:[ |
|
640 |
self deleteLine:(rangeStartLine+firstLineShown-1). |
|
641 |
self insertLine:'' before:rEnd. |
|
951 | 642 |
] ifFalse:[ |
643 |
super cursorDown |
|
644 |
]. |
|
979 | 645 |
wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn. |
951 | 646 |
] |
647 |
||
979 | 648 |
"Modified: / 20.6.1998 / 20:29:39 / cg" |
926 | 649 |
! |
650 |
||
914 | 651 |
doCursorHome |
938 | 652 |
self cursorVisibleLine:1 col:1 |
653 |
"/ super cursorHome |
|
654 |
||
655 |
"Modified: / 10.6.1998 / 20:47:31 / cg" |
|
914 | 656 |
! |
657 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
658 |
doCursorLeft:n |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
659 |
n timesRepeat:[ |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
660 |
super cursorLeft |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
661 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
662 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
663 |
"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
|
664 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
665 |
|
914 | 666 |
doCursorNewLine |
931 | 667 |
super cursorDown:1 |
668 |
||
669 |
"Modified: / 10.6.1998 / 16:55:57 / cg" |
|
914 | 670 |
! |
671 |
||
672 |
doCursorReturn |
|
673 |
super cursorToBeginOfLine |
|
674 |
! |
|
675 |
||
926 | 676 |
doCursorRight:n |
677 |
self cursorCol:(cursorCol + n) |
|
678 |
||
679 |
"Created: / 10.6.1998 / 15:10:08 / cg" |
|
680 |
! |
|
681 |
||
951 | 682 |
doCursorUp:n |
979 | 683 |
|wasOn rStart| |
926 | 684 |
|
979 | 685 |
"/ rangeStartLine == 1 ifTrue:[ |
686 |
"/ ^ super cursorUp:n |
|
687 |
"/ ]. |
|
688 |
cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[ |
|
951 | 689 |
"/ no special action req'd |
690 |
^ super cursorUp:n |
|
691 |
]. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
692 |
n timesRepeat:[ |
951 | 693 |
wasOn := self hideCursor. |
979 | 694 |
rStart := rangeStartLine+firstLineShown-1. |
695 |
cursorLine == rStart ifTrue:[ |
|
696 |
(rangeEndLine+firstLineShown-1) <= list size ifTrue:[ |
|
697 |
self deleteLine:(rangeEndLine+firstLineShown-1). |
|
698 |
self insertLine:'' before:rStart. |
|
699 |
]. |
|
951 | 700 |
] ifFalse:[ |
701 |
super cursorUp |
|
702 |
]. |
|
703 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
704 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
705 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
706 |
"Created: / 11.6.1998 / 22:29:46 / cg" |
979 | 707 |
"Modified: / 20.6.1998 / 20:30:34 / cg" |
914 | 708 |
! ! |
709 |
||
1329 | 710 |
!TerminalView methodsFor:'initialization-shell'! |
711 |
||
712 |
startCommand:aCommand |
|
713 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
714 |
a shell is started. The command is started in the current directory. |
|
715 |
Also fork a reader process, to read the shells output and |
|
716 |
tell me, whenever something arrives" |
|
717 |
||
718 |
^ self startCommand:aCommand in:nil |
|
719 |
||
720 |
"Modified: / 20.7.1998 / 18:30:24 / cg" |
|
721 |
! |
|
722 |
||
723 |
startCommand:aCommand in:aDirectory |
|
724 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
725 |
a shell is started. If aDirectory is not nil, the command is |
|
726 |
executed in that directory. |
|
727 |
Also fork a reader process, to read the shells output and |
|
728 |
tell me, whenever something arrives" |
|
729 |
||
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
730 |
|p slaveFD execFdArray closeFdArray blocked exitStatus |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
731 |
stxToCommandPipe commandToStxPipe cmd shell args env wDir shellAndArgs| |
1329 | 732 |
|
733 |
shellCommand := aCommand. |
|
734 |
shellDirectory := aDirectory. |
|
735 |
||
736 |
self create. "/ need my windowID (to pass down in environment) |
|
737 |
||
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
738 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
739 |
"/ must use another mechanism |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
740 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
741 |
stxToCommandPipe := OperatingSystem makePipe. |
1343 | 742 |
(stxToCommandPipe isNil |
743 |
or:[(stxToCommandPipe at:2) < 0 |
|
744 |
or:[(stxToCommandPipe at:2) < 0]]) ifTrue:[ |
|
745 |
^ 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
|
746 |
]. |
1343 | 747 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
748 |
commandToStxPipe := OperatingSystem makePipe. |
1343 | 749 |
(commandToStxPipe isNil |
750 |
or:[(commandToStxPipe at:2) < 0 |
|
751 |
or:[(commandToStxPipe at:2) < 0]]) ifTrue:[ |
|
752 |
^ 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
|
753 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
754 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
755 |
shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
756 |
shell := shellAndArgs at:1. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
757 |
args := (shellAndArgs at:2) ? ''. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
758 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
759 |
"/ pipe readSide is p at:1; |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
760 |
"/ writeSide is p at:2 |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
761 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
762 |
execFdArray := Array |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
763 |
with:(stxToCommandPipe at:1) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
764 |
with:(commandToStxPipe at:2) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
765 |
with:(commandToStxPipe at:2). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
766 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
767 |
closeFdArray := #(). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
768 |
"/ Array |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
769 |
"/ with:(stxToCommandPipe at:2) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
770 |
"/ with:(commandToStxPipe at:1). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
771 |
|
1329 | 772 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
773 |
outStream := ExternalStream forReadingFromFileDescriptor:(commandToStxPipe at:1). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
774 |
inStream := ExternalStream forWritingToFileDescriptor:(stxToCommandPipe at:2). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
775 |
outStream buffered:false. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
776 |
inStream buffered:false. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
777 |
] ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
778 |
p := ExternalStream makePTYPair. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
779 |
p isNil ifTrue:[ |
1343 | 780 |
self warn:'Cannot open pty.'. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
781 |
^ self. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
782 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
783 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
784 |
"/ p at:1 is the master; |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
785 |
"/ p at:2 is the slave |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
786 |
inStream := outStream := (p at:1). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
787 |
inStream buffered:false. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
788 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
789 |
self defineWindowSize. |
1329 | 790 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
791 |
"/ fork a shell process on the slave-side |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
792 |
slaveFD := (p at:2) fileDescriptor. |
1329 | 793 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
794 |
execFdArray := Array with:slaveFD with:slaveFD with:slaveFD. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
795 |
closeFdArray := #(). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
796 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
797 |
aCommand isNil ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
798 |
shell := OperatingSystem getEnvironment:'SHELL'. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
799 |
shell size == 0 ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
800 |
shell := '/bin/sh'. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
801 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
802 |
cmd := shell asFilename baseName. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
803 |
args := (Array with:cmd). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
804 |
] ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
805 |
shell := '/bin/sh'. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
806 |
args := (Array with:'sh' with:'-c' with:aCommand). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
807 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
808 |
]. |
1329 | 809 |
|
810 |
blocked := OperatingSystem blockInterrupts. |
|
811 |
||
812 |
shellPid := Processor |
|
813 |
monitor:[ |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
814 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
815 |
OperatingSystem |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
816 |
exec:shell |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
817 |
withArguments:args |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
818 |
fileDescriptors:execFdArray |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
819 |
closeDescriptors:closeFdArray |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
820 |
fork:true |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
821 |
newPgrp:true |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
822 |
inDirectory:aDirectory. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
823 |
] ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
824 |
env := Dictionary new. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
825 |
env at:'TERM' put:(self terminalType). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
826 |
env at:'LINES' put:(numberOfLines printString). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
827 |
env at:'COLUMNS' put:(numberOfColumns printString). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
828 |
drawableId notNil ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
829 |
env at:'WINDOWID' put:(drawableId address printString). |
1329 | 830 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
831 |
env at:'SHELL' put:shell. |
1329 | 832 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
833 |
OperatingSystem |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
834 |
exec:shell |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
835 |
withArguments:args |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
836 |
environment:env |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
837 |
fileDescriptors:execFdArray |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
838 |
closeDescriptors:closeFdArray |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
839 |
fork:true |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
840 |
newPgrp:true |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
841 |
inDirectory:aDirectory. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
842 |
] |
1329 | 843 |
] |
844 |
action:[:status | |
|
845 |
"/ Transcript show:'pid:'; showCR:status pid. |
|
846 |
"/ Transcript show:'status:'; showCR:status status. |
|
847 |
"/ Transcript show:'code:'; showCR:status code. |
|
848 |
"/ Transcript show:'core:'; showCR:status core. |
|
849 |
status stillAlive ifFalse:[ |
|
850 |
exitStatus := status. |
|
851 |
OperatingSystem closePid:shellPid. |
|
852 |
shellPid := nil. |
|
853 |
self pushEvent:#shellTerminated |
|
854 |
]. |
|
855 |
]. |
|
856 |
||
857 |
shellPid isNil ifTrue:[ |
|
858 |
self warn:'Cannot start shell'. |
|
859 |
(p at:1) close. |
|
860 |
(p at:2) close. |
|
861 |
]. |
|
862 |
||
863 |
blocked ifFalse:[ |
|
864 |
OperatingSystem unblockInterrupts |
|
865 |
]. |
|
866 |
||
867 |
self startReaderProcess. |
|
868 |
||
869 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
|
1343 | 870 |
"Modified: / 28.4.1999 / 11:52:28 / cg" |
1329 | 871 |
! |
872 |
||
873 |
startShell |
|
874 |
"start a shell on a pseudo terminal in the current directory. |
|
875 |
Also fork a reader process, to read the shells output and |
|
876 |
tell me, whenever something arrives" |
|
877 |
||
878 |
^ self startCommand:nil |
|
879 |
||
880 |
" |
|
881 |
VT100TerminalView openShell |
|
882 |
" |
|
883 |
||
884 |
"Modified: / 20.7.1998 / 18:29:54 / cg" |
|
885 |
! |
|
886 |
||
887 |
startShellIn:aDirectory |
|
888 |
"start a shell on a pseudo terminal in some directory. |
|
889 |
Also fork a reader process, to read the shells output and |
|
890 |
tell me, whenever something arrives" |
|
891 |
||
892 |
^ self startCommand:nil in:aDirectory |
|
893 |
||
894 |
" |
|
895 |
VT100TerminalView openShellIn:'/etc' |
|
896 |
" |
|
897 |
||
898 |
"Modified: / 20.7.1998 / 18:29:46 / cg" |
|
899 |
! ! |
|
900 |
||
901 |
!TerminalView methodsFor:'initialize / release'! |
|
914 | 902 |
|
903 |
closeDownShell |
|
1009 | 904 |
|pid| |
926 | 905 |
|
906 |
(pid := shellPid) notNil ifTrue:[ |
|
934 | 907 |
"/ Transcript print:'killing shell pid='; showCR:pid. |
908 |
||
926 | 909 |
OperatingSystem terminateProcessGroup:pid. |
910 |
OperatingSystem terminateProcess:pid. |
|
925 | 911 |
Delay waitForSeconds:1. |
912 |
shellPid notNil ifTrue:[ |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
913 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
914 |
OperatingSystem killProcessGroup:pid. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
915 |
]. |
926 | 916 |
OperatingSystem killProcess:pid. |
925 | 917 |
shellPid := nil. |
918 |
]. |
|
926 | 919 |
OperatingSystem closePid:pid. |
914 | 920 |
]. |
921 |
||
1009 | 922 |
self stopReaderProcess. |
923 |
||
914 | 924 |
inStream notNil ifTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
925 |
inStream isStream ifTrue:[inStream close]. |
914 | 926 |
inStream := nil |
927 |
]. |
|
928 |
outStream notNil ifTrue:[ |
|
929 |
outStream close. |
|
930 |
outStream := nil |
|
931 |
]. |
|
924 | 932 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
933 |
"Modified: / 27.4.1999 / 20:27:11 / cg" |
914 | 934 |
! |
935 |
||
936 |
destroy |
|
937 |
self closeDownShell. |
|
938 |
super destroy |
|
939 |
! |
|
940 |
||
941 |
escapeSequences:codes |
|
942 |
|tree| |
|
943 |
||
944 |
tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new]. |
|
945 |
||
946 |
codes do:[:specEntry | |
|
947 |
|sequence function| |
|
948 |
||
949 |
sequence := (specEntry at:1) withEscapes. |
|
950 |
function := specEntry at:2. |
|
951 |
||
952 |
tree := escapeSequenceTree. |
|
953 |
||
954 |
sequence keysAndValuesDo:[:idx :char | |
|
955 |
|followup| |
|
956 |
||
957 |
idx == sequence size ifTrue:[ |
|
958 |
tree at:char put:function |
|
959 |
] ifFalse:[ |
|
960 |
followup := tree at:char ifAbsent:nil. |
|
961 |
followup isNil ifTrue:[ |
|
962 |
tree at:char put:(followup := IdentityDictionary new). |
|
963 |
]. |
|
964 |
tree := followup |
|
965 |
] |
|
966 |
] |
|
967 |
]. |
|
918 | 968 |
escapeLeadingChars := escapeSequenceTree keys asSet. |
969 |
escapeLeadingChars add:(Character cr). |
|
970 |
escapeLeadingChars add:(Character return). |
|
971 |
escapeLeadingChars add:(Character backspace). |
|
972 |
||
973 |
escapeLeadingChars := escapeLeadingChars asArray |
|
974 |
||
975 |
"Modified: / 9.6.1998 / 19:43:12 / cg" |
|
914 | 976 |
! |
977 |
||
978 |
initialize |
|
979 |
super initialize. |
|
980 |
||
981 |
showMatchingParenthesis := false. |
|
982 |
insertMode := false. |
|
936 | 983 |
alwaysAppendAtEnd := false. |
944 | 984 |
collectSize := 100. |
977 | 985 |
st80Mode := false. |
986 |
trimBlankLines := true. |
|
914 | 987 |
|
926 | 988 |
numberOfColumns := 80. |
979 | 989 |
numberOfLines := 24. |
954 | 990 |
rangeStartLine := 1. |
991 |
rangeEndLine := numberOfLines. |
|
926 | 992 |
|
914 | 993 |
self initializeKeyboardSequences. |
994 |
list := OrderedCollection new:24 withAll:''. |
|
995 |
||
996 |
self initializeKeyboardMap. |
|
997 |
||
998 |
" |
|
999 |
VT52TerminalView openShell |
|
926 | 1000 |
VT100TerminalView openShell |
914 | 1001 |
" |
926 | 1002 |
|
979 | 1003 |
"Modified: / 20.6.1998 / 20:06:49 / cg" |
914 | 1004 |
! |
1005 |
||
1006 |
initializeKeyboardMap |
|
1349 | 1007 |
|keys ctrlKeys cmdKeys| |
914 | 1008 |
|
1349 | 1009 |
"/ setup my own keyboardMap, where control-keys |
1010 |
"/ (and some Cmd-keys) are not translated. |
|
914 | 1011 |
kbdMap := device keyboardMap copy. |
1349 | 1012 |
keys := kbdMap keys. |
914 | 1013 |
|
1349 | 1014 |
ctrlKeys := keys select:[:key | key startsWith:'Ctrl']. |
914 | 1015 |
ctrlKeys do:[:key | kbdMap removeKey:key]. |
950 | 1016 |
|
1349 | 1017 |
cmdKeys := keys select:[:key | key startsWith:'Cmd']. |
1018 |
cmdKeys do:[:key | |val| |
|
1019 |
val := kbdMap at:key. |
|
1020 |
val isSymbol ifTrue:[ |
|
1021 |
(#(Copy Paste SaveAs Print) includes:val) ifFalse:[ |
|
1022 |
kbdMap removeKey:key |
|
1023 |
] |
|
950 | 1024 |
] |
1025 |
]. |
|
914 | 1026 |
|
1027 |
kbdMap removeKey:#Delete ifAbsent:[]. |
|
1028 |
kbdMap removeKey:#BackSpace ifAbsent:[]. |
|
1029 |
||
1030 |
" |
|
1031 |
VT52TerminalView openShell |
|
1032 |
" |
|
950 | 1033 |
|
1349 | 1034 |
"Modified: / 29.4.1999 / 14:25:24 / cg" |
914 | 1035 |
! |
1036 |
||
1037 |
initializeKeyboardSequences |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1038 |
kbdSequences := (self anyKeyCodes) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1039 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1040 |
"Modified: / 5.5.1999 / 15:01:09 / cg" |
914 | 1041 |
! |
1042 |
||
1043 |
keyboardMap |
|
934 | 1044 |
"return my keyboard map. This has control keys removed and |
1045 |
those will be passed unchanged to the shell" |
|
1046 |
||
914 | 1047 |
^ kbdMap |
934 | 1048 |
|
1049 |
"Modified: / 10.6.1998 / 17:46:59 / cg" |
|
914 | 1050 |
! |
1051 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1052 |
reinitialize |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1053 |
"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
|
1054 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1055 |
super reinitialize. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1056 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1057 |
shellPid := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1058 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1059 |
self stopReaderProcess. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1060 |
readerProcess := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1061 |
inStream := outStream := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1062 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1063 |
"/ 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
|
1064 |
[ |
1322 | 1065 |
"/ Delay waitForSeconds:0.5. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1066 |
self doClearEntireScreen. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1067 |
self cursorLine:1 col:1. |
1321
9a312fa98358
also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents:
1320
diff
changeset
|
1068 |
self contents:nil. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1069 |
self flash. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1070 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1071 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1072 |
"/ 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
|
1073 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1074 |
self startCommand:shellCommand in:shellDirectory. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1075 |
] forkAt:8 |
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 |
|
914 | 1078 |
startReaderProcess |
934 | 1079 |
"Start a reader process, which looks for the commands output, |
1009 | 1080 |
and sends me #processInput:n: events whenever something arrives." |
934 | 1081 |
|
914 | 1082 |
readerProcess isNil ifTrue:[ |
1083 |
readerProcess := [ |
|
1084 |
[ |
|
947 | 1085 |
self waitUntilVisible. |
1086 |
||
940 | 1087 |
Stream streamErrorSignal handle:[:ex | |
1339 | 1088 |
Transcript show:'Terminal [error]: '; showCR:ex errorString. |
1089 |
Transcript show:'Terminal [info]: '; showCR:OperatingSystem lastErrorString. |
|
940 | 1090 |
] do:[ |
926 | 1091 |
[true] whileTrue:[ |
1092 |
Object abortSignal handle:[:ex | |
|
1093 |
self showCursor. |
|
1094 |
] do:[ |
|
1323 | 1095 |
|buffer n sensor| |
948 | 1096 |
|
926 | 1097 |
outStream readWait. |
1323 | 1098 |
(sensor := self sensor hasKeyPressEventFor:self) ifTrue:[ |
1099 |
true "(sensor userEventCount > 10)" ifTrue:[ |
|
997 | 1100 |
"/ give terminalView a chance to |
1101 |
"/ send out the character. |
|
1323 | 1102 |
Delay waitForSeconds:0.01. |
997 | 1103 |
] |
926 | 1104 |
] ifFalse:[ |
945 | 1105 |
buffer := String new:1024. |
1106 |
n := outStream nextAvailableBytes:1024 into:buffer startingAt:1. |
|
1107 |
n > 0 ifTrue:[ |
|
1108 |
self pushEvent:#processInput:n: with:buffer with:n. |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1109 |
self waitForOutputToDrain. |
945 | 1110 |
] ifFalse:[ |
1111 |
n == 0 ifTrue:[ |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1112 |
"/ 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
|
1113 |
"/ 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
|
1114 |
"/ 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
|
1115 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1116 |
Delay waitForSeconds:0.01 |
1323 | 1117 |
] ifFalse:[ |
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1118 |
outStream atEnd ifTrue:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1119 |
outStream close. outStream := nil. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1120 |
inStream close. inStream := nil. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1121 |
|
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1122 |
Processor activeProcess terminate. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1123 |
] ifFalse:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1124 |
"/ this should not happen. |
1323 | 1125 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1126 |
Delay waitForSeconds:0.05 |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1127 |
] |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1128 |
]. |
926 | 1129 |
] |
1130 |
] |
|
914 | 1131 |
] |
1132 |
] |
|
1133 |
] |
|
1134 |
] |
|
1135 |
] valueOnUnwindDo:[ |
|
1136 |
readerProcess := nil |
|
1137 |
] |
|
997 | 1138 |
] fork. "/ forkAt:9. |
1139 |
readerProcess name:'pty reader'. |
|
914 | 1140 |
] |
1141 |
||
1142 |
" |
|
934 | 1143 |
VT100TerminalView openShell |
914 | 1144 |
" |
926 | 1145 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1146 |
"Modified: / 27.4.1999 / 20:25:14 / cg" |
1009 | 1147 |
! |
1148 |
||
1149 |
stopReaderProcess |
|
1150 |
|sensor| |
|
1151 |
||
1152 |
readerProcess notNil ifTrue:[ |
|
1153 |
readerProcess terminate. |
|
1154 |
"/ give it a chance to really terminate |
|
1155 |
Processor yield. |
|
1156 |
readerProcess := nil |
|
1157 |
]. |
|
1158 |
||
1159 |
"/ flush any leftover input-processing events |
|
1160 |
(sensor := self sensor) notNil ifTrue:[ |
|
1161 |
sensor flushEventsFor:self withType:#processInput:n:. |
|
1162 |
] |
|
1163 |
"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
|
1164 |
! ! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
1165 |
|
914 | 1166 |
!TerminalView methodsFor:'menu'! |
1167 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1168 |
doReset |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1169 |
"reset the scroll-range; |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1170 |
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
|
1171 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1172 |
rangeStartLine := 1. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1173 |
rangeEndLine := numberOfLines. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1174 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1175 |
self normal. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1176 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1177 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1178 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1179 |
doSendInterrupt |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1180 |
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
|
1181 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1182 |
"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
|
1183 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1184 |
|
914 | 1185 |
editMenu |
1186 |
"return the views middleButtonMenu" |
|
1187 |
||
1347 | 1188 |
<resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)> |
914 | 1189 |
<resource: #programMenu> |
1190 |
||
1191 |
|items m sub shortKeys sensor| |
|
1192 |
||
1193 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
|
1194 |
items := #( |
|
1195 |
('Interrupt' doSendInterrupt) |
|
1182 | 1196 |
('-' ) |
1197 |
('Reset' doReset) |
|
914 | 1198 |
). |
1199 |
] ifFalse:[ |
|
1200 |
items := #( |
|
1201 |
('copy' copySelection Copy ) |
|
1202 |
('paste' pasteOrReplace Paste ) |
|
1203 |
('-' ) |
|
951 | 1204 |
('font ...' changeFont ) |
1205 |
('-' ) |
|
914 | 1206 |
('save as ...' save SaveAs ) |
1207 |
('print' doPrint Print ) |
|
1208 |
). |
|
1347 | 1209 |
|
1210 |
"/ disabled - for now; |
|
1211 |
"/ need a more intelligent filtering of control characters. |
|
1212 |
"/ |
|
1213 |
"/ filterStream isNil ifTrue:[ |
|
1214 |
"/ items := items , #( |
|
1215 |
"/ ('-' ) |
|
1216 |
"/ ('start save as ...' startSaveAs ) |
|
1217 |
"/ ('start print' startPrint ) |
|
1218 |
"/ ) |
|
1219 |
"/ ] ifFalse:[ |
|
1220 |
"/ items := items , #( |
|
1221 |
"/ ('-' ) |
|
1222 |
"/ ('stop filter' stopFilter ) |
|
1223 |
"/ ) |
|
1224 |
"/ ]. |
|
914 | 1225 |
]. |
1226 |
||
1227 |
m := PopUpMenu itemList:items resources:resources. |
|
1228 |
||
1229 |
self hasSelection not ifTrue:[ |
|
1230 |
m disable:#copySelection. |
|
1231 |
]. |
|
1232 |
^ m. |
|
1233 |
||
1347 | 1234 |
"Modified: / 29.4.1999 / 11:12:56 / cg" |
1235 |
! |
|
1236 |
||
1237 |
startSaveAs |
|
1238 |
"start saving all received data to some file" |
|
1239 |
||
1240 |
|fn| |
|
1241 |
||
1242 |
fn := Dialog requestFileName:'Save received data in file:'. |
|
1243 |
fn size > 0 ifTrue:[ |
|
1244 |
filterStream := fn asFilename writeStream |
|
1245 |
]. |
|
1246 |
||
1247 |
"Created: / 29.4.1999 / 11:06:29 / cg" |
|
1248 |
! |
|
1249 |
||
1250 |
stopFilter |
|
1251 |
"stop saving/printing of received data" |
|
1252 |
||
1253 |
filterStream close. |
|
1254 |
filterStream := nil. |
|
1255 |
||
1256 |
"Created: / 29.4.1999 / 11:07:49 / cg" |
|
1257 |
"Modified: / 29.4.1999 / 11:09:52 / cg" |
|
914 | 1258 |
! ! |
1259 |
||
940 | 1260 |
!TerminalView methodsFor:'misc'! |
914 | 1261 |
|
1262 |
removeTrailingBlankLines |
|
1263 |
^ self |
|
1264 |
! ! |
|
1265 |
||
1266 |
!TerminalView methodsFor:'processing - input'! |
|
1267 |
||
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1268 |
nextPutAll:aString |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1269 |
"/ self processInput:aString n:aString size |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1270 |
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
|
1271 |
|
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1272 |
"Created: / 27.7.1998 / 15:10:59 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1273 |
"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
|
1274 |
! |
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1275 |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1276 |
processInput:buffer n:count |
997 | 1277 |
|sensor| |
1278 |
||
1347 | 1279 |
filterStream notNil ifTrue:[ |
1280 |
filterStream nextPutAll:(buffer copyTo:count). |
|
1281 |
]. |
|
1282 |
||
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
1283 |
"/ self hideCursor. |
997 | 1284 |
|
1015 | 1285 |
"/ the following may not be too clean, but adds a lot of speed. |
1286 |
"/ instead of passing every individual character through the |
|
1287 |
"/ escape-state machine, collect chunks of non-control text |
|
1288 |
"/ when in state 0, and add them immediately to the pendingLines |
|
1289 |
"/ collection of the textCollectors asynchronous update mechanism. |
|
1290 |
"/ This helps a lot if you do something like "ls -lR /" ... |
|
1291 |
"/ For debugging the state machine, reenable the commented lines |
|
1292 |
"/ below. |
|
1293 |
||
1294 |
"/1 to:count do:[:i| |
|
1295 |
"/ self nextPut:(buffer at:i). |
|
1296 |
"/]. |
|
1297 |
"/self showCursor. |
|
1298 |
"/^ self. |
|
1299 |
||
1300 |
access critical:[ |
|
1301 |
|i i2 s crnlFollows| |
|
997 | 1302 |
|
1015 | 1303 |
i := 1. |
1304 |
[i <= count] whileTrue:[ |
|
1305 |
(state == 0) ifTrue:[ |
|
1306 |
"/ in initial state. |
|
1307 |
"/ quick scan forward for next control character ... |
|
1308 |
i2 := buffer indexOfControlCharacterStartingAt:i. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1309 |
i2 > count ifTrue:[i2 := 0]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1310 |
|
1015 | 1311 |
i2 == 0 ifTrue:[ |
1312 |
"/ no control characters - simply append all |
|
1313 |
"/ to the outstanding lines ... |
|
1314 |
s := buffer copyFrom:i to:count. |
|
1315 |
i := count + 1. "/ leave loop. |
|
997 | 1316 |
crnlFollows := false. |
1015 | 1317 |
] ifFalse:[ |
1318 |
i2 > i ifTrue:[ |
|
1319 |
s := buffer copyFrom:i to:i2-1. |
|
1320 |
i := i2. "/ proceed withcontrol character |
|
1321 |
crnlFollows := false. |
|
1322 |
i < (count - 1) ifTrue:[ |
|
1323 |
(buffer at:i) == Character return ifTrue:[ |
|
1324 |
(buffer at:i+1) == Character nl ifTrue:[ |
|
1325 |
crnlFollows := true. |
|
1326 |
i := i + 2. |
|
1327 |
] |
|
997 | 1328 |
] |
1015 | 1329 |
]. |
1330 |
] |
|
1331 |
]. |
|
997 | 1332 |
]. |
1333 |
||
1015 | 1334 |
s notNil ifTrue:[ |
1335 |
currentEmphasis notNil ifTrue:[ |
|
1336 |
s := s emphasizeAllWith:currentEmphasis |
|
1337 |
]. |
|
1338 |
||
1339 |
outstandingLine size > 0 ifTrue:[ |
|
1340 |
outstandingLine := outstandingLine , s. |
|
997 | 1341 |
] ifFalse:[ |
1015 | 1342 |
outstandingLine := s. |
997 | 1343 |
]. |
1015 | 1344 |
crnlFollows ifTrue:[ |
1345 |
outstandingLines isNil ifTrue:[ |
|
1346 |
outstandingLines := OrderedCollection with:outstandingLine |
|
1347 |
] ifFalse:[ |
|
1348 |
outstandingLines add:outstandingLine. |
|
1349 |
]. |
|
1350 |
outstandingLine := ''. |
|
1351 |
]. |
|
1352 |
s := nil. |
|
997 | 1353 |
|
1015 | 1354 |
collecting ifTrue:[ |
1355 |
flushPending ifFalse:[ |
|
1356 |
self installDelayedUpdate |
|
1357 |
] ifTrue:[ |
|
1358 |
"/ outstandingLines size > collectSize ifTrue:[ |
|
1359 |
"/ self endEntry |
|
1360 |
"/ ] |
|
1361 |
] |
|
1362 |
] ifFalse:[ |
|
1363 |
self endEntry |
|
1364 |
]. |
|
997 | 1365 |
] ifFalse:[ |
1015 | 1366 |
"/ no chunk to append (in an escape sequence) |
1367 |
"/ must handle individual characters |
|
1368 |
"/ 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
|
1369 |
|
1015 | 1370 |
self nextPut:(buffer at:i). |
1371 |
i := i + 1. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1372 |
[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
|
1373 |
self nextPut:(buffer at:i). |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1374 |
i := i + 1. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1375 |
] |
1015 | 1376 |
] |
1377 |
]. |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1378 |
]. |
948 | 1379 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1380 |
state == 0 ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1381 |
(sensor := self sensor) notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1382 |
"/ 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
|
1383 |
"/ enforce update of the view (asynchronous) |
997 | 1384 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1385 |
(sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
997 | 1386 |
self endEntry. |
1387 |
self showCursor. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1388 |
"/ self makeCursorVisible. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1389 |
] ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1390 |
"/ 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
|
1391 |
"/ 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
|
1392 |
"/ 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
|
1393 |
"/ 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
|
1394 |
"/ collectSize lines. |
1015 | 1395 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1396 |
outstandingLines size > collectSize ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1397 |
self endEntry. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1398 |
self showCursor. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1399 |
|
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1400 |
"/ 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
|
1401 |
windowGroup notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1402 |
windowGroup processRealExposeEventsFor:self. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1403 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1404 |
]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1405 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1406 |
]. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1407 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1408 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1409 |
"Created: / 10.6.1998 / 17:26:09 / cg" |
1347 | 1410 |
"Modified: / 29.4.1999 / 11:08:48 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1411 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1412 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1413 |
sync |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1414 |
self waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1415 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1416 |
"Created: / 27.7.1998 / 23:49:44 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1417 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1418 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1419 |
waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1420 |
|sensor| |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1421 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1422 |
sensor := self sensor. |
1323 | 1423 |
(sensor userEventCount > 30) ifTrue:[ |
1424 |
[sensor userEventCount > 5] whileTrue:[ |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1425 |
"/ give terminalView a chance to |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1426 |
"/ catch up. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1427 |
Delay waitForSeconds:0.1. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1428 |
] |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1429 |
]. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1430 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1431 |
"Modified: / 27.7.1998 / 23:16:19 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1432 |
"Created: / 27.7.1998 / 23:47:22 / cg" |
914 | 1433 |
! ! |
1434 |
||
1435 |
!TerminalView methodsFor:'queries'! |
|
1436 |
||
1437 |
preferredExtent |
|
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1438 |
^ (fontWidth * self class defaultNumberOfColumns + (leftMargin * 2)) |
951 | 1439 |
@ |
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1440 |
((self heightForLines:self class defaultNumberOfLines) + 8) |
926 | 1441 |
|
979 | 1442 |
"Modified: / 20.6.1998 / 20:06:57 / cg" |
929 | 1443 |
! |
1444 |
||
1445 |
terminalType |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
1446 |
^ 'dump' |
929 | 1447 |
|
1448 |
"Created: / 10.6.1998 / 16:22:30 / cg" |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
1449 |
"Modified: / 5.5.1999 / 11:22:32 / cg" |
914 | 1450 |
! ! |
1451 |
||
1452 |
!TerminalView methodsFor:'selection handling'! |
|
1453 |
||
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1454 |
autoMoveCursorToEndOfSelection |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1455 |
"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
|
1456 |
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
|
1457 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1458 |
^ false |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1459 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1460 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1461 |
|
914 | 1462 |
paste:someText |
1463 |
"paste - redefined to send the chars to the shell instead |
|
1464 |
of pasting into the view" |
|
1465 |
||
950 | 1466 |
|s nLines| |
1467 |
||
1468 |
s := someText. |
|
1469 |
s isString ifTrue:[ |
|
1470 |
s := s asStringCollection |
|
1471 |
] ifFalse:[ |
|
1472 |
(s isKindOf:StringCollection) ifFalse:[ |
|
1473 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
1474 |
^ self |
|
1475 |
] |
|
1476 |
]. |
|
1477 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
1478 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
|
1479 |
s keysAndValuesDo:[:idx :line | |
|
1480 |
inStream nextPutAll:line. |
|
1481 |
idx ~~ nLines ifTrue:[ |
|
1482 |
inStream nextPut:(Character return). |
|
1483 |
] |
|
1484 |
]. |
|
1485 |
||
1486 |
"Modified: / 12.6.1998 / 22:12:47 / cg" |
|
914 | 1487 |
! ! |
1488 |
||
1489 |
!TerminalView class methodsFor:'documentation'! |
|
1490 |
||
1491 |
version |
|
1359 | 1492 |
^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.79 1999-05-05 14:50:01 cg Exp $' |
914 | 1493 |
! ! |