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