author | Stefan Vogel <sv@exept.de> |
Thu, 27 Feb 2003 15:45:44 +0100 | |
changeset 2450 | ac2ab4cbfb79 |
parent 2449 | b16aece32285 |
child 2466 | f986a03f160f |
permissions | -rw-r--r-- |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
3 |
All Rights Reserved |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
4 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
5 |
This software is furnished under a license and may be used |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
10 |
hereby transferred. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
11 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
12 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
13 |
|
1833 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
914 | 16 |
TextCollector subclass:#TerminalView |
2268 | 17 |
instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences |
18 |
escapeSequenceTree currentSequence kbdMap escapeLeadingChars |
|
19 |
numberOfColumns numberOfLines shellTerminateAction rangeStartLine |
|
20 |
rangeEndLine state savedCursor shellCommand shellDirectory |
|
21 |
filterStream localEcho translateNLToCRNL inputTranslateCRToNL |
|
22 |
autoWrapFlag' |
|
23 |
classVariableNames:'Debug' |
|
24 |
poolDictionaries:'' |
|
25 |
category:'Views-TerminalViews' |
|
914 | 26 |
! |
27 |
||
28 |
!TerminalView class methodsFor:'documentation'! |
|
29 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
30 |
copyright |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
31 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
32 |
COPYRIGHT (c) 1998 by eXept Software AG |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
33 |
All Rights Reserved |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
34 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
35 |
This software is furnished under a license and may be used |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
36 |
only in accordance with the terms of that license and with the |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
37 |
inclusion of the above copyright notice. This software may not |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
38 |
be provided or otherwise made available to, or used by, any |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
39 |
other person. No title to or ownership of the software is |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
40 |
hereby transferred. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
41 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
42 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
43 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
44 |
|
914 | 45 |
documentation |
46 |
" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
47 |
I provide terminal functionality, by interpreting data |
1418 | 48 |
arriving from some stream (typically connected to a command interpreter |
49 |
via a pty, or another system via a modem) |
|
50 |
and sending my keyboard data to it. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
51 |
|
1418 | 52 |
I am abstract providing general functionality |
53 |
- concrete terminal characteristics are defined by concrete subclasses |
|
54 |
(see VT52TerminalView, VT100TerminalView). |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
55 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
56 |
Concrete applications are: |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
57 |
consoles (VT100TerminalView), |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
58 |
telnet-views (see TelnetTool) |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
59 |
editor wrappers (if you like emacs/vi) |
914 | 60 |
|
1418 | 61 |
<<although my class protocol includes common startup protocol |
62 |
(to open a terminalView with a shell or on the output of a command), |
|
63 |
I can be used as a widget within an application (Modem software). |
|
64 |
||
914 | 65 |
[author:] |
66 |
Claus Gittinger |
|
915 | 67 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
68 |
[instance variables:] |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
69 |
inStream stream where keyboard input is |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
70 |
sent to (connected to shells or commands input) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
71 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
72 |
outStream stream where the output of the |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
73 |
shell or command arrives |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
74 |
(read here and displayed in the view) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
75 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
76 |
readerProcess process which reads commands |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
77 |
output and sends it to the view |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
78 |
|
2204 | 79 |
[class variables]: |
80 |
Debug := true trace incoming characters |
|
81 |
||
82 |
||
915 | 83 |
[start with:] |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
84 |
VT52TerminalView open |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
85 |
VT100TerminalView open |
915 | 86 |
VT52TerminalView openShell |
919 | 87 |
VT100TerminalView openShell |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
88 |
VT100TerminalView openOnCommand:'ls -l' |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
89 |
VT100TerminalView openOnCommand:'dir' |
1418 | 90 |
|
91 |
[see also:] |
|
92 |
TelNetTool |
|
914 | 93 |
" |
94 |
! ! |
|
95 |
||
2207 | 96 |
!TerminalView class methodsFor:'initialization'! |
2205 | 97 |
|
98 |
initialize |
|
2207 | 99 |
|
2205 | 100 |
Debug := false. |
2207 | 101 |
|
102 |
" |
|
103 |
self initialize |
|
104 |
" |
|
2205 | 105 |
! ! |
106 |
||
1052 | 107 |
!TerminalView class methodsFor:'defaults'! |
108 |
||
109 |
defaultIcon |
|
110 |
^ Image fromFile:'bitmaps/xpmBitmaps/terminal_images/xterm-icon.xpm' |
|
111 |
||
112 |
"Created: / 4.8.1998 / 17:48:18 / cg" |
|
113 |
"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
|
114 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
115 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
116 |
defaultNumberOfColumns |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
117 |
^ 80 |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
118 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
119 |
"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
|
120 |
"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
|
121 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
122 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
123 |
defaultNumberOfLines |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
124 |
^ 25 |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
125 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
126 |
"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
|
127 |
"Modified: / 4.8.1998 / 17:48:31 / cg" |
1052 | 128 |
! ! |
129 |
||
972 | 130 |
!TerminalView class methodsFor:'opening'! |
914 | 131 |
|
928 | 132 |
open |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
133 |
^ self openShell |
928 | 134 |
|
135 |
" |
|
136 |
VT100TerminalView open |
|
137 |
" |
|
138 |
||
139 |
"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
|
140 |
"Modified: / 9.7.1998 / 17:55:37 / cg" |
928 | 141 |
! |
142 |
||
914 | 143 |
openDummy |
972 | 144 |
"for testing purposes only - opens a dummy tty-view, which simply |
145 |
echoes whatever is typed in" |
|
146 |
||
914 | 147 |
|in vt52| |
148 |
||
149 |
vt52 := self new. |
|
150 |
in := ForwardingStream on:''. |
|
151 |
||
152 |
in fwdStream:vt52. |
|
153 |
vt52 inStream:in. |
|
154 |
vt52 outStream:in. |
|
155 |
vt52 open |
|
156 |
||
157 |
" |
|
158 |
self openDummy |
|
159 |
" |
|
160 |
! |
|
161 |
||
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
162 |
openOnCommand:aCommandString |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
163 |
"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
|
164 |
(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
|
165 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
166 |
^ self openOnCommand:aCommandString onExit:[] |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
167 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
168 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
169 |
VT100TerminalView openOnCommand:'ls -l' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
170 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
171 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
172 |
"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
|
173 |
"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
|
174 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
175 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
176 |
openOnCommand:aCommandString onExit:aBlock |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
177 |
"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
|
178 |
(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
|
179 |
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
|
180 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
181 |
|in top scr vt52| |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
182 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
183 |
top := StandardSystemView new. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
184 |
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
|
185 |
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
|
186 |
vt52 := scr scrolledView. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
187 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
188 |
vt52 startCommand:aCommandString. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
189 |
vt52 shellTerminateAction:[ |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
190 |
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
|
191 |
]. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
192 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
193 |
top extent:(scr preferredExtent). |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
194 |
top label:('executing: "' , aCommandString , '"'). |
1014 | 195 |
top iconLabel:'command'. |
1052 | 196 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
197 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
198 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
199 |
^ vt52 |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
200 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
201 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
202 |
VT100TerminalView openOnCommand:'ls -lR' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
203 |
VT100TerminalView openOnCommand:'vi /etc/hosts' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
204 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
205 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
206 |
"Created: / 9.7.1998 / 17:54:34 / cg" |
1052 | 207 |
"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
|
208 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
209 |
|
1014 | 210 |
openOnInput:inStream output:outStream |
972 | 211 |
"open a terminalView on the given streams (which are typically some |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
212 |
kind of socket or pty). |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
213 |
Keys pressed are sent to inStream, text appearing |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
214 |
from outStream is displayed in the terminal view. |
972 | 215 |
This can be used to implement things like rlogin |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
216 |
or telnet views (if connected to a modem, a com-program can also be |
972 | 217 |
implemented this way)." |
218 |
||
2078 | 219 |
|top scr| |
972 | 220 |
|
221 |
top := StandardSystemView new. |
|
2078 | 222 |
scr := self openOnInput:inStream output:outStream in:top. |
223 |
||
224 |
top extent:(scr preferredExtent). |
|
225 |
top label:'shell'. |
|
226 |
top iconLabel:'shell'. |
|
227 |
top icon:(self defaultIcon). |
|
228 |
top open. |
|
229 |
^ top |
|
230 |
||
231 |
"Modified: / 5.5.1999 / 17:25:59 / cg" |
|
232 |
! |
|
233 |
||
234 |
openOnInput:inStream output:outStream in:aView |
|
235 |
"open a terminalView on the given streams (which are typically some |
|
236 |
kind of socket or pty). |
|
237 |
Keys pressed are sent to inStream, text appearing |
|
238 |
from outStream is displayed in the terminal view. |
|
239 |
This can be used to implement things like rlogin |
|
240 |
or telnet views (if connected to a modem, a com-program can also be |
|
241 |
implemented this way)." |
|
242 |
||
243 |
|scr vt| |
|
244 |
||
245 |
scr := ScrollableView for:self in:aView. |
|
972 | 246 |
scr origin:0.0@0.0 corner:1.0@1.0. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
247 |
vt := scr scrolledView. |
972 | 248 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
249 |
vt inStream:inStream. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
250 |
vt outStream:outStream. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
251 |
vt startReaderProcess. |
972 | 252 |
|
2078 | 253 |
^ scr |
974 | 254 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
255 |
"Modified: / 5.5.1999 / 17:25:59 / cg" |
972 | 256 |
! |
257 |
||
914 | 258 |
openShell |
972 | 259 |
"start a shell on a pseudo-TTY, open a terminalView on it |
260 |
(i.e. this is kind of an xterm)" |
|
261 |
||
997 | 262 |
^ self openShellIn:nil |
992 | 263 |
|
264 |
" |
|
265 |
VT100TerminalView openShell |
|
266 |
" |
|
267 |
||
997 | 268 |
"Modified: / 21.7.1998 / 18:24:55 / cg" |
992 | 269 |
! |
270 |
||
271 |
openShellIn:aDirectory |
|
272 |
"start a shell on a pseudo-TTY, open a terminalView on it |
|
273 |
(i.e. this is kind of an xterm)" |
|
274 |
||
2163 | 275 |
| top scr vt lbl| |
914 | 276 |
|
277 |
top := StandardSystemView new. |
|
948 | 278 |
scr := ScrollableView for:self in:top. |
914 | 279 |
scr origin:0.0@0.0 corner:1.0@1.0. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
280 |
vt := scr scrolledView. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
281 |
vt startShellIn:aDirectory. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
282 |
vt shellTerminateAction:[top destroy]. |
914 | 283 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
284 |
lbl := OperatingSystem isUNIXlike ifTrue:['shell'] ifFalse:['dos']. |
940 | 285 |
top extent:(scr preferredExtent). |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
286 |
top label:lbl. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
287 |
top iconLabel:lbl. |
1052 | 288 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
289 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
290 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
291 |
^ vt |
914 | 292 |
|
293 |
" |
|
992 | 294 |
VT100TerminalView openShellIn:'/etc' |
914 | 295 |
" |
946 | 296 |
|
992 | 297 |
"Created: / 20.7.1998 / 18:28:15 / cg" |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
298 |
"Modified: / 5.5.1999 / 17:27:10 / cg" |
914 | 299 |
! ! |
300 |
||
972 | 301 |
!TerminalView class methodsFor:'queries'! |
302 |
||
303 |
isVisualStartable |
|
304 |
"returns whether this application class can be started via #open" |
|
305 |
||
306 |
self == TerminalView ifTrue:[^ false]. |
|
307 |
^ true |
|
308 |
||
309 |
"Created: / 10.6.1998 / 15:48:43 / cg" |
|
310 |
! ! |
|
311 |
||
914 | 312 |
!TerminalView methodsFor:'accessing'! |
313 |
||
2076 | 314 |
filterStream:something |
315 |
"set a filter stream; if not nil, it gets all incoming data via nextPutAll:. |
|
316 |
(added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt |
|
317 |
incoming data by some other program)" |
|
318 |
||
319 |
filterStream := something. |
|
320 |
||
321 |
"Created: / 28.1.2002 / 20:56:04 / micha" |
|
322 |
"Modified: / 28.1.2002 / 20:56:11 / micha" |
|
323 |
! |
|
324 |
||
914 | 325 |
inStream |
326 |
"return the value of the instance variable 'inStream' (automatically generated)" |
|
327 |
||
2075 | 328 |
^ inStream |
329 |
! |
|
914 | 330 |
|
331 |
inStream:something |
|
332 |
"set the value of the instance variable 'inStream' (automatically generated)" |
|
333 |
||
2075 | 334 |
inStream := something. |
335 |
! |
|
914 | 336 |
|
2078 | 337 |
inputTranslateCRToNL |
338 |
^ inputTranslateCRToNL |
|
339 |
! |
|
340 |
||
341 |
inputTranslateCRToNL:something |
|
342 |
inputTranslateCRToNL := something. |
|
343 |
! |
|
344 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
345 |
localEcho:aBoolean |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
346 |
"enable/disable local echo" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
347 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
348 |
localEcho := aBoolean |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
349 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
350 |
"Created: / 5.5.1999 / 17:53:16 / cg" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
351 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
352 |
|
914 | 353 |
outStream |
354 |
"return the value of the instance variable 'outStream' (automatically generated)" |
|
355 |
||
2075 | 356 |
^ outStream |
357 |
! |
|
914 | 358 |
|
359 |
outStream:something |
|
360 |
"set the value of the instance variable 'outStream' (automatically generated)" |
|
361 |
||
2075 | 362 |
outStream := something. |
363 |
! |
|
946 | 364 |
|
1004 | 365 |
readerProcess |
366 |
"return the value of the instance variable 'readerProcess' (automatically generated)" |
|
367 |
||
368 |
^ readerProcess |
|
369 |
! |
|
370 |
||
946 | 371 |
shellTerminateAction:aBlock |
372 |
"set the block which is evaluated when the shell terminates. |
|
373 |
Can be used to close down the application in this case." |
|
374 |
||
375 |
shellTerminateAction := aBlock. |
|
376 |
||
377 |
"Created: / 12.6.1998 / 17:02:58 / cg" |
|
2076 | 378 |
! |
379 |
||
380 |
translateNLToCRNL |
|
381 |
"return the value of the instance variable 'translateNLToCRNL' (automatically generated)" |
|
382 |
||
383 |
^ translateNLToCRNL |
|
384 |
||
385 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
386 |
! |
|
387 |
||
388 |
translateNLToCRNL:something |
|
389 |
"set the value of the instance variable 'translateNLToCRNL' (automatically generated)" |
|
390 |
||
391 |
translateNLToCRNL := something. |
|
392 |
||
393 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
946 | 394 |
! ! |
914 | 395 |
|
396 |
!TerminalView methodsFor:'cursor handling'! |
|
397 |
||
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
398 |
cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
399 |
cursorLine + n > list size ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
400 |
list := list , (Array new:n). |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
401 |
self textChanged. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
402 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
403 |
super cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
404 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
405 |
"Modified: / 10.6.1998 / 17:18:41 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
406 |
"Created: / 10.6.1998 / 17:18:50 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
407 |
! |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
408 |
|
968
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
409 |
cursorMovementAllowed |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
410 |
"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
|
411 |
(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
|
412 |
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
|
413 |
cursor positioning escape sequences arriving from the |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
414 |
stream." |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
415 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
416 |
^ false |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
417 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
418 |
"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
|
419 |
! |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
420 |
|
2169 | 421 |
numberOfTerminalCols |
422 |
^ numberOfColumns |
|
423 |
! |
|
424 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
425 |
numberOfTerminalColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
426 |
^ numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
427 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
428 |
"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
|
429 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
430 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
431 |
numberOfTerminalLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
432 |
"/ 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
|
433 |
"/ 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
|
434 |
"/ in ListView ... |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
435 |
"/ ... 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
|
436 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
437 |
^ numberOfLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
438 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
439 |
"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
|
440 |
"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
|
441 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
442 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
443 |
restoreCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
444 |
|l c| |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
445 |
|
2192 | 446 |
savedCursor isNil ifTrue:[ |
447 |
l := c := 1. |
|
448 |
] ifFalse:[ |
|
449 |
l := savedCursor y. |
|
450 |
c := savedCursor x. |
|
451 |
]. |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
452 |
self cursorLine:l col:c. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
453 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
454 |
"Created: / 14.8.1998 / 13:49:24 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
455 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
456 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
457 |
saveCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
458 |
savedCursor := cursorCol @ cursorLine |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
459 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
460 |
"Created: / 14.8.1998 / 13:48:45 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
461 |
"Modified: / 14.8.1998 / 13:49:32 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
462 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
463 |
|
914 | 464 |
validateCursorCol:col inLine:line |
465 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
466 |
Here, the linelength is enforced" |
|
467 |
||
2268 | 468 |
col > numberOfColumns ifTrue:[ |
469 |
autoWrapFlag ifTrue:[ |
|
470 |
self endEntry. |
|
471 |
self cursorLine:(self cursorLine + 1) col:(col-numberOfColumns). |
|
472 |
^ 1. |
|
473 |
]. |
|
474 |
]. |
|
926 | 475 |
^ col min:numberOfColumns |
914 | 476 |
|
926 | 477 |
"Modified: / 10.6.1998 / 15:09:41 / cg" |
914 | 478 |
! ! |
479 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
480 |
!TerminalView methodsFor:'defaults'! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
481 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
482 |
anyKeyCodes |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
483 |
^ IdentityDictionary withKeysAndValues: |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
484 |
#( |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
485 |
#Escape '\e' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
486 |
#BackSpace '\b' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
487 |
#Return '\r' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
488 |
#Delete '\0177' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
489 |
#Tab '\t' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
490 |
) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
491 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
492 |
"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
|
493 |
! ! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
494 |
|
914 | 495 |
!TerminalView methodsFor:'event handling'! |
496 |
||
951 | 497 |
computeNumberOfLinesShown |
498 |
|prevNLines prevNCols| |
|
499 |
||
500 |
prevNCols := (innerWidth // font width). |
|
501 |
prevNLines := nFullLinesShown. |
|
502 |
||
503 |
super computeNumberOfLinesShown. |
|
504 |
||
505 |
((innerWidth // font width) ~~ prevNCols |
|
506 |
or:[prevNLines ~~ nFullLinesShown]) ifTrue:[ |
|
507 |
self defineWindowSize. |
|
508 |
] |
|
509 |
||
510 |
"Created: / 12.6.1998 / 22:34:39 / cg" |
|
979 | 511 |
"Modified: / 20.6.1998 / 19:45:28 / cg" |
951 | 512 |
! |
513 |
||
1359 | 514 |
contentsChanged |
515 |
super contentsChanged. |
|
516 |
self defineWindowSize. |
|
517 |
||
518 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
|
519 |
"Created: / 5.5.1999 / 16:30:15 / cg" |
|
520 |
! |
|
521 |
||
943 | 522 |
defineWindowSize |
2192 | 523 |
| delta prevNumCols prevNumLines| |
1359 | 524 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
525 |
"/self halt. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
526 |
"/self realized ifFalse:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
527 |
"/ "/ iconfified |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
528 |
"/ ^ self |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
529 |
"/]. |
1359 | 530 |
prevNumCols := numberOfColumns. |
531 |
prevNumLines := numberOfLines. |
|
1161 | 532 |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
533 |
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
|
534 |
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
|
535 |
numberOfLines := nFullLinesShown. |
1359 | 536 |
|
537 |
((prevNumCols == numberOfColumns) |
|
538 |
and:[prevNumLines == numberOfLines]) ifTrue:[ |
|
539 |
^ self |
|
540 |
]. |
|
541 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
542 |
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
|
543 |
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
|
544 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
545 |
|
1359 | 546 |
"/ any idea, how to do this under windows ? |
547 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
548 |
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
|
549 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
550 |
"/ 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
|
551 |
"/ 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
|
552 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
553 |
(inStream notNil |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
554 |
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
|
555 |
and:[inStream isOpen]]) ifTrue:[ |
2192 | 556 |
Debug ifTrue:[ |
557 |
Transcript showCR:'VT100: changed len to ', numberOfLines printString. |
|
558 |
]. |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
559 |
(OperatingSystem |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
560 |
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
|
561 |
width:numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
562 |
height:numberOfLines) ifFalse:[ |
2192 | 563 |
Debug ifTrue:[ |
564 |
Transcript showCR:'VT100: cannot change windowSize'. |
|
565 |
]. |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
566 |
]. |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
567 |
|
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
568 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
569 |
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
|
570 |
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
|
571 |
] |
943 | 572 |
]. |
573 |
||
574 |
"Created: / 11.6.1998 / 22:51:39 / cg" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
575 |
"Modified: / 5.5.1999 / 19:45:09 / cg" |
943 | 576 |
! |
577 |
||
914 | 578 |
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
|
579 |
|rest event rawKey seq| |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
580 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
581 |
"/ somewhat complicated, since some characters |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
582 |
"/ should go untranslated (CTRL-key), |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
583 |
"/ even if defined as function keys. |
914 | 584 |
|
585 |
inStream isNil ifTrue:[^ self]. |
|
586 |
||
2192 | 587 |
Debug ifTrue:[ |
588 |
Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString. |
|
589 |
]. |
|
914 | 590 |
|
591 |
aKey isCharacter ifTrue:[ |
|
592 |
"/ send it down to inStream ... |
|
593 |
inStream nextPut:aKey. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
594 |
localEcho ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
595 |
self nextPut:aKey |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
596 |
]. |
914 | 597 |
^ self |
598 |
]. |
|
599 |
||
1366 | 600 |
(#(Control Control_L Control_R |
601 |
Shift Shift_L Shift_R |
|
602 |
Alt Alt_L Alt_R |
|
603 |
Cmd Cmd_L Cmd_R |
|
604 |
Meta Meta_L Meta_R) includes:aKey) ifTrue:[ |
|
605 |
^ self |
|
606 |
]. |
|
607 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
608 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
609 |
"/ 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
|
610 |
"/ |
2078 | 611 |
(aKey == #Return |
612 |
and:[inputTranslateCRToNL]) ifTrue:[ |
|
613 |
seq := '\n'. |
|
614 |
] ifFalse:[ |
|
615 |
seq := kbdSequences at:aKey ifAbsent:nil. |
|
616 |
]. |
|
914 | 617 |
seq notNil ifTrue:[ |
2192 | 618 |
Debug ifTrue:[ |
619 |
Transcript show:'->' ; showCR:seq storeString. |
|
620 |
]. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
621 |
seq := seq withEscapes. |
2078 | 622 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
623 |
inStream nextPutAll:seq. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
624 |
localEcho ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
625 |
self nextPutAll:seq |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
626 |
]. |
914 | 627 |
^ self |
628 |
]. |
|
629 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
630 |
self sensor ctrlDown ifTrue:[ |
1366 | 631 |
(aKey startsWith:'Ctrl') ifTrue:[ |
632 |
rawKey := aKey |
|
633 |
] ifFalse:[ |
|
634 |
"/ already translated - undo it. |
|
635 |
||
636 |
event := WindowGroup lastEventQuerySignal query. |
|
637 |
rawKey := event rawKey. |
|
638 |
rawKey isCharacter ifTrue:[ |
|
639 |
rawKey := 'Ctrl' , rawKey. |
|
640 |
] |
|
1360 | 641 |
] |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
642 |
] ifFalse:[ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
643 |
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
|
644 |
]. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
645 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
646 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
647 |
"/ 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
|
648 |
"/ |
2192 | 649 |
Debug ifTrue:[ |
650 |
Transcript show:'raw ->' ; showCR:rawKey storeString. |
|
651 |
]. |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
652 |
|
914 | 653 |
seq := kbdSequences at:rawKey ifAbsent:nil. |
654 |
seq notNil ifTrue:[ |
|
2192 | 655 |
Debug ifTrue:[ |
656 |
Transcript show:'->' ; showCR:seq storeString. |
|
657 |
]. |
|
914 | 658 |
inStream nextPutAll:(seq withEscapes). |
659 |
^ self |
|
660 |
]. |
|
661 |
||
662 |
(rawKey startsWith:'Ctrl') ifTrue:[ |
|
663 |
rest := rawKey copyFrom:5. |
|
664 |
rest size == 1 ifTrue:[ |
|
665 |
rest := rest at:1. |
|
666 |
(rest >= $a and:[rest <= $z]) ifTrue:[ |
|
2192 | 667 |
Debug ifTrue:[ |
668 |
Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
|
669 |
]. |
|
914 | 670 |
inStream nextPut:(Character value:(rest - $a + 1)). |
671 |
^ self |
|
672 |
]. |
|
673 |
(rest >= $A and:[rest <= $Z]) ifTrue:[ |
|
2192 | 674 |
Debug ifTrue:[ |
675 |
Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
|
676 |
]. |
|
914 | 677 |
inStream nextPut:(Character value:(rest - $A + 1)). |
678 |
^ self |
|
679 |
]. |
|
680 |
] |
|
681 |
]. |
|
682 |
||
934 | 683 |
(rawKey startsWith:'Control') ifTrue:[ |
684 |
^ self |
|
685 |
]. |
|
686 |
(rawKey startsWith:'Shift') ifTrue:[ |
|
687 |
^ self |
|
688 |
]. |
|
689 |
(rawKey startsWith:'Alt') ifTrue:[ |
|
690 |
^ self |
|
691 |
]. |
|
692 |
(rawKey startsWith:'Cmd') ifTrue:[ |
|
950 | 693 |
^ super keyPress:aKey x:x y:y |
934 | 694 |
]. |
1345 | 695 |
(rawKey = 'Ctrl') ifTrue:[ |
696 |
^ self |
|
697 |
]. |
|
934 | 698 |
|
2192 | 699 |
Debug ifTrue:[ |
700 |
Transcript show:'unhandled key: '; showCR:rawKey. |
|
701 |
]. |
|
914 | 702 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
703 |
"Modified: / 5.5.1999 / 18:32:42 / cg" |
914 | 704 |
! |
705 |
||
706 |
shellTerminated |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
707 |
"shell has terminated" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
708 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
709 |
"/Delay waitForSeconds:10. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
710 |
[self readAnyAvailableData > 0] whileTrue:[Delay waitForSeconds:0.1]. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
711 |
"/ |
914 | 712 |
self closeDownShell. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
713 |
|
946 | 714 |
shellTerminateAction notNil ifTrue:[ |
715 |
shellTerminateAction value |
|
716 |
] ifFalse:[ |
|
717 |
"/ may be removed ... |
|
718 |
self warn:'shell terminated'. |
|
719 |
] |
|
720 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
721 |
"Modified: / 5.5.1999 / 18:43:22 / cg" |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
722 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
723 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
724 |
sizeChanged:how |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
725 |
super sizeChanged:how. |
943 | 726 |
self defineWindowSize. |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
727 |
|
943 | 728 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
914 | 729 |
! ! |
730 |
||
731 |
!TerminalView methodsFor:'functions'! |
|
732 |
||
733 |
doBackspace |
|
734 |
self cursorLeft. |
|
735 |
self replaceCharAtCursor:(Character space). |
|
736 |
self cursorLeft. |
|
737 |
||
931 | 738 |
"Modified: / 10.6.1998 / 17:09:12 / cg" |
914 | 739 |
! |
740 |
||
926 | 741 |
doClearDisplay |
1420 | 742 |
"clear everything" |
743 |
||
1000 | 744 |
self doClearEntireScreen. |
745 |
||
746 |
"Modified: / 21.7.1998 / 20:05:35 / cg" |
|
747 |
! |
|
748 |
||
1420 | 749 |
doClearEntireLine |
750 |
"clear the cursor line. cursor position remains unchanged" |
|
751 |
||
752 |
self at:cursorLine put:'' |
|
753 |
! |
|
754 |
||
1000 | 755 |
doClearEntireScreen |
1420 | 756 |
"clear everything" |
757 |
||
926 | 758 |
firstLineShown to:(list size) do:[:l | |
759 |
self at:l put:'' |
|
760 |
]. |
|
922 | 761 |
|
1000 | 762 |
"Modified: / 21.7.1998 / 20:00:19 / cg" |
763 |
"Created: / 21.7.1998 / 20:05:24 / cg" |
|
926 | 764 |
! |
765 |
||
1000 | 766 |
doClearFromBeginningOfLine |
1420 | 767 |
"clear from beginning of line to the cursorPosition" |
768 |
||
1000 | 769 |
|l| |
770 |
||
771 |
l := self listAt:cursorLine. |
|
772 |
l notNil ifTrue:[ |
|
773 |
(l size >= (cursorCol-1)) ifTrue:[ |
|
774 |
l := l copy from:1 to:cursorCol-1 put:(Character space). |
|
775 |
] ifFalse:[ |
|
776 |
l := nil. |
|
777 |
]. |
|
778 |
self withoutRedrawAt:cursorLine put:l. |
|
779 |
self invalidateLine:cursorLine |
|
780 |
"/ self at:cursorLine put:l. |
|
781 |
] |
|
782 |
||
783 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
|
784 |
"Created: / 21.7.1998 / 20:10:58 / cg" |
|
785 |
! |
|
786 |
||
787 |
doClearFromBeginningOfScreen |
|
1420 | 788 |
"clear from beginning of the screen to the cursorPosition" |
789 |
||
1000 | 790 |
self doClearFromBeginningOfLine. |
791 |
cursorLine-1 to:firstLineShown do:[:l | |
|
922 | 792 |
self at:l put:'' |
793 |
]. |
|
794 |
||
926 | 795 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
1000 | 796 |
"Created: / 21.7.1998 / 20:08:29 / cg" |
926 | 797 |
! |
798 |
||
799 |
doClearToEndOfLine |
|
1420 | 800 |
"clear from the cursorPosition to the end of the line" |
801 |
||
926 | 802 |
|l| |
803 |
||
804 |
l := self listAt:cursorLine. |
|
931 | 805 |
(l size >= (cursorCol-1)) ifTrue:[ |
951 | 806 |
l notNil ifTrue:[ |
807 |
l := l copyTo:cursorCol-1. |
|
979 | 808 |
self withoutRedrawAt:cursorLine put:l. |
809 |
self invalidateLine:cursorLine |
|
810 |
"/ self at:cursorLine put:l. |
|
951 | 811 |
] |
926 | 812 |
] |
813 |
||
814 |
"Created: / 10.6.1998 / 14:45:01 / cg" |
|
979 | 815 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
914 | 816 |
! |
817 |
||
1000 | 818 |
doClearToEndOfScreen |
1420 | 819 |
"clear from the cursorPosition to the end of the screen" |
820 |
||
1000 | 821 |
self doClearToEndOfLine. |
822 |
cursorLine+1 to:(list size) do:[:l | |
|
823 |
self at:l put:'' |
|
824 |
]. |
|
825 |
||
826 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
|
827 |
"Created: / 21.7.1998 / 20:06:14 / cg" |
|
828 |
! |
|
829 |
||
926 | 830 |
doCursorDown:n |
1420 | 831 |
"move the cursor down by n lines" |
832 |
||
979 | 833 |
|wasOn rEnd| |
926 | 834 |
|
979 | 835 |
"/ rangeEndLine == numberOfLines ifTrue:[ |
836 |
"/ ^ super cursorDown:n |
|
837 |
"/ ]. |
|
838 |
cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[ |
|
951 | 839 |
"/ no special action req'd |
840 |
^ super cursorDown:n |
|
841 |
]. |
|
979 | 842 |
|
951 | 843 |
n timesRepeat:[ |
844 |
wasOn := self hideCursor. |
|
979 | 845 |
rEnd := rangeEndLine+firstLineShown-1. |
846 |
cursorLine == rEnd ifTrue:[ |
|
847 |
self deleteLine:(rangeStartLine+firstLineShown-1). |
|
848 |
self insertLine:'' before:rEnd. |
|
951 | 849 |
] ifFalse:[ |
850 |
super cursorDown |
|
851 |
]. |
|
979 | 852 |
wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn. |
951 | 853 |
] |
854 |
||
979 | 855 |
"Modified: / 20.6.1998 / 20:29:39 / cg" |
926 | 856 |
! |
857 |
||
914 | 858 |
doCursorHome |
1420 | 859 |
"move the cursor to the home position" |
860 |
||
938 | 861 |
self cursorVisibleLine:1 col:1 |
862 |
"/ super cursorHome |
|
863 |
||
864 |
"Modified: / 10.6.1998 / 20:47:31 / cg" |
|
914 | 865 |
! |
866 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
867 |
doCursorLeft:n |
1420 | 868 |
"move the cursor to the left by n columns" |
869 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
870 |
n timesRepeat:[ |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
871 |
super cursorLeft |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
872 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
873 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
874 |
"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
|
875 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
876 |
|
914 | 877 |
doCursorNewLine |
1420 | 878 |
"move the cursor down to the next line (col remains unchanged)" |
879 |
||
931 | 880 |
super cursorDown:1 |
881 |
||
882 |
"Modified: / 10.6.1998 / 16:55:57 / cg" |
|
914 | 883 |
! |
884 |
||
885 |
doCursorReturn |
|
1420 | 886 |
"move the cursor down and left to the beginning to the next line" |
887 |
||
914 | 888 |
super cursorToBeginOfLine |
889 |
! |
|
890 |
||
926 | 891 |
doCursorRight:n |
1420 | 892 |
"move the cursor to the right by n columns" |
893 |
||
926 | 894 |
self cursorCol:(cursorCol + n) |
895 |
||
896 |
"Created: / 10.6.1998 / 15:10:08 / cg" |
|
897 |
! |
|
898 |
||
951 | 899 |
doCursorUp:n |
1420 | 900 |
"move the cursor up by n lines" |
901 |
||
979 | 902 |
|wasOn rStart| |
926 | 903 |
|
979 | 904 |
"/ rangeStartLine == 1 ifTrue:[ |
905 |
"/ ^ super cursorUp:n |
|
906 |
"/ ]. |
|
907 |
cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[ |
|
951 | 908 |
"/ no special action req'd |
909 |
^ super cursorUp:n |
|
910 |
]. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
911 |
n timesRepeat:[ |
951 | 912 |
wasOn := self hideCursor. |
979 | 913 |
rStart := rangeStartLine+firstLineShown-1. |
914 |
cursorLine == rStart ifTrue:[ |
|
915 |
(rangeEndLine+firstLineShown-1) <= list size ifTrue:[ |
|
916 |
self deleteLine:(rangeEndLine+firstLineShown-1). |
|
917 |
self insertLine:'' before:rStart. |
|
918 |
]. |
|
951 | 919 |
] ifFalse:[ |
920 |
super cursorUp |
|
921 |
]. |
|
922 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
923 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
924 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
925 |
"Created: / 11.6.1998 / 22:29:46 / cg" |
979 | 926 |
"Modified: / 20.6.1998 / 20:30:34 / cg" |
914 | 927 |
! ! |
928 |
||
1329 | 929 |
!TerminalView methodsFor:'initialization-shell'! |
930 |
||
931 |
startCommand:aCommand |
|
932 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
933 |
a shell is started. The command is started in the current directory. |
|
934 |
Also fork a reader process, to read the shells output and |
|
935 |
tell me, whenever something arrives" |
|
936 |
||
937 |
^ self startCommand:aCommand in:nil |
|
938 |
||
939 |
"Modified: / 20.7.1998 / 18:30:24 / cg" |
|
940 |
! |
|
941 |
||
942 |
startCommand:aCommand in:aDirectory |
|
943 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
944 |
a shell is started. If aDirectory is not nil, the command is |
|
945 |
executed in that directory. |
|
946 |
Also fork a reader process, to read the shells output and |
|
947 |
tell me, whenever something arrives" |
|
948 |
||
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
949 |
|pty slaveFD execFdArray blocked exitStatus |
2105
f62f8077568e
Close inherited filedescriptors when forking subprocess.
Stefan Vogel <sv@exept.de>
parents:
2078
diff
changeset
|
950 |
stxToCommandPipe commandToStxPipe cmd shell args env shellAndArgs| |
1329 | 951 |
|
952 |
shellCommand := aCommand. |
|
953 |
shellDirectory := aDirectory. |
|
954 |
||
955 |
self create. "/ need my windowID (to pass down in environment) |
|
956 |
||
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
957 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
958 |
"use two pipes to COMMAND.COM" |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
959 |
stxToCommandPipe := ExternalStream makePipe. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
960 |
stxToCommandPipe isNil ifTrue:[ |
1343 | 961 |
^ 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
|
962 |
]. |
1343 | 963 |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
964 |
commandToStxPipe := ExternalStream makePipe. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
965 |
commandToStxPipe isNil ifTrue:[ |
1343 | 966 |
^ 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
|
967 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
968 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
969 |
"/ pipe readSide is p at:1; |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
970 |
"/ writeSide is p at:2 |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
971 |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
972 |
slaveFD := (commandToStxPipe at:2) fileDescriptor. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
973 |
execFdArray := Array |
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
974 |
with:(stxToCommandPipe at:1) fileDescriptor "stdin" |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
975 |
with:slaveFD "stdout" |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
976 |
with:slaveFD. "stderr" |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
977 |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
978 |
outStream := commandToStxPipe at:1. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
979 |
inStream := stxToCommandPipe at:2. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
980 |
outStream buffered:false. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
981 |
inStream buffered:false. |
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
982 |
|
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
983 |
shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
984 |
shell := shellAndArgs at:1. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
985 |
args := (shellAndArgs at:2) ? ''. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
986 |
] ifFalse:[ |
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
987 |
"Use a pseudo-tty" |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
988 |
pty := ExternalStream makePTYPair. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
989 |
pty isNil ifTrue:[ |
1343 | 990 |
self warn:'Cannot open pty.'. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
991 |
^ self. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
992 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
993 |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
994 |
"/ pty at:1 is the master; |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
995 |
"/ pty at:2 is the slave |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
996 |
inStream := outStream := (pty at:1). |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
997 |
inStream buffered:false. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
998 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
999 |
self defineWindowSize. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1000 |
"/ fork a shell process on the slave-side |
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1001 |
slaveFD := (pty at:2) fileDescriptor. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1002 |
execFdArray := Array with:slaveFD with:slaveFD with:slaveFD. |
2105
f62f8077568e
Close inherited filedescriptors when forking subprocess.
Stefan Vogel <sv@exept.de>
parents:
2078
diff
changeset
|
1003 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1004 |
aCommand isNil ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1005 |
shell := OperatingSystem getEnvironment:'SHELL'. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1006 |
shell size == 0 ifTrue:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1007 |
shell := '/bin/sh'. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1008 |
]. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1009 |
cmd := shell asFilename baseName. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1010 |
args := (Array with:cmd). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1011 |
] ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1012 |
shell := '/bin/sh'. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1013 |
args := (Array with:'sh' with:'-c' with:aCommand). |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1014 |
]. |
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1015 |
env := Dictionary new. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1016 |
env at:'SHELL' put:shell. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1017 |
env at:'TERM' put:(self terminalType). |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1018 |
env at:'LINES' put:(numberOfLines printString). |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1019 |
env at:'COLUMNS' put:(numberOfColumns printString). |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1020 |
(device platformName = 'X11' and:[drawableId notNil]) ifTrue:[ |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1021 |
env at:'WINDOWID' put:(drawableId address printString). |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1022 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1023 |
]. |
1329 | 1024 |
|
1025 |
blocked := OperatingSystem blockInterrupts. |
|
1026 |
||
1027 |
shellPid := Processor |
|
1028 |
monitor:[ |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1029 |
OperatingSystem |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1030 |
exec:shell |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1031 |
withArguments:args |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1032 |
environment:env |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1033 |
fileDescriptors:execFdArray |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1034 |
fork:true |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1035 |
newPgrp:true |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1036 |
inDirectory:aDirectory. |
1329 | 1037 |
] |
1038 |
action:[:status | |
|
2192 | 1039 |
Debug ifTrue:[ |
1040 |
Transcript show:'pid:'; showCR:status pid. |
|
1041 |
Transcript show:'status:'; showCR:status status. |
|
1042 |
Transcript show:'code:'; showCR:status code. |
|
1043 |
Transcript show:'core:'; showCR:status core. |
|
1044 |
]. |
|
1045 |
status stillAlive ifFalse:[ |
|
1046 |
exitStatus := status. |
|
1047 |
OperatingSystem closePid:shellPid. |
|
1048 |
shellPid := nil. |
|
1049 |
self pushEvent:#shellTerminated |
|
1050 |
]. |
|
1329 | 1051 |
]. |
1052 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1053 |
blocked ifFalse:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1054 |
OperatingSystem unblockInterrupts |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1055 |
]. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1056 |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1057 |
"close the slave side of the pty/pipes (only used by the child)" |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1058 |
pty notNil ifTrue:[ |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1059 |
(pty at:2) close. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1060 |
]. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1061 |
|
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1062 |
commandToStxPipe notNil ifTrue:[ |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1063 |
(commandToStxPipe at:2) close. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1064 |
(stxToCommandPipe at:1) close. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1065 |
]. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1066 |
|
1329 | 1067 |
shellPid isNil ifTrue:[ |
1068 |
self warn:'Cannot start shell'. |
|
2449
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1069 |
outStream close. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1070 |
inStream close. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1071 |
inStream := outStream := nil. |
b16aece32285
Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents:
2448
diff
changeset
|
1072 |
^ self. |
1329 | 1073 |
]. |
1074 |
||
1075 |
self startReaderProcess. |
|
1076 |
||
1077 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1078 |
"Modified: / 5.5.1999 / 17:28:37 / cg" |
1329 | 1079 |
! |
1080 |
||
1081 |
startShell |
|
1082 |
"start a shell on a pseudo terminal in the current directory. |
|
1083 |
Also fork a reader process, to read the shells output and |
|
1084 |
tell me, whenever something arrives" |
|
1085 |
||
1086 |
^ self startCommand:nil |
|
1087 |
||
1088 |
" |
|
1089 |
VT100TerminalView openShell |
|
1090 |
" |
|
1091 |
||
1092 |
"Modified: / 20.7.1998 / 18:29:54 / cg" |
|
1093 |
! |
|
1094 |
||
1095 |
startShellIn:aDirectory |
|
1096 |
"start a shell on a pseudo terminal in some directory. |
|
1097 |
Also fork a reader process, to read the shells output and |
|
1098 |
tell me, whenever something arrives" |
|
1099 |
||
1100 |
^ self startCommand:nil in:aDirectory |
|
1101 |
||
1102 |
" |
|
1103 |
VT100TerminalView openShellIn:'/etc' |
|
1104 |
" |
|
1105 |
||
1106 |
"Modified: / 20.7.1998 / 18:29:46 / cg" |
|
1107 |
! ! |
|
1108 |
||
1109 |
!TerminalView methodsFor:'initialize / release'! |
|
914 | 1110 |
|
1111 |
closeDownShell |
|
1420 | 1112 |
"shut down my shell process and stop the background reader thread." |
1113 |
||
1009 | 1114 |
|pid| |
926 | 1115 |
|
1116 |
(pid := shellPid) notNil ifTrue:[ |
|
2192 | 1117 |
Debug ifTrue:[ |
1118 |
Transcript print:'killing shell pid='; showCR:pid. |
|
1119 |
]. |
|
926 | 1120 |
OperatingSystem terminateProcessGroup:pid. |
1121 |
OperatingSystem terminateProcess:pid. |
|
925 | 1122 |
Delay waitForSeconds:1. |
1123 |
shellPid notNil ifTrue:[ |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1124 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1125 |
OperatingSystem killProcessGroup:pid. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1126 |
]. |
926 | 1127 |
OperatingSystem killProcess:pid. |
925 | 1128 |
shellPid := nil. |
1129 |
]. |
|
926 | 1130 |
OperatingSystem closePid:pid. |
914 | 1131 |
]. |
1132 |
||
1009 | 1133 |
self stopReaderProcess. |
1134 |
||
914 | 1135 |
inStream notNil ifTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1136 |
inStream isStream ifTrue:[inStream close]. |
914 | 1137 |
inStream := nil |
1138 |
]. |
|
1139 |
outStream notNil ifTrue:[ |
|
1140 |
outStream close. |
|
1141 |
outStream := nil |
|
1142 |
]. |
|
924 | 1143 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1144 |
"Modified: / 5.5.1999 / 18:43:02 / cg" |
914 | 1145 |
! |
1146 |
||
1147 |
escapeSequences:codes |
|
1420 | 1148 |
"setup my escape sequences" |
1149 |
||
914 | 1150 |
|tree| |
1151 |
||
1152 |
tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new]. |
|
1153 |
||
1154 |
codes do:[:specEntry | |
|
1155 |
|sequence function| |
|
1156 |
||
1157 |
sequence := (specEntry at:1) withEscapes. |
|
1158 |
function := specEntry at:2. |
|
1159 |
||
1160 |
tree := escapeSequenceTree. |
|
1161 |
||
1162 |
sequence keysAndValuesDo:[:idx :char | |
|
1163 |
|followup| |
|
1164 |
||
1165 |
idx == sequence size ifTrue:[ |
|
1166 |
tree at:char put:function |
|
1167 |
] ifFalse:[ |
|
1168 |
followup := tree at:char ifAbsent:nil. |
|
1169 |
followup isNil ifTrue:[ |
|
1170 |
tree at:char put:(followup := IdentityDictionary new). |
|
1171 |
]. |
|
1172 |
tree := followup |
|
1173 |
] |
|
1174 |
] |
|
1175 |
]. |
|
918 | 1176 |
escapeLeadingChars := escapeSequenceTree keys asSet. |
1177 |
escapeLeadingChars add:(Character cr). |
|
1178 |
escapeLeadingChars add:(Character return). |
|
1179 |
escapeLeadingChars add:(Character backspace). |
|
1180 |
||
1181 |
escapeLeadingChars := escapeLeadingChars asArray |
|
1182 |
||
1183 |
"Modified: / 9.6.1998 / 19:43:12 / cg" |
|
914 | 1184 |
! |
1185 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1186 |
flushInput |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1187 |
|sensor| |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1188 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1189 |
"/ flush any leftover input-processing events |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1190 |
(sensor := self sensor) notNil ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1191 |
sensor flushEventsFor:self withType:#processInput:n:. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1192 |
] |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1193 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1194 |
"Modified: / 21.7.1998 / 19:00:13 / cg" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1195 |
"Created: / 5.5.1999 / 18:41:42 / cg" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1196 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1197 |
|
2163 | 1198 |
initStyle |
1199 |
super initStyle. |
|
1200 |
"/ self foregroundColor:Color green. |
|
1201 |
"/ self backgroundColor:Color black. |
|
1202 |
! |
|
1203 |
||
914 | 1204 |
initialize |
2194 | 1205 |
|
914 | 1206 |
super initialize. |
1207 |
||
1208 |
showMatchingParenthesis := false. |
|
1209 |
insertMode := false. |
|
936 | 1210 |
alwaysAppendAtEnd := false. |
944 | 1211 |
collectSize := 100. |
977 | 1212 |
st80Mode := false. |
1213 |
trimBlankLines := true. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1214 |
localEcho := false. |
2078 | 1215 |
inputTranslateCRToNL := false. |
2268 | 1216 |
autoWrapFlag := true. |
1217 |
"/ cursorType := #block. |
|
914 | 1218 |
|
926 | 1219 |
numberOfColumns := 80. |
979 | 1220 |
numberOfLines := 24. |
954 | 1221 |
rangeStartLine := 1. |
1222 |
rangeEndLine := numberOfLines. |
|
926 | 1223 |
|
2423
d2685982f94f
tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents:
2356
diff
changeset
|
1224 |
self setTab8. |
d2685982f94f
tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents:
2356
diff
changeset
|
1225 |
|
914 | 1226 |
self initializeKeyboardSequences. |
1227 |
list := OrderedCollection new:24 withAll:''. |
|
1228 |
||
1229 |
self initializeKeyboardMap. |
|
1230 |
||
1231 |
" |
|
1232 |
VT52TerminalView openShell |
|
926 | 1233 |
VT100TerminalView openShell |
914 | 1234 |
" |
926 | 1235 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1236 |
"Modified: / 5.5.1999 / 17:54:47 / cg" |
914 | 1237 |
! |
1238 |
||
1239 |
initializeKeyboardMap |
|
1349 | 1240 |
|keys ctrlKeys cmdKeys| |
914 | 1241 |
|
1349 | 1242 |
"/ setup my own keyboardMap, where control-keys |
1243 |
"/ (and some Cmd-keys) are not translated. |
|
914 | 1244 |
kbdMap := device keyboardMap copy. |
1349 | 1245 |
keys := kbdMap keys. |
914 | 1246 |
|
1349 | 1247 |
ctrlKeys := keys select:[:key | key startsWith:'Ctrl']. |
914 | 1248 |
ctrlKeys do:[:key | kbdMap removeKey:key]. |
950 | 1249 |
|
1349 | 1250 |
cmdKeys := keys select:[:key | key startsWith:'Cmd']. |
1251 |
cmdKeys do:[:key | |val| |
|
1252 |
val := kbdMap at:key. |
|
1253 |
val isSymbol ifTrue:[ |
|
1254 |
(#(Copy Paste SaveAs Print) includes:val) ifFalse:[ |
|
1255 |
kbdMap removeKey:key |
|
1256 |
] |
|
950 | 1257 |
] |
1258 |
]. |
|
914 | 1259 |
|
1260 |
kbdMap removeKey:#Delete ifAbsent:[]. |
|
1261 |
kbdMap removeKey:#BackSpace ifAbsent:[]. |
|
1262 |
||
1263 |
" |
|
1264 |
VT52TerminalView openShell |
|
1265 |
" |
|
950 | 1266 |
|
1349 | 1267 |
"Modified: / 29.4.1999 / 14:25:24 / cg" |
914 | 1268 |
! |
1269 |
||
1270 |
initializeKeyboardSequences |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1271 |
kbdSequences := (self anyKeyCodes) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1272 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1273 |
"Modified: / 5.5.1999 / 15:01:09 / cg" |
914 | 1274 |
! |
1275 |
||
1276 |
keyboardMap |
|
934 | 1277 |
"return my keyboard map. This has control keys removed and |
1278 |
those will be passed unchanged to the shell" |
|
1279 |
||
914 | 1280 |
^ kbdMap |
934 | 1281 |
|
1282 |
"Modified: / 10.6.1998 / 17:46:59 / cg" |
|
914 | 1283 |
! |
1284 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1285 |
reinitialize |
1833 | 1286 |
"reinit after a snapIn. |
1287 |
this is invoked (by the system thread) after a snapShot image restart" |
|
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1288 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1289 |
super reinitialize. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1290 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1291 |
shellPid := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1292 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1293 |
self stopReaderProcess. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1294 |
self flushInput. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1295 |
|
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1296 |
readerProcess := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1297 |
inStream := outStream := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1298 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1299 |
"/ 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
|
1300 |
[ |
1322 | 1301 |
"/ Delay waitForSeconds:0.5. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1302 |
self doClearEntireScreen. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1303 |
self cursorLine:1 col:1. |
1321
9a312fa98358
also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents:
1320
diff
changeset
|
1304 |
self contents:nil. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1305 |
self flash. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1306 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1307 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1308 |
"/ 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
|
1309 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1310 |
self startCommand:shellCommand in:shellDirectory. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1311 |
] forkAt:8 |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1312 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1313 |
"Modified: / 5.5.1999 / 18:41:55 / cg" |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1314 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1315 |
|
2155 | 1316 |
release |
1317 |
"release myself - shut down the shell, stop the reader thread." |
|
1318 |
||
2341
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1319 |
[self closeDownShell. |
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1320 |
self flushInput. |
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1321 |
] fork. |
2155 | 1322 |
super release |
1323 |
||
1324 |
"Modified: / 5.5.1999 / 18:42:55 / cg" |
|
1325 |
! |
|
1326 |
||
914 | 1327 |
startReaderProcess |
934 | 1328 |
"Start a reader process, which looks for the commands output, |
1009 | 1329 |
and sends me #processInput:n: events whenever something arrives." |
934 | 1330 |
|
914 | 1331 |
readerProcess isNil ifTrue:[ |
1332 |
readerProcess := [ |
|
1333 |
[ |
|
947 | 1334 |
self waitUntilVisible. |
1335 |
||
940 | 1336 |
Stream streamErrorSignal handle:[:ex | |
2450
ac2ab4cbfb79
More descriptive error messages
Stefan Vogel <sv@exept.de>
parents:
2449
diff
changeset
|
1337 |
Transcript show:'Terminal(PTY-reader) [error]: '; showCR:ex errorString. |
940 | 1338 |
] do:[ |
926 | 1339 |
[true] whileTrue:[ |
1340 |
Object abortSignal handle:[:ex | |
|
1341 |
self showCursor. |
|
1342 |
] do:[ |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1343 |
|n sensor| |
948 | 1344 |
|
926 | 1345 |
outStream readWait. |
2126 | 1346 |
sensor := self sensor. |
1347 |
(sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[ |
|
1323 | 1348 |
true "(sensor userEventCount > 10)" ifTrue:[ |
997 | 1349 |
"/ give terminalView a chance to |
1350 |
"/ send out the character. |
|
1323 | 1351 |
Delay waitForSeconds:0.01. |
997 | 1352 |
] |
926 | 1353 |
] ifFalse:[ |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1354 |
n := self readAnyAvailableData. |
945 | 1355 |
n > 0 ifTrue:[ |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1356 |
shellPid notNil ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1357 |
self waitForOutputToDrain. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1358 |
] |
945 | 1359 |
] ifFalse:[ |
1360 |
n == 0 ifTrue:[ |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1361 |
"/ 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
|
1362 |
"/ 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
|
1363 |
"/ and says its at the end (sigh) |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1364 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1365 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1366 |
Delay waitForSeconds:0.01 |
1323 | 1367 |
] ifFalse:[ |
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1368 |
outStream atEnd ifTrue:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1369 |
outStream close. outStream := nil. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1370 |
inStream close. inStream := nil. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1371 |
Processor activeProcess terminate. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1372 |
] ifFalse:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1373 |
"/ this should not happen. |
1323 | 1374 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1375 |
Delay waitForSeconds:0.05 |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1376 |
] |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1377 |
]. |
926 | 1378 |
] |
1379 |
] |
|
914 | 1380 |
] |
1381 |
] |
|
1382 |
] |
|
1383 |
] |
|
1384 |
] valueOnUnwindDo:[ |
|
1385 |
readerProcess := nil |
|
1386 |
] |
|
997 | 1387 |
] fork. "/ forkAt:9. |
1388 |
readerProcess name:'pty reader'. |
|
914 | 1389 |
] |
1390 |
||
1391 |
" |
|
934 | 1392 |
VT100TerminalView openShell |
914 | 1393 |
" |
926 | 1394 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1395 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
2077 | 1396 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
1009 | 1397 |
! |
1398 |
||
1399 |
stopReaderProcess |
|
1420 | 1400 |
"stop the background reader thread" |
1401 |
||
1009 | 1402 |
|sensor| |
1403 |
||
1404 |
readerProcess notNil ifTrue:[ |
|
1405 |
readerProcess terminate. |
|
1406 |
"/ give it a chance to really terminate |
|
1407 |
Processor yield. |
|
1408 |
readerProcess := nil |
|
1409 |
]. |
|
1410 |
||
1411 |
"/ flush any leftover input-processing events |
|
1412 |
(sensor := self sensor) notNil ifTrue:[ |
|
1413 |
sensor flushEventsFor:self withType:#processInput:n:. |
|
1414 |
] |
|
1415 |
"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
|
1416 |
! ! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
1417 |
|
914 | 1418 |
!TerminalView methodsFor:'menu'! |
1419 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1420 |
doReset |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1421 |
"reset the scroll-range; |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1422 |
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
|
1423 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1424 |
rangeStartLine := 1. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1425 |
rangeEndLine := numberOfLines. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1426 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1427 |
self normal. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1428 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1429 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1430 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1431 |
doSendInterrupt |
1420 | 1432 |
"send an INT-signal to the shell (UNIX only)" |
1433 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1434 |
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
|
1435 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1436 |
"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
|
1437 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1438 |
|
914 | 1439 |
editMenu |
1440 |
"return the views middleButtonMenu" |
|
1441 |
||
1347 | 1442 |
<resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)> |
914 | 1443 |
<resource: #programMenu> |
1444 |
||
2075 | 1445 |
|items m sensor| |
914 | 1446 |
|
1447 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
|
1448 |
items := #( |
|
1449 |
('Interrupt' doSendInterrupt) |
|
1182 | 1450 |
('-' ) |
1451 |
('Reset' doReset) |
|
914 | 1452 |
). |
1453 |
] ifFalse:[ |
|
1454 |
items := #( |
|
2075 | 1455 |
('Copy' copySelection Copy ) |
1456 |
('Paste' pasteOrReplace Paste ) |
|
914 | 1457 |
('-' ) |
2075 | 1458 |
('Font...' changeFont ) |
951 | 1459 |
('-' ) |
2448 | 1460 |
('Save As...' save SaveAs ) |
2075 | 1461 |
('Print' doPrint Print ) |
914 | 1462 |
). |
1347 | 1463 |
|
1464 |
"/ disabled - for now; |
|
1465 |
"/ need a more intelligent filtering of control characters. |
|
1466 |
"/ |
|
1467 |
"/ filterStream isNil ifTrue:[ |
|
1468 |
"/ items := items , #( |
|
1469 |
"/ ('-' ) |
|
2075 | 1470 |
"/ ('Start Save as ...' startSaveAs ) |
1471 |
"/ ('Start Print' startPrint ) |
|
1347 | 1472 |
"/ ) |
1473 |
"/ ] ifFalse:[ |
|
1474 |
"/ items := items , #( |
|
1475 |
"/ ('-' ) |
|
2075 | 1476 |
"/ ('Stop filter' stopFilter ) |
1347 | 1477 |
"/ ) |
1478 |
"/ ]. |
|
914 | 1479 |
]. |
1480 |
||
1481 |
m := PopUpMenu itemList:items resources:resources. |
|
1482 |
||
1483 |
self hasSelection not ifTrue:[ |
|
1484 |
m disable:#copySelection. |
|
1485 |
]. |
|
1486 |
^ m. |
|
1487 |
||
1347 | 1488 |
"Modified: / 29.4.1999 / 11:12:56 / cg" |
1489 |
! |
|
1490 |
||
1491 |
startSaveAs |
|
1492 |
"start saving all received data to some file" |
|
1493 |
||
1494 |
|fn| |
|
1495 |
||
1496 |
fn := Dialog requestFileName:'Save received data in file:'. |
|
1497 |
fn size > 0 ifTrue:[ |
|
1498 |
filterStream := fn asFilename writeStream |
|
1499 |
]. |
|
1500 |
||
1501 |
"Created: / 29.4.1999 / 11:06:29 / cg" |
|
1502 |
! |
|
1503 |
||
1504 |
stopFilter |
|
1505 |
"stop saving/printing of received data" |
|
1506 |
||
1507 |
filterStream close. |
|
1508 |
filterStream := nil. |
|
1509 |
||
1510 |
"Created: / 29.4.1999 / 11:07:49 / cg" |
|
1511 |
"Modified: / 29.4.1999 / 11:09:52 / cg" |
|
914 | 1512 |
! ! |
1513 |
||
940 | 1514 |
!TerminalView methodsFor:'misc'! |
914 | 1515 |
|
1516 |
removeTrailingBlankLines |
|
1517 |
^ self |
|
1518 |
! ! |
|
1519 |
||
1520 |
!TerminalView methodsFor:'processing - input'! |
|
1521 |
||
1420 | 1522 |
doNothing |
1523 |
"private - end of an ignored escape-sequence" |
|
1524 |
||
1525 |
self endOfSequence |
|
1526 |
||
1527 |
"Created: / 12.6.1998 / 20:40:43 / cg" |
|
1528 |
! |
|
1529 |
||
1530 |
endOfSequence |
|
1531 |
"private - reset state-machine at end of escape-sequence" |
|
1532 |
||
1533 |
state := 0. |
|
1534 |
||
1535 |
"Created: / 12.6.1998 / 20:39:52 / cg" |
|
1536 |
! |
|
1537 |
||
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1538 |
nextPutAll:aString |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1539 |
"/ self processInput:aString n:aString size |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1540 |
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
|
1541 |
|
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1542 |
"Created: / 27.7.1998 / 15:10:59 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1543 |
"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
|
1544 |
! |
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1545 |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1546 |
processInput:buffer n:count |
997 | 1547 |
|sensor| |
1548 |
||
1347 | 1549 |
filterStream notNil ifTrue:[ |
1550 |
filterStream nextPutAll:(buffer copyTo:count). |
|
1551 |
]. |
|
1552 |
||
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
1553 |
"/ self hideCursor. |
997 | 1554 |
|
1015 | 1555 |
"/ the following may not be too clean, but adds a lot of speed. |
1556 |
"/ instead of passing every individual character through the |
|
1557 |
"/ escape-state machine, collect chunks of non-control text |
|
1558 |
"/ when in state 0, and add them immediately to the pendingLines |
|
1559 |
"/ collection of the textCollectors asynchronous update mechanism. |
|
1560 |
"/ This helps a lot if you do something like "ls -lR /" ... |
|
1561 |
"/ For debugging the state machine, reenable the commented lines |
|
1562 |
"/ below. |
|
1563 |
||
1564 |
"/1 to:count do:[:i| |
|
1565 |
"/ self nextPut:(buffer at:i). |
|
1566 |
"/]. |
|
1567 |
"/self showCursor. |
|
1568 |
"/^ self. |
|
1569 |
||
1570 |
access critical:[ |
|
2191 | 1571 |
|index controlCharIndex stringWithOutControl crnlFollows| |
997 | 1572 |
|
2191 | 1573 |
index := 1. |
1574 |
[index <= count] whileTrue:[ |
|
1015 | 1575 |
(state == 0) ifTrue:[ |
1576 |
"/ in initial state. |
|
1577 |
"/ quick scan forward for next control character ... |
|
2191 | 1578 |
controlCharIndex := buffer indexOfControlCharacterStartingAt:index. |
1579 |
controlCharIndex > count ifTrue:[controlCharIndex := 0]. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1580 |
|
2191 | 1581 |
controlCharIndex == 0 ifTrue:[ |
1015 | 1582 |
"/ no control characters - simply append all |
1583 |
"/ to the outstanding lines ... |
|
2191 | 1584 |
stringWithOutControl := buffer copyFrom:index to:count. |
1585 |
index := count + 1. "/ leave loop. |
|
997 | 1586 |
crnlFollows := false. |
1015 | 1587 |
] ifFalse:[ |
2191 | 1588 |
controlCharIndex > index ifTrue:[ |
1589 |
stringWithOutControl := buffer copyFrom:index to:controlCharIndex-1. |
|
1590 |
index := controlCharIndex. "/ proceed withcontrol character |
|
1015 | 1591 |
crnlFollows := false. |
2191 | 1592 |
index < (count - 1) ifTrue:[ |
1593 |
(buffer at:index) == Character return ifTrue:[ |
|
1594 |
(buffer at:index+1) == Character nl ifTrue:[ |
|
1015 | 1595 |
crnlFollows := true. |
2191 | 1596 |
index := index + 2. |
1015 | 1597 |
] |
997 | 1598 |
] |
1015 | 1599 |
]. |
1600 |
] |
|
1601 |
]. |
|
997 | 1602 |
]. |
1603 |
||
2191 | 1604 |
stringWithOutControl notNil ifTrue:[ |
2356 | 1605 |
"/ self endEntry. |
1606 |
||
2268 | 1607 |
"/ characterwise, for correct wrap handling at line end |
2356 | 1608 |
|
1609 |
(cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[ |
|
2268 | 1610 |
self endEntry. |
1611 |
stringWithOutControl do:[:eachCharacter | |
|
1612 |
self nextPut:eachCharacter. |
|
1613 |
self endEntry |
|
1614 |
]. |
|
2356 | 1615 |
crnlFollows ifTrue:[ |
1616 |
self nextPut:Character return. |
|
1617 |
self nextPut:Character nl. |
|
1618 |
]. |
|
1619 |
self endEntry. |
|
1620 |
stringWithOutControl := nil. |
|
997 | 1621 |
] ifFalse:[ |
2356 | 1622 |
|
1623 |
Debug ifTrue:[ |
|
1624 |
Transcript showCR:'String:<', stringWithOutControl, '>'. |
|
1625 |
]. |
|
1626 |
currentEmphasis notNil ifTrue:[ |
|
1627 |
stringWithOutControl := stringWithOutControl emphasizeAllWith:currentEmphasis |
|
1628 |
]. |
|
1629 |
||
1630 |
outstandingLine size > 0 ifTrue:[ |
|
1631 |
outstandingLine := outstandingLine , stringWithOutControl. |
|
1015 | 1632 |
] ifFalse:[ |
2356 | 1633 |
outstandingLine := stringWithOutControl. |
1015 | 1634 |
]. |
2356 | 1635 |
crnlFollows ifTrue:[ |
1636 |
outstandingLines isNil ifTrue:[ |
|
1637 |
outstandingLines := OrderedCollection with:outstandingLine |
|
1638 |
] ifFalse:[ |
|
1639 |
outstandingLines add:outstandingLine. |
|
1640 |
]. |
|
1641 |
outstandingLine := ''. |
|
1642 |
]. |
|
1643 |
stringWithOutControl := nil. |
|
997 | 1644 |
|
2356 | 1645 |
collecting ifTrue:[ |
1646 |
flushPending ifFalse:[ |
|
1647 |
self installDelayedUpdate |
|
1648 |
] ifTrue:[ |
|
1649 |
"/ outstandingLines size > collectSize ifTrue:[ |
|
1650 |
"/ self endEntry |
|
1651 |
"/ ] |
|
1652 |
] |
|
1653 |
] ifFalse:[ |
|
1654 |
self endEntry |
|
1655 |
]. |
|
1015 | 1656 |
]. |
997 | 1657 |
] ifFalse:[ |
1015 | 1658 |
"/ no chunk to append (in an escape sequence) |
1659 |
"/ must handle individual characters |
|
1660 |
"/ 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
|
1661 |
|
2207 | 1662 |
self nextPut:(buffer at:index). |
2191 | 1663 |
index := index + 1. |
1664 |
[state ~~ 0 and:[index <= count]] whileTrue:[ |
|
2207 | 1665 |
self nextPut:(buffer at:index). |
2191 | 1666 |
index := index + 1. |
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1667 |
] |
1015 | 1668 |
] |
1669 |
]. |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1670 |
]. |
948 | 1671 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1672 |
state == 0 ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1673 |
(sensor := self sensor) notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1674 |
"/ 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
|
1675 |
"/ enforce update of the view (asynchronous) |
997 | 1676 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1677 |
(sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
997 | 1678 |
self endEntry. |
1679 |
self showCursor. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1680 |
"/ self makeCursorVisible. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1681 |
] ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1682 |
"/ 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
|
1683 |
"/ 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
|
1684 |
"/ 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
|
1685 |
"/ 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
|
1686 |
"/ collectSize lines. |
1015 | 1687 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1688 |
outstandingLines size > collectSize ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1689 |
self endEntry. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1690 |
self showCursor. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1691 |
|
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1692 |
"/ 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
|
1693 |
windowGroup notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1694 |
windowGroup processRealExposeEventsFor:self. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1695 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1696 |
]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1697 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1698 |
]. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1699 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1700 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1701 |
"Created: / 10.6.1998 / 17:26:09 / cg" |
1347 | 1702 |
"Modified: / 29.4.1999 / 11:08:48 / cg" |
2076 | 1703 |
"Modified: / 28.1.2002 / 20:41:36 / micha" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1704 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1705 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1706 |
readAnyAvailableData |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1707 |
"read data from the stream, |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1708 |
and sends me #processInput:n: events if something arrived. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1709 |
Returns the amount of data read." |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1710 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1711 |
|buffer n bufferSize| |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1712 |
|
1370
165f57ba2b12
care for closed stream in readAnyAvail
Claus Gittinger <cg@exept.de>
parents:
1366
diff
changeset
|
1713 |
outStream isNil ifTrue:[^ 0]. |
165f57ba2b12
care for closed stream in readAnyAvail
Claus Gittinger <cg@exept.de>
parents:
1366
diff
changeset
|
1714 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1715 |
bufferSize := 512. "/ 1024. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1716 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1717 |
buffer := String new:bufferSize. |
1371
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1718 |
ExternalStream readErrorSignal handle:[:ex | |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1719 |
n := 0 |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1720 |
] do:[ |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1721 |
n := outStream nextAvailableBytes:bufferSize into:buffer startingAt:1. |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1722 |
]. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1723 |
n > 0 ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1724 |
self pushEvent:#processInput:n: with:buffer with:n. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1725 |
]. |
1371
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1726 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1727 |
^ n |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1728 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1729 |
"Created: / 5.5.1999 / 17:57:39 / cg" |
1371
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1730 |
"Modified: / 8.5.1999 / 20:14:14 / cg" |
2077 | 1731 |
"Modified: / 28.1.2002 / 21:10:25 / micha" |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1732 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1733 |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1734 |
sync |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1735 |
self waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1736 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1737 |
"Created: / 27.7.1998 / 23:49:44 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1738 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1739 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1740 |
waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1741 |
|sensor| |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1742 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1743 |
sensor := self sensor. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1744 |
(sensor notNil and:[sensor userEventCount > 30]) ifTrue:[ |
1323 | 1745 |
[sensor userEventCount > 5] whileTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1746 |
"/ give terminalView a chance to |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1747 |
"/ catch up. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1748 |
Delay waitForSeconds:0.1. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1749 |
] |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1750 |
]. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1751 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1752 |
"Created: / 27.7.1998 / 23:47:22 / cg" |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1753 |
"Modified: / 5.5.1999 / 18:51:00 / cg" |
914 | 1754 |
! ! |
1755 |
||
1756 |
!TerminalView methodsFor:'queries'! |
|
1757 |
||
1758 |
preferredExtent |
|
1420 | 1759 |
"return my preferred extent - this is computed from my numberOfLines, |
1760 |
numberOfCols and font size" |
|
1761 |
||
2268 | 1762 |
^ (fontWidth * self class defaultNumberOfColumns + (leftMargin + margin * 2)) |
951 | 1763 |
@ |
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1764 |
((self heightForLines:self class defaultNumberOfLines) + 8) |
926 | 1765 |
|
979 | 1766 |
"Modified: / 20.6.1998 / 20:06:57 / cg" |
929 | 1767 |
! |
1768 |
||
1769 |
terminalType |
|
1420 | 1770 |
"returns a string describing this terminal (usually, this is |
1771 |
passed down to the shell as TERM environment variable). |
|
1772 |
Here, 'dump' is returned." |
|
1773 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
1774 |
^ 'dump' |
929 | 1775 |
|
1776 |
"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
|
1777 |
"Modified: / 5.5.1999 / 11:22:32 / cg" |
914 | 1778 |
! ! |
1779 |
||
1780 |
!TerminalView methodsFor:'selection handling'! |
|
1781 |
||
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1782 |
autoMoveCursorToEndOfSelection |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1783 |
"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
|
1784 |
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
|
1785 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1786 |
^ false |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1787 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1788 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1789 |
|
914 | 1790 |
paste:someText |
1791 |
"paste - redefined to send the chars to the shell instead |
|
1792 |
of pasting into the view" |
|
1793 |
||
950 | 1794 |
|s nLines| |
1795 |
||
1796 |
s := someText. |
|
1797 |
s isString ifTrue:[ |
|
1798 |
s := s asStringCollection |
|
1799 |
] ifFalse:[ |
|
1800 |
(s isKindOf:StringCollection) ifFalse:[ |
|
1801 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
1802 |
^ self |
|
1803 |
] |
|
1804 |
]. |
|
1805 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
1806 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
|
1807 |
s keysAndValuesDo:[:idx :line | |
|
1404 | 1808 |
line notNil ifTrue:[inStream nextPutAll:line]. |
950 | 1809 |
idx ~~ nLines ifTrue:[ |
1810 |
inStream nextPut:(Character return). |
|
1811 |
] |
|
1812 |
]. |
|
1813 |
||
1814 |
"Modified: / 12.6.1998 / 22:12:47 / cg" |
|
914 | 1815 |
! ! |
1816 |
||
1817 |
!TerminalView class methodsFor:'documentation'! |
|
1818 |
||
1819 |
version |
|
2450
ac2ab4cbfb79
More descriptive error messages
Stefan Vogel <sv@exept.de>
parents:
2449
diff
changeset
|
1820 |
^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.112 2003-02-27 14:45:44 stefan Exp $' |
914 | 1821 |
! ! |
2205 | 1822 |
|
1823 |
TerminalView initialize! |