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