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