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