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