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