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