author | Claus Gittinger <cg@exept.de> |
Sun, 01 Jun 2014 17:41:38 +0200 | |
changeset 4596 | dc86ba455936 |
parent 4595 | b6bca31ea81b |
child 4597 | c0c195dcf0c1 |
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 |
|
4317 | 19 |
filterStream recorderStream localEcho translateNLToCRNL |
4324 | 20 |
inputTranslateCRToNL inputTranslateBackspaceToDelete autoWrapFlag |
21 |
masterWindow alternateKeypadMode noColors |
|
4593 | 22 |
sizeOfOutstandingInputToBeProcessed lineEditMode lineBuffer |
23 |
lineBufferCursorPosition lineBufferHistory |
|
24 |
lineBufferHistoryPosition' |
|
4288 | 25 |
classVariableNames:'Debug DebugKeyboard' |
2268 | 26 |
poolDictionaries:'' |
27 |
category:'Views-TerminalViews' |
|
914 | 28 |
! |
29 |
||
30 |
!TerminalView class methodsFor:'documentation'! |
|
31 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
32 |
copyright |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
33 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
34 |
COPYRIGHT (c) 1998 by eXept Software AG |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
35 |
All Rights Reserved |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
36 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
hereby transferred. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
43 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
44 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
45 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
46 |
|
914 | 47 |
documentation |
48 |
" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
49 |
I provide terminal functionality, by interpreting data |
1418 | 50 |
arriving from some stream (typically connected to a command interpreter |
51 |
via a pty, or another system via a modem) |
|
52 |
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
|
53 |
|
1418 | 54 |
I am abstract providing general functionality |
55 |
- concrete terminal characteristics are defined by concrete subclasses |
|
56 |
(see VT52TerminalView, VT100TerminalView). |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
57 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
58 |
Concrete applications are: |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
59 |
consoles (VT100TerminalView), |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
60 |
telnet-views (see TelnetTool) |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
61 |
editor wrappers (if you like emacs/vi) |
914 | 62 |
|
4223 | 63 |
Although my class protocol includes common startup protocol |
1418 | 64 |
(to open a terminalView with a shell or on the output of a command), |
4223 | 65 |
I can be used as a widget within an application (modem software). |
1418 | 66 |
|
914 | 67 |
[author:] |
68 |
Claus Gittinger |
|
915 | 69 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
70 |
[instance variables:] |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
71 |
inStream stream where keyboard input is |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
72 |
sent to (connected to shells or commands input) |
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 |
outStream stream where the output of the |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
75 |
shell or command arrives |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
76 |
(read here and displayed in the view) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
77 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
78 |
readerProcess process which reads commands |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
79 |
output and sends it to the view |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
80 |
|
2204 | 81 |
[class variables]: |
82 |
Debug := true trace incoming characters |
|
83 |
||
84 |
||
915 | 85 |
[start with:] |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
86 |
VT52TerminalView open |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
87 |
VT100TerminalView open |
915 | 88 |
VT52TerminalView openShell |
919 | 89 |
VT100TerminalView openShell |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
90 |
VT100TerminalView openOnCommand:'ls -l' |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
91 |
VT100TerminalView openOnCommand:'dir' |
1418 | 92 |
|
93 |
[see also:] |
|
94 |
TelNetTool |
|
914 | 95 |
" |
3758 | 96 |
! |
97 |
||
98 |
example |
|
99 |
" |
|
100 |
|terminal in out inputLine| |
|
101 |
||
102 |
in := InternalPipeStream new. |
|
103 |
out := InternalPipeStream new. |
|
104 |
||
105 |
terminal := TerminalView openOnInput:in output:out. |
|
106 |
terminal localEcho:true. |
|
107 |
terminal inputTranslateCRToNL:true. |
|
108 |
||
109 |
out nextPutLine:'Hello world - please type at me:'. |
|
110 |
||
111 |
[ |
|
112 |
inputLine := in nextLine asString. |
|
113 |
inputLine ~= '#exit' ifTrue:[ |
|
114 |
out nextPutLine:(Compiler evaluate:inputLine) printString. |
|
115 |
]. |
|
116 |
inputLine = '#exit' |
|
117 |
] whileFalse. |
|
118 |
||
119 |
terminal topView destroy. |
|
120 |
" |
|
914 | 121 |
! ! |
122 |
||
2207 | 123 |
!TerminalView class methodsFor:'initialization'! |
2205 | 124 |
|
125 |
initialize |
|
2207 | 126 |
|
4294 | 127 |
Debug := DebugKeyboard := false. |
2207 | 128 |
|
4294 | 129 |
" |
130 |
self initialize |
|
131 |
" |
|
2205 | 132 |
! ! |
133 |
||
1052 | 134 |
!TerminalView class methodsFor:'defaults'! |
135 |
||
136 |
defaultIcon |
|
4030 | 137 |
"This resource specification was automatically generated |
138 |
by the ImageEditor of ST/X." |
|
139 |
||
140 |
"Do not manually edit this!! If it is corrupted, |
|
141 |
the ImageEditor may not be able to read the specification." |
|
142 |
||
143 |
" |
|
144 |
self defaultIcon inspect |
|
145 |
ImageEditor openOnClass:self andSelector:#defaultIcon |
|
146 |
Icon flushCachedIcons |
|
147 |
" |
|
148 |
||
149 |
<resource: #image> |
|
4028 | 150 |
|
4030 | 151 |
^Icon |
152 |
constantNamed:'TerminalView class defaultIcon' |
|
153 |
ifAbsentPut:[(Depth8Image new) width: 48; height: 36; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
154 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@C@0LC@0LC@0LC@0LC@0LC@0LC@0LC@0LC@0L@@@@@@@@@ |
|
155 |
@@@@@@@@@@@@@@@@@@LDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PC@@@@@@@@@@@@@@@@@@@@@@@@@0PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PD |
|
156 |
@ H@@@@@@@@@@@@@@@@@@@@@@0PD@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDDA@PD@ H@@@@@@@@@@@@@@@@@@@@@@0PD@PDA@PDA@PDA@PDA@PDA@PDA@PDA |
|
157 |
@PDAA@PD@ HB@@@@@@@@@@@@@@@@@@@@@0PD@PDEAPDE@PDE@PTEAPTA@PTA@PDA@PDAA@PD@ HB@@@@@@@@@@@@@@@@@@@@@0PD@PDA@PDA@PDA@PDA@PDA |
|
158 |
@PDA@PDA@PDAA@PD@ HB@ @@@@@@@@@@@@@@@@@@@0PD@PDEAPTE@PTE@PTEAPDA@PDA@PDA@PDAA@PD@ HB@ @@@@@@@@@@@@@@@@@@@0PD@PDA@PDA@PDA |
|
159 |
@PDA@PDA@PDA@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@@0PD@PDEAPTEAPTEAPTE@PTEAPTE@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@@0PD@PDA |
|
160 |
@PDA@PDA@PDA@PDA@PDA@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@@0PD@PDEAPTAAPTEAPDEAPDAAPTE@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@ |
|
161 |
@0PD@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@@0PD@PDE@PDA@PDA@PDA@PDA@PDA@PDA@PDAA@PD@ HB@ H@@@@@@@@@ |
|
162 |
@@@@@@@@@0PD@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@@0PD@PDEAPTE@PTAAPTE@PTA@PDA@PDA@PDAA@PD@ HB@ H@ |
|
163 |
@@@@@@@@@@@@@@@@@0PD@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDAA@PD@ HB@ H@@@@@@@@@@@@@@@@@@0PD@PDE@PTEAPTA@PDA@PDA@PDA@PDA@PDAA@PD |
|
164 |
@ HB@ H@@@@@@@@@@@@@@@@@@0PDA@DA@PDA@PDA@PDA@PDA@PDA@PDA@PDDA@PD@ HB@ @@@@@@@@@@@@@@@@@@@0PDA@PDA@PDA@PDA@PDA@PDA@PDA@PD |
|
165 |
A@PDA@PD@ HB@@@@@@@@@@@@@@@@@@@@@@LDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PB@ H@@@@@@@@@@@@@@@@@@@@@@@@@@@HB@ HB@ HB@ HB@ HB |
|
166 |
@ HB@ HB@ HB@ HC@0LB@ @@@@@@@@@@@@@@@@@@@@@@@@@C@0LC@0LC@0LC@0LC@0LC@0LC@0LC@0LC@0HB@ @@@@@@@@@@@@@@@@@@@@@@@@HB@ HB@ HB |
|
167 |
@ HB@ HB@ HB@ HB@ HB@ HB@ HB@ @@@@@@@@@@@@@@@@@@@@@BA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PD@ HB@ LC@@LC@@@@@@@@@@@@@@@BA@PD |
|
168 |
A@PDA@PDA@PDA@PDA@PD@@@@@@@@@@PD@ HB@ @@@0@@@0@@@@@@@@@@@ HB@ HB@ HB@ HB@ HB@ HB@ HB@ HB@ HBA@PD@ HB@@@@@@@C@@@@@@@@@@@B |
|
169 |
A@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PB@ HB@ @@@@@@@@L@@@@@@@@@@@HDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@HB@@@@@@@@@ HB@ HB@@@@ |
|
170 |
@@@@@@HDA@TEAPTEAPTEAPTEAPTEAPTEAPTDA@PDA@HB@@@@@ HB@ HC@0LB@@@@@@@@@ PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PD@ H@@@@B@ PDA@HB |
|
171 |
@0LB@@@@@@@BA@PEAPTEAPTEAPTEAPTEAPTEAPTEAPPDA@PB@ @@@@@BA@PDA@PC@0H@@@@@@@HDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@PDA@HB@@@@@@@B |
|
172 |
@0LC@0LB@ @@@@@@@@HB@ HB@ HB@ HB@ HB@ HB@ HB@ HB@ HB@ H@@@@@@@@B@ HB@ HB@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
173 |
@@@@@@@@@@@@@@@@@@@@@@@@') ; 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:' |
|
174 |
@@@@@@@@@O???>@@@_????@@@?????0@@?????0@@?????8@@?????8@@?????<@@?????<@@?????>@@?????>@@?????>@@?????>@@?????>@@?????>@ |
|
175 |
@?????>@@?????>@@?????>@@?????>@@?????<@@?????8@@_????0@@C????<@@A????<@@C????<@@O?????X@O????<$@?????8HA????? PC????8G8 |
|
176 |
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
|
177 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
178 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
179 |
defaultNumberOfColumns |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
180 |
^ 80 |
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 |
"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
|
183 |
"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
|
184 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
185 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
186 |
defaultNumberOfLines |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
187 |
^ 25 |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
188 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
189 |
"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
|
190 |
"Modified: / 4.8.1998 / 17:48:31 / cg" |
1052 | 191 |
! ! |
192 |
||
972 | 193 |
!TerminalView class methodsFor:'opening'! |
914 | 194 |
|
928 | 195 |
open |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
196 |
^ self openShell |
928 | 197 |
|
198 |
" |
|
199 |
VT100TerminalView open |
|
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
200 |
VT52TerminalView open |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
201 |
TerminalView open |
928 | 202 |
" |
203 |
||
204 |
"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
|
205 |
"Modified: / 9.7.1998 / 17:55:37 / cg" |
928 | 206 |
! |
207 |
||
914 | 208 |
openDummy |
972 | 209 |
"for testing purposes only - opens a dummy tty-view, which simply |
210 |
echoes whatever is typed in" |
|
211 |
||
914 | 212 |
|in vt52| |
213 |
||
214 |
vt52 := self new. |
|
215 |
in := ForwardingStream on:''. |
|
216 |
||
217 |
in fwdStream:vt52. |
|
218 |
vt52 inStream:in. |
|
219 |
vt52 outStream:in. |
|
220 |
vt52 open |
|
221 |
||
222 |
" |
|
223 |
self openDummy |
|
224 |
" |
|
225 |
! |
|
226 |
||
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
227 |
openOnCommand:aCommandString |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
228 |
"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
|
229 |
(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
|
230 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
231 |
^ self openOnCommand:aCommandString onExit:[] |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
232 |
|
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 |
VT100TerminalView openOnCommand:'ls -l' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
235 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
236 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
237 |
"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
|
238 |
"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
|
239 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
240 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
241 |
openOnCommand:aCommandString onExit:aBlock |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
242 |
"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
|
243 |
(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
|
244 |
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
|
245 |
|
4254 | 246 |
|top scr vt| |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
247 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
248 |
top := StandardSystemView new. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
249 |
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
|
250 |
scr origin:0.0@0.0 corner:1.0@1.0. |
4220 | 251 |
vt := scr scrolledView. |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
252 |
|
4220 | 253 |
vt masterWindow: top. |
254 |
vt startCommand:aCommandString. |
|
255 |
vt shellTerminateAction:[ |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
256 |
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
|
257 |
]. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
258 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
259 |
top extent:(scr preferredExtent). |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
260 |
top label:('executing: "' , aCommandString , '"'). |
1014 | 261 |
top iconLabel:'command'. |
1052 | 262 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
263 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
264 |
|
4220 | 265 |
^ vt |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
266 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
267 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
268 |
VT100TerminalView openOnCommand:'ls -lR' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
269 |
VT100TerminalView openOnCommand:'vi /etc/hosts' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
270 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
271 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
272 |
"Created: / 9.7.1998 / 17:54:34 / cg" |
1052 | 273 |
"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
|
274 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
275 |
|
1014 | 276 |
openOnInput:inStream output:outStream |
972 | 277 |
"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
|
278 |
kind of socket or pty). |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
279 |
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
|
280 |
from outStream is displayed in the terminal view. |
972 | 281 |
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
|
282 |
or telnet views (if connected to a modem, a com-program can also be |
972 | 283 |
implemented this way)." |
284 |
||
4268 | 285 |
|top vt| |
972 | 286 |
|
287 |
top := StandardSystemView new. |
|
4268 | 288 |
vt := self openOnInput:inStream output:outStream in:top. |
289 |
vt masterWindow:top. |
|
2078 | 290 |
|
4268 | 291 |
top extent:(vt preferredExtent). |
2078 | 292 |
top label:'shell'. |
293 |
top iconLabel:'shell'. |
|
294 |
top icon:(self defaultIcon). |
|
295 |
top open. |
|
4268 | 296 |
^ vt |
2078 | 297 |
|
298 |
"Modified: / 5.5.1999 / 17:25:59 / cg" |
|
299 |
! |
|
300 |
||
301 |
openOnInput:inStream output:outStream in:aView |
|
2778 | 302 |
"open a terminalView on the given streams |
303 |
(which are typically some kind of socket or pty). |
|
2078 | 304 |
Keys pressed are sent to inStream, text appearing |
305 |
from outStream is displayed in the terminal view. |
|
306 |
This can be used to implement things like rlogin |
|
307 |
or telnet views (if connected to a modem, a com-program can also be |
|
308 |
implemented this way)." |
|
309 |
||
310 |
|scr vt| |
|
311 |
||
312 |
scr := ScrollableView for:self in:aView. |
|
972 | 313 |
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
|
314 |
vt := scr scrolledView. |
972 | 315 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
316 |
vt inStream:inStream. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
317 |
vt outStream:outStream. |
2778 | 318 |
vt startReaderProcessWhenVisible. |
972 | 319 |
|
2078 | 320 |
^ scr |
974 | 321 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
322 |
"Modified: / 5.5.1999 / 17:25:59 / cg" |
972 | 323 |
! |
324 |
||
914 | 325 |
openShell |
972 | 326 |
"start a shell on a pseudo-TTY, open a terminalView on it |
327 |
(i.e. this is kind of an xterm)" |
|
328 |
||
997 | 329 |
^ self openShellIn:nil |
992 | 330 |
|
331 |
" |
|
332 |
VT100TerminalView openShell |
|
333 |
" |
|
334 |
||
997 | 335 |
"Modified: / 21.7.1998 / 18:24:55 / cg" |
992 | 336 |
! |
337 |
||
338 |
openShellIn:aDirectory |
|
339 |
"start a shell on a pseudo-TTY, open a terminalView on it |
|
340 |
(i.e. this is kind of an xterm)" |
|
341 |
||
2163 | 342 |
| top scr vt lbl| |
914 | 343 |
|
344 |
top := StandardSystemView new. |
|
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
345 |
scr := HVScrollableView for:self in:top. |
914 | 346 |
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
|
347 |
vt := scr scrolledView. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
348 |
vt startShellIn:aDirectory. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
349 |
vt shellTerminateAction:[top destroy]. |
4220 | 350 |
vt masterWindow: top. |
914 | 351 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
352 |
lbl := OperatingSystem isUNIXlike ifTrue:['shell'] ifFalse:['dos']. |
940 | 353 |
top extent:(scr preferredExtent). |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
354 |
top label:lbl. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
355 |
top iconLabel:lbl. |
1052 | 356 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
357 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
358 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
359 |
^ vt |
914 | 360 |
|
361 |
" |
|
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
362 |
TerminalView openShellIn:'/etc' |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
363 |
VT52TerminalView openShellIn:'/etc' |
992 | 364 |
VT100TerminalView openShellIn:'/etc' |
914 | 365 |
" |
946 | 366 |
|
992 | 367 |
"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
|
368 |
"Modified: / 5.5.1999 / 17:27:10 / cg" |
914 | 369 |
! ! |
370 |
||
972 | 371 |
!TerminalView class methodsFor:'queries'! |
372 |
||
373 |
isVisualStartable |
|
374 |
"returns whether this application class can be started via #open" |
|
375 |
||
376 |
self == TerminalView ifTrue:[^ false]. |
|
377 |
^ true |
|
378 |
||
379 |
"Created: / 10.6.1998 / 15:48:43 / cg" |
|
380 |
! ! |
|
381 |
||
914 | 382 |
!TerminalView methodsFor:'accessing'! |
383 |
||
2076 | 384 |
filterStream:something |
385 |
"set a filter stream; if not nil, it gets all incoming data via nextPutAll:. |
|
4317 | 386 |
Added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt |
387 |
incoming data by some other program" |
|
2076 | 388 |
|
389 |
filterStream := something. |
|
390 |
||
391 |
"Created: / 28.1.2002 / 20:56:04 / micha" |
|
392 |
"Modified: / 28.1.2002 / 20:56:11 / micha" |
|
393 |
! |
|
394 |
||
914 | 395 |
inStream |
2954 | 396 |
"set the stream, which gets all input data (i.e. keyboard input)" |
914 | 397 |
|
2075 | 398 |
^ inStream |
399 |
! |
|
914 | 400 |
|
401 |
inStream:something |
|
2954 | 402 |
"return the stream, which gets all input data (i.e. keyboard input)" |
914 | 403 |
|
2075 | 404 |
inStream := something. |
405 |
! |
|
914 | 406 |
|
4324 | 407 |
inputTranslateBackspaceToDelete |
408 |
^ inputTranslateBackspaceToDelete |
|
409 |
! |
|
410 |
||
411 |
inputTranslateBackspaceToDelete:aBoolean |
|
412 |
inputTranslateBackspaceToDelete := aBoolean. |
|
413 |
! |
|
414 |
||
2078 | 415 |
inputTranslateCRToNL |
416 |
^ inputTranslateCRToNL |
|
417 |
! |
|
418 |
||
4266 | 419 |
inputTranslateCRToNL:aBoolean |
420 |
inputTranslateCRToNL := aBoolean. |
|
2078 | 421 |
! |
422 |
||
4593 | 423 |
lineEditMode:something |
424 |
lineEditMode := something. |
|
425 |
! |
|
426 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
427 |
localEcho:aBoolean |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
428 |
"enable/disable local echo" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
429 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
430 |
localEcho := aBoolean |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
431 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
432 |
"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
|
433 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
434 |
|
4220 | 435 |
masterWindow:something |
436 |
masterWindow := something. |
|
437 |
! |
|
438 |
||
4299 | 439 |
noColors |
440 |
^ noColors |
|
441 |
! |
|
442 |
||
443 |
noColors:something |
|
444 |
noColors := something. |
|
445 |
! |
|
446 |
||
914 | 447 |
outStream |
2954 | 448 |
"return the stream, which is used to present data in the view (i.e. shell output)" |
914 | 449 |
|
2075 | 450 |
^ outStream |
451 |
! |
|
914 | 452 |
|
453 |
outStream:something |
|
2954 | 454 |
"set the stream, which is used to present data in the view (i.e. shell output)" |
914 | 455 |
|
2075 | 456 |
outStream := something. |
457 |
! |
|
946 | 458 |
|
1004 | 459 |
readerProcess |
460 |
^ readerProcess |
|
461 |
! |
|
462 |
||
4317 | 463 |
recorderStream:aWriteStream |
464 |
"set a recorder stream; if not nil, it gets all user input (keyboard) data via nextPut:. |
|
465 |
Added to allow saving of user input to a file, for later replay of a session" |
|
466 |
||
467 |
recorderStream := aWriteStream. |
|
468 |
! |
|
469 |
||
946 | 470 |
shellTerminateAction:aBlock |
471 |
"set the block which is evaluated when the shell terminates. |
|
472 |
Can be used to close down the application in this case." |
|
473 |
||
474 |
shellTerminateAction := aBlock. |
|
475 |
||
476 |
"Created: / 12.6.1998 / 17:02:58 / cg" |
|
2076 | 477 |
! |
478 |
||
479 |
translateNLToCRNL |
|
480 |
^ translateNLToCRNL |
|
481 |
||
482 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
483 |
! |
|
484 |
||
4266 | 485 |
translateNLToCRNL:aBoolean |
486 |
translateNLToCRNL := aBoolean. |
|
2076 | 487 |
|
488 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
946 | 489 |
! ! |
914 | 490 |
|
491 |
!TerminalView methodsFor:'cursor handling'! |
|
492 |
||
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
493 |
cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
494 |
cursorLine + n > list size ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
495 |
list := list , (Array new:n). |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
496 |
self textChanged. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
497 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
498 |
super cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
499 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
500 |
"Modified: / 10.6.1998 / 17:18:41 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
501 |
"Created: / 10.6.1998 / 17:18:50 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
502 |
! |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
503 |
|
968
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
504 |
cursorMovementAllowed |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
505 |
"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
|
506 |
(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
|
507 |
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
|
508 |
cursor positioning escape sequences arriving from the |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
509 |
stream." |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
510 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
511 |
^ false |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
512 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
513 |
"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
|
514 |
! |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
515 |
|
2169 | 516 |
numberOfTerminalCols |
517 |
^ numberOfColumns |
|
518 |
! |
|
519 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
520 |
numberOfTerminalColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
521 |
^ numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
522 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
523 |
"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
|
524 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
525 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
526 |
numberOfTerminalLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
527 |
"/ 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
|
528 |
"/ 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
|
529 |
"/ in ListView ... |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
530 |
"/ ... 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
|
531 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
532 |
^ numberOfLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
533 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
534 |
"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
|
535 |
"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
|
536 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
537 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
538 |
restoreCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
539 |
|l c| |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
540 |
|
2192 | 541 |
savedCursor isNil ifTrue:[ |
542 |
l := c := 1. |
|
543 |
] ifFalse:[ |
|
544 |
l := savedCursor y. |
|
545 |
c := savedCursor x. |
|
546 |
]. |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
547 |
self cursorLine:l col:c. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
548 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
549 |
"Created: / 14.8.1998 / 13:49:24 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
550 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
551 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
552 |
saveCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
553 |
savedCursor := cursorCol @ cursorLine |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
554 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
555 |
"Created: / 14.8.1998 / 13:48:45 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
556 |
"Modified: / 14.8.1998 / 13:49:32 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
557 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
558 |
|
914 | 559 |
validateCursorCol:col inLine:line |
560 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
561 |
Here, the linelength is enforced" |
|
562 |
||
2268 | 563 |
col > numberOfColumns ifTrue:[ |
564 |
autoWrapFlag ifTrue:[ |
|
565 |
self endEntry. |
|
4452 | 566 |
self cursorLine:(self cursorLine + 1) col:1 " (col-numberOfColumns) ". |
2268 | 567 |
^ 1. |
568 |
]. |
|
569 |
]. |
|
926 | 570 |
^ col min:numberOfColumns |
914 | 571 |
|
926 | 572 |
"Modified: / 10.6.1998 / 15:09:41 / cg" |
914 | 573 |
! ! |
574 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
575 |
!TerminalView methodsFor:'defaults'! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
576 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
577 |
anyKeyCodes |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
578 |
^ IdentityDictionary withKeysAndValues: |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
579 |
#( |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
580 |
#Escape '\e' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
581 |
#BackSpace '\b' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
582 |
#Return '\r' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
583 |
#Delete '\0177' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
584 |
#Tab '\t' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
585 |
) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
586 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
587 |
"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
|
588 |
! ! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
589 |
|
914 | 590 |
!TerminalView methodsFor:'event handling'! |
591 |
||
951 | 592 |
computeNumberOfLinesShown |
593 |
|prevNLines prevNCols| |
|
594 |
||
4518 | 595 |
prevNCols := (innerWidth // gc font width). |
951 | 596 |
prevNLines := nFullLinesShown. |
597 |
||
598 |
super computeNumberOfLinesShown. |
|
599 |
||
4518 | 600 |
((innerWidth // gc font width) ~~ prevNCols |
951 | 601 |
or:[prevNLines ~~ nFullLinesShown]) ifTrue:[ |
602 |
self defineWindowSize. |
|
603 |
] |
|
604 |
||
605 |
"Created: / 12.6.1998 / 22:34:39 / cg" |
|
979 | 606 |
"Modified: / 20.6.1998 / 19:45:28 / cg" |
951 | 607 |
! |
608 |
||
1359 | 609 |
contentsChanged |
4256 | 610 |
"this one is sent, whenever contents changes its size" |
611 |
||
1359 | 612 |
super contentsChanged. |
2594 | 613 |
"/ self defineWindowSize. |
1359 | 614 |
|
615 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
|
616 |
"Created: / 5.5.1999 / 16:30:15 / cg" |
|
617 |
! |
|
618 |
||
943 | 619 |
defineWindowSize |
2192 | 620 |
| delta prevNumCols prevNumLines| |
1359 | 621 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
622 |
"/self halt. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
623 |
"/self realized ifFalse:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
624 |
"/ "/ iconfified |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
625 |
"/ ^ self |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
626 |
"/]. |
1359 | 627 |
prevNumCols := numberOfColumns. |
628 |
prevNumLines := numberOfLines. |
|
1161 | 629 |
|
4518 | 630 |
numberOfColumns := (innerWidth // gc font width). |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
631 |
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
|
632 |
numberOfLines := nFullLinesShown. |
1359 | 633 |
((prevNumCols == numberOfColumns) |
634 |
and:[prevNumLines == numberOfLines]) ifTrue:[ |
|
635 |
^ self |
|
636 |
]. |
|
637 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
638 |
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
|
639 |
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
|
640 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
641 |
|
1359 | 642 |
"/ any idea, how to do this under windows ? |
643 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
644 |
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
|
645 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
646 |
"/ 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
|
647 |
"/ 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
|
648 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
649 |
(inStream notNil |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
650 |
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
|
651 |
and:[inStream isOpen]]) ifTrue:[ |
4285 | 652 |
Debug ifTrue:[ |
4287 | 653 |
Transcript showCR:'VT100: windowSize changed nLines to ', numberOfLines printString. |
4285 | 654 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
655 |
(OperatingSystem |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
656 |
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
|
657 |
width:numberOfColumns |
4285 | 658 |
height:numberOfLines |
659 |
) ifFalse:[ |
|
2192 | 660 |
Debug ifTrue:[ |
661 |
Transcript showCR:'VT100: cannot change windowSize'. |
|
662 |
]. |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
663 |
]. |
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
664 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
665 |
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
|
666 |
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
|
667 |
] |
943 | 668 |
]. |
669 |
||
670 |
"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
|
671 |
"Modified: / 5.5.1999 / 19:45:09 / cg" |
943 | 672 |
! |
673 |
||
914 | 674 |
keyPress:aKey x:x y:y |
4164 | 675 |
<resource: #keyboard (#Control #Control_L #Control_R |
676 |
#Shift #Shift_L #Shift_R |
|
677 |
#Alt #Alt_L #Alt_R |
|
678 |
#Cmd #Cmd_L #Cmd_R |
|
679 |
#Meta #Meta_L #Meta_R |
|
680 |
#Return)> |
|
681 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
682 |
|rest event rawKey seq| |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
683 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
684 |
"/ somewhat complicated, since some characters |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
685 |
"/ should go untranslated (CTRL-key), |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
686 |
"/ even if defined as function keys. |
914 | 687 |
|
688 |
inStream isNil ifTrue:[^ self]. |
|
689 |
||
4294 | 690 |
DebugKeyboard ifTrue:[ |
2192 | 691 |
Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString. |
692 |
]. |
|
4593 | 693 |
lineEditMode == true ifTrue:[ |
4596 | 694 |
"/ TODO: check if tty is in raw mode - then ignore lineEditMode |
4593 | 695 |
(self keyPressInLineEditMode:aKey) ifTrue:[^ self]. |
696 |
]. |
|
914 | 697 |
|
698 |
aKey isCharacter ifTrue:[ |
|
2466 | 699 |
self deselect. |
700 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
701 |
localEcho ifTrue:[ |
3758 | 702 |
self nextPut:aKey. |
703 |
self flush. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
704 |
]. |
4290 | 705 |
"/ send it down to inStream ... |
4317 | 706 |
self sendCharacter:aKey. |
914 | 707 |
^ self |
708 |
]. |
|
709 |
||
1366 | 710 |
(#(Control Control_L Control_R |
711 |
Shift Shift_L Shift_R |
|
712 |
Alt Alt_L Alt_R |
|
713 |
Cmd Cmd_L Cmd_R |
|
714 |
Meta Meta_L Meta_R) includes:aKey) ifTrue:[ |
|
715 |
^ self |
|
716 |
]. |
|
717 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
718 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
719 |
"/ 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
|
720 |
"/ |
2078 | 721 |
(aKey == #Return |
722 |
and:[inputTranslateCRToNL]) ifTrue:[ |
|
723 |
seq := '\n'. |
|
724 |
] ifFalse:[ |
|
4324 | 725 |
(aKey == #BackSpace |
726 |
and:[inputTranslateBackspaceToDelete]) ifTrue:[ |
|
727 |
seq := kbdSequences at:#Delete ifAbsent:[ kbdSequences at:aKey ifAbsent:nil ]. |
|
728 |
] ifFalse:[ |
|
729 |
seq := kbdSequences at:aKey ifAbsent:nil. |
|
730 |
]. |
|
2078 | 731 |
]. |
3758 | 732 |
|
914 | 733 |
seq notNil ifTrue:[ |
4294 | 734 |
DebugKeyboard ifTrue:[ |
2192 | 735 |
Transcript show:'->' ; showCR:seq storeString. |
736 |
]. |
|
4105 | 737 |
seq := seq withoutCEscapes. |
2078 | 738 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
739 |
localEcho ifTrue:[ |
3758 | 740 |
seq do:[:k | self nextPut:k]. |
741 |
self flush. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
742 |
]. |
4317 | 743 |
self send:seq. |
914 | 744 |
^ self |
745 |
]. |
|
746 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
747 |
self sensor ctrlDown ifTrue:[ |
1366 | 748 |
(aKey startsWith:'Ctrl') ifTrue:[ |
749 |
rawKey := aKey |
|
750 |
] ifFalse:[ |
|
751 |
"/ already translated - undo it. |
|
752 |
||
753 |
event := WindowGroup lastEventQuerySignal query. |
|
754 |
rawKey := event rawKey. |
|
755 |
rawKey isCharacter ifTrue:[ |
|
756 |
rawKey := 'Ctrl' , rawKey. |
|
757 |
] |
|
1360 | 758 |
] |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
759 |
] ifFalse:[ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
760 |
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
|
761 |
]. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
762 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
763 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
764 |
"/ 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
|
765 |
"/ |
4294 | 766 |
DebugKeyboard ifTrue:[ |
2192 | 767 |
Transcript show:'raw ->' ; showCR:rawKey storeString. |
768 |
]. |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
769 |
|
914 | 770 |
seq := kbdSequences at:rawKey ifAbsent:nil. |
771 |
seq notNil ifTrue:[ |
|
4294 | 772 |
DebugKeyboard ifTrue:[ |
3758 | 773 |
Transcript show:'->' ; showCR:seq storeString. |
774 |
]. |
|
4317 | 775 |
self send:(seq withoutCEscapes). |
914 | 776 |
^ self |
777 |
]. |
|
778 |
||
779 |
(rawKey startsWith:'Ctrl') ifTrue:[ |
|
780 |
rest := rawKey copyFrom:5. |
|
781 |
rest size == 1 ifTrue:[ |
|
782 |
rest := rest at:1. |
|
4336 | 783 |
(rest asLowercase between:$a and:$z) ifTrue:[ |
4294 | 784 |
DebugKeyboard ifTrue:[ |
4336 | 785 |
Transcript show:'->' ; showCR:(Character controlCharacter:rest) storeString. |
2192 | 786 |
]. |
4336 | 787 |
self sendCharacter:(Character controlCharacter:rest). |
914 | 788 |
^ self |
789 |
]. |
|
790 |
] |
|
791 |
]. |
|
792 |
||
934 | 793 |
(rawKey startsWith:'Control') ifTrue:[ |
794 |
^ self |
|
795 |
]. |
|
796 |
(rawKey startsWith:'Shift') ifTrue:[ |
|
797 |
^ self |
|
798 |
]. |
|
799 |
(rawKey startsWith:'Alt') ifTrue:[ |
|
800 |
^ self |
|
801 |
]. |
|
802 |
(rawKey startsWith:'Cmd') ifTrue:[ |
|
950 | 803 |
^ super keyPress:aKey x:x y:y |
934 | 804 |
]. |
1345 | 805 |
(rawKey = 'Ctrl') ifTrue:[ |
806 |
^ self |
|
807 |
]. |
|
934 | 808 |
|
4294 | 809 |
DebugKeyboard ifTrue:[ |
2192 | 810 |
Transcript show:'unhandled key: '; showCR:rawKey. |
811 |
]. |
|
914 | 812 |
|
4294 | 813 |
" |
814 |
DebugKeyboard := true |
|
815 |
" |
|
816 |
||
4105 | 817 |
"Modified: / 25-01-2012 / 10:43:06 / cg" |
914 | 818 |
! |
819 |
||
4593 | 820 |
keyPressInLineEditMode:aKey |
821 |
"readline alike line editing. |
|
822 |
return true, if the character was processed, |
|
823 |
false if not. Then, the caller should proceed as usual." |
|
824 |
||
825 |
|clearLine| |
|
826 |
||
827 |
clearLine := |
|
828 |
[ |
|
829 |
lineBufferCursorPosition-1 timesRepeat:[ self deleteCharBeforeCursor ]. |
|
830 |
(lineBuffer size-(lineBufferCursorPosition-1)) timesRepeat:[ self deleteCharAtCursor]. |
|
831 |
]. |
|
832 |
||
833 |
"/ in lineEditMode, defer sending to the pty, until a newline is entered |
|
834 |
lineBuffer isNil ifTrue:[ |
|
835 |
lineBuffer := String new. |
|
836 |
lineBufferCursorPosition := 1. |
|
837 |
]. |
|
838 |
||
839 |
aKey isCharacter ifTrue:[ |
|
840 |
lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-1) |
|
841 |
, aKey |
|
842 |
, (lineBuffer copyFrom:lineBufferCursorPosition). |
|
843 |
self insertCharAtCursor:aKey. |
|
844 |
lineBufferCursorPosition := lineBufferCursorPosition + 1. |
|
845 |
^ true. |
|
846 |
]. |
|
847 |
aKey == #Return ifTrue:[ |
|
848 |
"/ as the pty is in echo mode, |
|
849 |
"/ we should either disable echo for the following, |
|
850 |
"/ or remove from the textview and let the program redraw them. |
|
851 |
"/ the second alternative looks easier for now... |
|
852 |
clearLine value. |
|
853 |
||
854 |
lineBuffer do:[:ch | |
|
855 |
self sendCharacter:ch. |
|
856 |
]. |
|
857 |
inputTranslateCRToNL ifTrue:[ |
|
858 |
self sendCharacter:(Character nl). |
|
859 |
] ifFalse:[ |
|
860 |
self sendCharacter:(Character return). |
|
861 |
]. |
|
862 |
lineBufferHistory isNil ifTrue:[ |
|
863 |
lineBufferHistory := OrderedCollection new. |
|
864 |
]. |
|
4594 | 865 |
(lineBufferHistory size > 0 and:[lineBufferHistory last isEmpty]) ifTrue:[ |
866 |
lineBufferHistory removeLast |
|
867 |
]. |
|
4593 | 868 |
lineBufferHistory addLast:lineBuffer. |
869 |
lineBufferHistoryPosition := lineBufferHistory size + 1. |
|
870 |
lineBuffer := nil. |
|
871 |
^ true. |
|
872 |
]. |
|
873 |
||
874 |
aKey == #BackSpace ifTrue:[ |
|
875 |
lineBufferCursorPosition > 1 ifFalse:[ |
|
876 |
self beep. |
|
877 |
^ true |
|
878 |
]. |
|
879 |
lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-2) |
|
880 |
, (lineBuffer copyFrom:lineBufferCursorPosition). |
|
881 |
self deleteCharBeforeCursor. |
|
882 |
lineBufferCursorPosition := lineBufferCursorPosition - 1. |
|
883 |
^ true. |
|
884 |
]. |
|
885 |
||
886 |
aKey == #CursorLeft ifTrue:[ |
|
887 |
lineBufferCursorPosition > 1 ifFalse:[ |
|
888 |
self beep. |
|
889 |
^ true |
|
890 |
]. |
|
891 |
lineBufferCursorPosition := lineBufferCursorPosition - 1. |
|
892 |
self cursorLeft. |
|
893 |
^ true. |
|
894 |
]. |
|
895 |
aKey == #CursorRight ifTrue:[ |
|
896 |
lineBufferCursorPosition < lineBuffer size ifFalse:[ |
|
897 |
self beep. |
|
898 |
^ true |
|
899 |
]. |
|
900 |
lineBufferCursorPosition := lineBufferCursorPosition + 1. |
|
901 |
self cursorRight. |
|
902 |
^ true. |
|
903 |
]. |
|
904 |
aKey == #CursorUp ifTrue:[ |
|
905 |
lineBufferHistoryPosition > 1 ifFalse:[ |
|
906 |
self beep. |
|
907 |
^ true |
|
908 |
]. |
|
909 |
||
4595 | 910 |
"/ remember the current lineBuffer (but only if it is the last) |
4593 | 911 |
lineBufferHistoryPosition > lineBufferHistory size ifTrue:[ |
912 |
lineBufferHistory add:lineBuffer. |
|
913 |
]. |
|
914 |
clearLine value. |
|
915 |
||
916 |
lineBufferHistoryPosition := lineBufferHistoryPosition - 1. |
|
917 |
lineBuffer := lineBufferHistory at:lineBufferHistoryPosition. |
|
918 |
self insertStringAtCursor:lineBuffer. |
|
919 |
lineBufferCursorPosition := lineBuffer size + 1. |
|
920 |
^ true. |
|
921 |
]. |
|
922 |
aKey == #CursorDown ifTrue:[ |
|
923 |
lineBufferHistoryPosition < lineBufferHistory size ifFalse:[ |
|
924 |
self beep. |
|
925 |
^ true |
|
926 |
]. |
|
927 |
||
928 |
clearLine value. |
|
929 |
||
930 |
lineBufferHistoryPosition := lineBufferHistoryPosition + 1. |
|
931 |
lineBuffer := lineBufferHistory at:lineBufferHistoryPosition. |
|
4594 | 932 |
lineBufferHistoryPosition >= lineBufferHistory size ifTrue:[ |
933 |
lineBufferHistory removeLast. |
|
934 |
]. |
|
4593 | 935 |
self insertStringAtCursor:lineBuffer. |
936 |
lineBufferCursorPosition := lineBuffer size + 1. |
|
937 |
^ true. |
|
938 |
]. |
|
939 |
^ false. |
|
940 |
! |
|
941 |
||
914 | 942 |
shellTerminated |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
943 |
"shell has terminated" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
944 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
945 |
"/Delay waitForSeconds:10. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
946 |
[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
|
947 |
"/ |
4265 | 948 |
self closeDownShellAndStopReaderProcess. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
949 |
|
946 | 950 |
shellTerminateAction notNil ifTrue:[ |
951 |
shellTerminateAction value |
|
952 |
] ifFalse:[ |
|
953 |
"/ may be removed ... |
|
4250 | 954 |
self warn:(resources string:'shell terminated'). |
946 | 955 |
] |
956 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
957 |
"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
|
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 |
sizeChanged:how |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
961 |
super sizeChanged:how. |
943 | 962 |
self defineWindowSize. |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
963 |
|
943 | 964 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
914 | 965 |
! ! |
966 |
||
967 |
!TerminalView methodsFor:'functions'! |
|
968 |
||
969 |
doBackspace |
|
970 |
self cursorLeft. |
|
971 |
self replaceCharAtCursor:(Character space). |
|
972 |
self cursorLeft. |
|
973 |
||
931 | 974 |
"Modified: / 10.6.1998 / 17:09:12 / cg" |
914 | 975 |
! |
976 |
||
926 | 977 |
doClearDisplay |
1420 | 978 |
"clear everything" |
979 |
||
1000 | 980 |
self doClearEntireScreen. |
981 |
||
982 |
"Modified: / 21.7.1998 / 20:05:35 / cg" |
|
983 |
! |
|
984 |
||
1420 | 985 |
doClearEntireLine |
986 |
"clear the cursor line. cursor position remains unchanged" |
|
987 |
||
988 |
self at:cursorLine put:'' |
|
989 |
! |
|
990 |
||
1000 | 991 |
doClearEntireScreen |
1420 | 992 |
"clear everything" |
993 |
||
926 | 994 |
firstLineShown to:(list size) do:[:l | |
995 |
self at:l put:'' |
|
996 |
]. |
|
922 | 997 |
|
1000 | 998 |
"Modified: / 21.7.1998 / 20:00:19 / cg" |
999 |
"Created: / 21.7.1998 / 20:05:24 / cg" |
|
926 | 1000 |
! |
1001 |
||
1000 | 1002 |
doClearFromBeginningOfLine |
1420 | 1003 |
"clear from beginning of line to the cursorPosition" |
1004 |
||
1000 | 1005 |
|l| |
1006 |
||
1007 |
l := self listAt:cursorLine. |
|
1008 |
l notNil ifTrue:[ |
|
1009 |
(l size >= (cursorCol-1)) ifTrue:[ |
|
1010 |
l := l copy from:1 to:cursorCol-1 put:(Character space). |
|
1011 |
] ifFalse:[ |
|
1012 |
l := nil. |
|
1013 |
]. |
|
1014 |
self withoutRedrawAt:cursorLine put:l. |
|
1015 |
self invalidateLine:cursorLine |
|
1016 |
"/ self at:cursorLine put:l. |
|
1017 |
] |
|
1018 |
||
1019 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
|
1020 |
"Created: / 21.7.1998 / 20:10:58 / cg" |
|
1021 |
! |
|
1022 |
||
1023 |
doClearFromBeginningOfScreen |
|
1420 | 1024 |
"clear from beginning of the screen to the cursorPosition" |
1025 |
||
1000 | 1026 |
self doClearFromBeginningOfLine. |
1027 |
cursorLine-1 to:firstLineShown do:[:l | |
|
922 | 1028 |
self at:l put:'' |
1029 |
]. |
|
1030 |
||
926 | 1031 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
1000 | 1032 |
"Created: / 21.7.1998 / 20:08:29 / cg" |
926 | 1033 |
! |
1034 |
||
1035 |
doClearToEndOfLine |
|
1420 | 1036 |
"clear from the cursorPosition to the end of the line" |
1037 |
||
926 | 1038 |
|l| |
1039 |
||
1040 |
l := self listAt:cursorLine. |
|
931 | 1041 |
(l size >= (cursorCol-1)) ifTrue:[ |
951 | 1042 |
l notNil ifTrue:[ |
1043 |
l := l copyTo:cursorCol-1. |
|
979 | 1044 |
self withoutRedrawAt:cursorLine put:l. |
1045 |
self invalidateLine:cursorLine |
|
1046 |
"/ self at:cursorLine put:l. |
|
951 | 1047 |
] |
926 | 1048 |
] |
1049 |
||
1050 |
"Created: / 10.6.1998 / 14:45:01 / cg" |
|
979 | 1051 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
914 | 1052 |
! |
1053 |
||
1000 | 1054 |
doClearToEndOfScreen |
1420 | 1055 |
"clear from the cursorPosition to the end of the screen" |
1056 |
||
1000 | 1057 |
self doClearToEndOfLine. |
1058 |
cursorLine+1 to:(list size) do:[:l | |
|
1059 |
self at:l put:'' |
|
1060 |
]. |
|
1061 |
||
1062 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
|
1063 |
"Created: / 21.7.1998 / 20:06:14 / cg" |
|
1064 |
! |
|
1065 |
||
926 | 1066 |
doCursorDown:n |
1420 | 1067 |
"move the cursor down by n lines" |
1068 |
||
979 | 1069 |
|wasOn rEnd| |
926 | 1070 |
|
979 | 1071 |
"/ rangeEndLine == numberOfLines ifTrue:[ |
1072 |
"/ ^ super cursorDown:n |
|
1073 |
"/ ]. |
|
1074 |
cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[ |
|
951 | 1075 |
"/ no special action req'd |
1076 |
^ super cursorDown:n |
|
1077 |
]. |
|
979 | 1078 |
|
951 | 1079 |
n timesRepeat:[ |
1080 |
wasOn := self hideCursor. |
|
979 | 1081 |
rEnd := rangeEndLine+firstLineShown-1. |
1082 |
cursorLine == rEnd ifTrue:[ |
|
1083 |
self deleteLine:(rangeStartLine+firstLineShown-1). |
|
1084 |
self insertLine:'' before:rEnd. |
|
951 | 1085 |
] ifFalse:[ |
1086 |
super cursorDown |
|
1087 |
]. |
|
979 | 1088 |
wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn. |
951 | 1089 |
] |
1090 |
||
979 | 1091 |
"Modified: / 20.6.1998 / 20:29:39 / cg" |
926 | 1092 |
! |
1093 |
||
914 | 1094 |
doCursorHome |
1420 | 1095 |
"move the cursor to the home position" |
1096 |
||
938 | 1097 |
self cursorVisibleLine:1 col:1 |
1098 |
"/ super cursorHome |
|
1099 |
||
1100 |
"Modified: / 10.6.1998 / 20:47:31 / cg" |
|
914 | 1101 |
! |
1102 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1103 |
doCursorLeft:n |
1420 | 1104 |
"move the cursor to the left by n columns" |
1105 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1106 |
n timesRepeat:[ |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1107 |
super cursorLeft |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1108 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1109 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1110 |
"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
|
1111 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1112 |
|
914 | 1113 |
doCursorNewLine |
1420 | 1114 |
"move the cursor down to the next line (col remains unchanged)" |
1115 |
||
931 | 1116 |
super cursorDown:1 |
1117 |
||
1118 |
"Modified: / 10.6.1998 / 16:55:57 / cg" |
|
914 | 1119 |
! |
1120 |
||
1121 |
doCursorReturn |
|
1420 | 1122 |
"move the cursor down and left to the beginning to the next line" |
1123 |
||
914 | 1124 |
super cursorToBeginOfLine |
1125 |
! |
|
1126 |
||
926 | 1127 |
doCursorRight:n |
1420 | 1128 |
"move the cursor to the right by n columns" |
1129 |
||
926 | 1130 |
self cursorCol:(cursorCol + n) |
1131 |
||
1132 |
"Created: / 10.6.1998 / 15:10:08 / cg" |
|
1133 |
! |
|
1134 |
||
951 | 1135 |
doCursorUp:n |
1420 | 1136 |
"move the cursor up by n lines" |
1137 |
||
979 | 1138 |
|wasOn rStart| |
926 | 1139 |
|
979 | 1140 |
"/ rangeStartLine == 1 ifTrue:[ |
1141 |
"/ ^ super cursorUp:n |
|
1142 |
"/ ]. |
|
1143 |
cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[ |
|
951 | 1144 |
"/ no special action req'd |
1145 |
^ super cursorUp:n |
|
1146 |
]. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1147 |
n timesRepeat:[ |
951 | 1148 |
wasOn := self hideCursor. |
979 | 1149 |
rStart := rangeStartLine+firstLineShown-1. |
1150 |
cursorLine == rStart ifTrue:[ |
|
1151 |
(rangeEndLine+firstLineShown-1) <= list size ifTrue:[ |
|
1152 |
self deleteLine:(rangeEndLine+firstLineShown-1). |
|
1153 |
self insertLine:'' before:rStart. |
|
1154 |
]. |
|
951 | 1155 |
] ifFalse:[ |
1156 |
super cursorUp |
|
1157 |
]. |
|
1158 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1159 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1160 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1161 |
"Created: / 11.6.1998 / 22:29:46 / cg" |
979 | 1162 |
"Modified: / 20.6.1998 / 20:30:34 / cg" |
914 | 1163 |
! ! |
1164 |
||
2501 | 1165 |
!TerminalView methodsFor:'initialization & release'! |
914 | 1166 |
|
1167 |
closeDownShell |
|
4265 | 1168 |
"shut down my shell process." |
1420 | 1169 |
|
1009 | 1170 |
|pid| |
926 | 1171 |
|
1172 |
(pid := shellPid) notNil ifTrue:[ |
|
2192 | 1173 |
Debug ifTrue:[ |
4265 | 1174 |
Transcript show:'killing shell pid='; showCR:pid. |
2192 | 1175 |
]. |
926 | 1176 |
OperatingSystem terminateProcessGroup:pid. |
1177 |
OperatingSystem terminateProcess:pid. |
|
925 | 1178 |
Delay waitForSeconds:1. |
1179 |
shellPid notNil ifTrue:[ |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1180 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1181 |
OperatingSystem killProcessGroup:pid. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1182 |
]. |
926 | 1183 |
OperatingSystem killProcess:pid. |
925 | 1184 |
shellPid := nil. |
1185 |
]. |
|
926 | 1186 |
OperatingSystem closePid:pid. |
914 | 1187 |
]. |
4265 | 1188 |
! |
914 | 1189 |
|
4265 | 1190 |
closeDownShellAndStopReaderProcess |
1191 |
"shut down my shell process and stop the background reader thread." |
|
1192 |
||
1193 |
self closeDownShell. |
|
1009 | 1194 |
self stopReaderProcess. |
4265 | 1195 |
self closeStreams |
1009 | 1196 |
|
4265 | 1197 |
"Modified: / 5.5.1999 / 18:43:02 / cg" |
1198 |
! |
|
1199 |
||
1200 |
closeStreams |
|
4576 | 1201 |
|s| |
1202 |
||
1203 |
(s := inStream) notNil ifTrue:[ |
|
1204 |
inStream := nil. |
|
1205 |
s isStream ifTrue:[s close]. |
|
914 | 1206 |
]. |
4576 | 1207 |
(s := outStream) notNil ifTrue:[ |
1208 |
outStream := nil. |
|
1209 |
s close. |
|
914 | 1210 |
]. |
924 | 1211 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1212 |
"Modified: / 5.5.1999 / 18:43:02 / cg" |
914 | 1213 |
! |
1214 |
||
1215 |
escapeSequences:codes |
|
1420 | 1216 |
"setup my escape sequences" |
1217 |
||
914 | 1218 |
|tree| |
1219 |
||
1220 |
tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new]. |
|
1221 |
||
1222 |
codes do:[:specEntry | |
|
1223 |
|sequence function| |
|
1224 |
||
4105 | 1225 |
sequence := (specEntry at:1) withoutCEscapes. |
914 | 1226 |
function := specEntry at:2. |
1227 |
||
1228 |
tree := escapeSequenceTree. |
|
1229 |
||
1230 |
sequence keysAndValuesDo:[:idx :char | |
|
1231 |
|followup| |
|
1232 |
||
1233 |
idx == sequence size ifTrue:[ |
|
1234 |
tree at:char put:function |
|
1235 |
] ifFalse:[ |
|
1236 |
followup := tree at:char ifAbsent:nil. |
|
1237 |
followup isNil ifTrue:[ |
|
1238 |
tree at:char put:(followup := IdentityDictionary new). |
|
1239 |
]. |
|
1240 |
tree := followup |
|
1241 |
] |
|
1242 |
] |
|
1243 |
]. |
|
918 | 1244 |
escapeLeadingChars := escapeSequenceTree keys asSet. |
1245 |
escapeLeadingChars add:(Character cr). |
|
1246 |
escapeLeadingChars add:(Character return). |
|
1247 |
escapeLeadingChars add:(Character backspace). |
|
1248 |
||
1249 |
escapeLeadingChars := escapeLeadingChars asArray |
|
1250 |
||
4105 | 1251 |
"Modified: / 25-01-2012 / 10:42:46 / cg" |
914 | 1252 |
! |
1253 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1254 |
flushInput |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1255 |
|sensor| |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1256 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1257 |
"/ flush any leftover input-processing events |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1258 |
(sensor := self sensor) notNil ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1259 |
sensor flushEventsFor:self withType:#processInput:n:. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1260 |
] |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1261 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1262 |
"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
|
1263 |
"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
|
1264 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1265 |
|
2163 | 1266 |
initStyle |
1267 |
super initStyle. |
|
1268 |
"/ self foregroundColor:Color green. |
|
1269 |
"/ self backgroundColor:Color black. |
|
1270 |
! |
|
1271 |
||
914 | 1272 |
initialize |
2194 | 1273 |
|
914 | 1274 |
super initialize. |
1275 |
||
1276 |
showMatchingParenthesis := false. |
|
4288 | 1277 |
self insertMode: false. |
936 | 1278 |
alwaysAppendAtEnd := false. |
4315 | 1279 |
collectSize := 4096. |
1280 |
sizeOfOutstandingInputToBeProcessed := 0. |
|
977 | 1281 |
st80Mode := false. |
1282 |
trimBlankLines := true. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1283 |
localEcho := false. |
2078 | 1284 |
inputTranslateCRToNL := false. |
4324 | 1285 |
inputTranslateBackspaceToDelete := false. |
2268 | 1286 |
autoWrapFlag := true. |
4299 | 1287 |
noColors := false. |
4593 | 1288 |
lineEditMode := false. |
2268 | 1289 |
"/ cursorType := #block. |
4452 | 1290 |
"/ cursorTypeNoFocus := #frame. |
1291 |
||
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1292 |
state := 0. |
914 | 1293 |
|
926 | 1294 |
numberOfColumns := 80. |
979 | 1295 |
numberOfLines := 24. |
954 | 1296 |
rangeStartLine := 1. |
1297 |
rangeEndLine := numberOfLines. |
|
926 | 1298 |
|
2423
d2685982f94f
tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents:
2356
diff
changeset
|
1299 |
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
|
1300 |
|
914 | 1301 |
self initializeKeyboardSequences. |
1302 |
list := OrderedCollection new:24 withAll:''. |
|
1303 |
||
2577 | 1304 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
1305 |
kbdSequences at:#Return put:'\r\n'. |
|
1306 |
]. |
|
914 | 1307 |
self initializeKeyboardMap. |
1308 |
||
1309 |
" |
|
1310 |
VT52TerminalView openShell |
|
926 | 1311 |
VT100TerminalView openShell |
914 | 1312 |
" |
926 | 1313 |
|
4315 | 1314 |
"Modified: / 30-07-2013 / 10:43:07 / cg" |
914 | 1315 |
! |
1316 |
||
1317 |
initializeKeyboardMap |
|
1349 | 1318 |
|keys ctrlKeys cmdKeys| |
914 | 1319 |
|
1349 | 1320 |
"/ setup my own keyboardMap, where control-keys |
1321 |
"/ (and some Cmd-keys) are not translated. |
|
4518 | 1322 |
kbdMap := self graphicsDevice keyboardMap copy. |
1349 | 1323 |
keys := kbdMap keys. |
914 | 1324 |
|
1349 | 1325 |
ctrlKeys := keys select:[:key | key startsWith:'Ctrl']. |
914 | 1326 |
ctrlKeys do:[:key | kbdMap removeKey:key]. |
950 | 1327 |
|
1349 | 1328 |
cmdKeys := keys select:[:key | key startsWith:'Cmd']. |
1329 |
cmdKeys do:[:key | |val| |
|
1330 |
val := kbdMap at:key. |
|
1331 |
val isSymbol ifTrue:[ |
|
2506 | 1332 |
(#(Copy Paste SaveAs Print Find FindNext FindPrev GotoLine) includes:val) ifFalse:[ |
1349 | 1333 |
kbdMap removeKey:key |
1334 |
] |
|
950 | 1335 |
] |
1336 |
]. |
|
914 | 1337 |
|
1338 |
kbdMap removeKey:#Delete ifAbsent:[]. |
|
1339 |
kbdMap removeKey:#BackSpace ifAbsent:[]. |
|
1340 |
||
1341 |
" |
|
1342 |
VT52TerminalView openShell |
|
1343 |
" |
|
950 | 1344 |
|
1349 | 1345 |
"Modified: / 29.4.1999 / 14:25:24 / cg" |
914 | 1346 |
! |
1347 |
||
1348 |
initializeKeyboardSequences |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1349 |
kbdSequences := (self anyKeyCodes) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1350 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1351 |
"Modified: / 5.5.1999 / 15:01:09 / cg" |
914 | 1352 |
! |
1353 |
||
1354 |
keyboardMap |
|
934 | 1355 |
"return my keyboard map. This has control keys removed and |
1356 |
those will be passed unchanged to the shell" |
|
1357 |
||
914 | 1358 |
^ kbdMap |
934 | 1359 |
|
1360 |
"Modified: / 10.6.1998 / 17:46:59 / cg" |
|
914 | 1361 |
! |
1362 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1363 |
reinitialize |
1833 | 1364 |
"reinit after a snapIn. |
1365 |
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
|
1366 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1367 |
super reinitialize. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1368 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1369 |
shellPid := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1370 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1371 |
self stopReaderProcess. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1372 |
self flushInput. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1373 |
|
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1374 |
readerProcess := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1375 |
inStream := outStream := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1376 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1377 |
"/ 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
|
1378 |
[ |
1322 | 1379 |
"/ Delay waitForSeconds:0.5. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1380 |
self doClearEntireScreen. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1381 |
self cursorLine:1 col:1. |
1321
9a312fa98358
also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents:
1320
diff
changeset
|
1382 |
self contents:nil. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1383 |
self flash. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1384 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1385 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1386 |
"/ 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
|
1387 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1388 |
self startCommand:shellCommand in:shellDirectory. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1389 |
] forkAt:8 |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1390 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1391 |
"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
|
1392 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1393 |
|
2155 | 1394 |
release |
1395 |
"release myself - shut down the shell, stop the reader thread." |
|
1396 |
||
4265 | 1397 |
[ |
1398 |
self closeDownShellAndStopReaderProcess. |
|
1399 |
self flushInput. |
|
2341
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1400 |
] fork. |
2155 | 1401 |
super release |
1402 |
||
1403 |
"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
|
1404 |
! ! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
1405 |
|
2501 | 1406 |
!TerminalView methodsFor:'initialization-shell'! |
1407 |
||
2778 | 1408 |
basicStartCommand:aCommand in:aDirectory |
2501 | 1409 |
"start a command on a pseudo terminal. If the command arg is nil, |
1410 |
a shell is started. If aDirectory is not nil, the command is |
|
1411 |
executed in that directory. |
|
1412 |
Also fork a reader process, to read the shells output and |
|
1413 |
tell me, whenever something arrives" |
|
1414 |
||
1415 |
|pty slaveFD execFdArray blocked exitStatus |
|
1416 |
stxToCommandPipe commandToStxPipe cmd shell args env shellAndArgs| |
|
1417 |
||
1418 |
shellCommand := aCommand. |
|
1419 |
shellDirectory := aDirectory. |
|
1420 |
||
1421 |
self create. "/ need my windowID (to pass down in environment) |
|
1422 |
||
1423 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1424 |
"use two pipes to COMMAND.COM" |
|
2538
2ee2ed3bad39
Move makePTYPair to NonPositionableExternalStream
Stefan Vogel <sv@exept.de>
parents:
2506
diff
changeset
|
1425 |
stxToCommandPipe := NonPositionableExternalStream makePipe. |
2501 | 1426 |
stxToCommandPipe isNil ifTrue:[ |
4250 | 1427 |
self warn:(resources string:'Could not create pipe to COMMAND.COM.'). |
1428 |
^ self. |
|
2501 | 1429 |
]. |
1430 |
||
2538
2ee2ed3bad39
Move makePTYPair to NonPositionableExternalStream
Stefan Vogel <sv@exept.de>
parents:
2506
diff
changeset
|
1431 |
commandToStxPipe := NonPositionableExternalStream makePipe. |
2501 | 1432 |
commandToStxPipe isNil ifTrue:[ |
4250 | 1433 |
self warn:(resources string:'Could not create pipe from COMMAND.COM.'). |
1434 |
^ self. |
|
2501 | 1435 |
]. |
1436 |
||
1437 |
"/ pipe readSide is p at:1; |
|
1438 |
"/ writeSide is p at:2 |
|
1439 |
||
1440 |
slaveFD := (commandToStxPipe at:2) fileDescriptor. |
|
1441 |
execFdArray := Array |
|
1442 |
with:(stxToCommandPipe at:1) fileDescriptor "stdin" |
|
1443 |
with:slaveFD "stdout" |
|
1444 |
with:slaveFD. "stderr" |
|
1445 |
||
1446 |
outStream := commandToStxPipe at:1. |
|
1447 |
inStream := stxToCommandPipe at:2. |
|
1448 |
||
1449 |
shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand. |
|
1450 |
shell := shellAndArgs at:1. |
|
1451 |
args := (shellAndArgs at:2) ? ''. |
|
1452 |
] ifFalse:[ |
|
1453 |
"Use a pseudo-tty" |
|
2538
2ee2ed3bad39
Move makePTYPair to NonPositionableExternalStream
Stefan Vogel <sv@exept.de>
parents:
2506
diff
changeset
|
1454 |
pty := NonPositionableExternalStream makePTYPair. |
2501 | 1455 |
pty isNil ifTrue:[ |
1456 |
self warn:'Cannot open pty.'. |
|
1457 |
^ self. |
|
1458 |
]. |
|
1459 |
||
1460 |
"/ pty at:1 is the master; |
|
1461 |
"/ pty at:2 is the slave |
|
1462 |
inStream := outStream := (pty at:1). |
|
1463 |
||
1464 |
self defineWindowSize. |
|
1465 |
"/ fork a shell process on the slave-side |
|
1466 |
slaveFD := (pty at:2) fileDescriptor. |
|
1467 |
execFdArray := Array with:slaveFD with:slaveFD with:slaveFD. |
|
1468 |
||
1469 |
aCommand isNil ifTrue:[ |
|
1470 |
shell := OperatingSystem getEnvironment:'SHELL'. |
|
1471 |
shell size == 0 ifTrue:[ |
|
1472 |
shell := '/bin/sh'. |
|
1473 |
]. |
|
1474 |
cmd := shell asFilename baseName. |
|
1475 |
args := (Array with:cmd). |
|
1476 |
] ifFalse:[ |
|
1477 |
shell := '/bin/sh'. |
|
1478 |
args := (Array with:'sh' with:'-c' with:aCommand). |
|
1479 |
]. |
|
1480 |
env := Dictionary new. |
|
1481 |
env at:'SHELL' put:shell. |
|
1482 |
env at:'TERM' put:(self terminalType). |
|
4222 | 1483 |
env at:'HOME' put:(OperatingSystem getEnvironment:'HOME'). |
1484 |
env at:'USER' put:(OperatingSystem getEnvironment:'USER'). |
|
2501 | 1485 |
env at:'LINES' put:(numberOfLines printString). |
1486 |
env at:'COLUMNS' put:(numberOfColumns printString). |
|
4518 | 1487 |
(self graphicsDevice platformName = 'X11' and:[self drawableId notNil]) ifTrue:[ |
1488 |
env at:'WINDOWID' put:(self drawableId address printString). |
|
2501 | 1489 |
]. |
1490 |
]. |
|
1491 |
||
1492 |
blocked := OperatingSystem blockInterrupts. |
|
1493 |
||
1494 |
shellPid := Processor |
|
1495 |
monitor:[ |
|
1496 |
OperatingSystem |
|
1497 |
exec:shell |
|
1498 |
withArguments:args |
|
1499 |
environment:env |
|
1500 |
fileDescriptors:execFdArray |
|
1501 |
fork:true |
|
1502 |
newPgrp:true |
|
1503 |
inDirectory:aDirectory. |
|
1504 |
] |
|
1505 |
action:[:status | |
|
1506 |
Debug ifTrue:[ |
|
4325 | 1507 |
Transcript showCR:'shell status change'. |
1508 |
Transcript show:' pid:'; showCR:status pid. |
|
1509 |
Transcript show:' status:'; showCR:status status. |
|
1510 |
Transcript show:' code:'; showCR:status code. |
|
1511 |
Transcript show:' core:'; showCR:status core. |
|
2501 | 1512 |
]. |
1513 |
status stillAlive ifFalse:[ |
|
1514 |
exitStatus := status. |
|
1515 |
OperatingSystem closePid:shellPid. |
|
1516 |
shellPid := nil. |
|
1517 |
self pushEvent:#shellTerminated |
|
1518 |
]. |
|
1519 |
]. |
|
1520 |
||
1521 |
blocked ifFalse:[ |
|
1522 |
OperatingSystem unblockInterrupts |
|
1523 |
]. |
|
1524 |
||
1525 |
"close the slave side of the pty/pipes (only used by the child)" |
|
1526 |
pty notNil ifTrue:[ |
|
1527 |
(pty at:2) close. |
|
1528 |
]. |
|
1529 |
||
1530 |
commandToStxPipe notNil ifTrue:[ |
|
1531 |
(commandToStxPipe at:2) close. |
|
1532 |
(stxToCommandPipe at:1) close. |
|
1533 |
]. |
|
1534 |
||
1535 |
shellPid isNil ifTrue:[ |
|
1536 |
self warn:'Cannot start shell'. |
|
4327 | 1537 |
self closeStreams. |
2501 | 1538 |
^ self. |
1539 |
]. |
|
1540 |
||
2778 | 1541 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
1542 |
"Modified: / 5.5.1999 / 17:28:37 / cg" |
|
1543 |
! |
|
1544 |
||
1545 |
startCommand:aCommand |
|
1546 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
1547 |
a shell is started. The command is started in the current directory. |
|
1548 |
Also fork a reader process, to read the shells output and |
|
1549 |
tell me, whenever something arrives" |
|
1550 |
||
1551 |
self startCommand:aCommand in:nil |
|
1552 |
||
1553 |
"Modified: / 20.7.1998 / 18:30:24 / cg" |
|
1554 |
! |
|
1555 |
||
1556 |
startCommand:aCommand in:aDirectory |
|
1557 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
1558 |
a shell is started. If aDirectory is not nil, the command is |
|
1559 |
executed in that directory. |
|
1560 |
Also fork a reader process, to read the shells output and |
|
1561 |
tell me, whenever something arrives" |
|
1562 |
||
1563 |
self basicStartCommand:aCommand in:aDirectory. |
|
1564 |
self startReaderProcessWhenVisible. |
|
2501 | 1565 |
|
1566 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
|
1567 |
"Modified: / 5.5.1999 / 17:28:37 / cg" |
|
1568 |
! |
|
1569 |
||
1570 |
startShell |
|
1571 |
"start a shell on a pseudo terminal in the current directory. |
|
1572 |
Also fork a reader process, to read the shells output and |
|
1573 |
tell me, whenever something arrives" |
|
1574 |
||
1575 |
^ self startCommand:nil |
|
1576 |
||
1577 |
" |
|
1578 |
VT100TerminalView openShell |
|
1579 |
" |
|
1580 |
||
1581 |
"Modified: / 20.7.1998 / 18:29:54 / cg" |
|
1582 |
! |
|
1583 |
||
1584 |
startShellIn:aDirectory |
|
1585 |
"start a shell on a pseudo terminal in some directory. |
|
1586 |
Also fork a reader process, to read the shells output and |
|
1587 |
tell me, whenever something arrives" |
|
1588 |
||
2778 | 1589 |
self startCommand:nil in:aDirectory |
2501 | 1590 |
|
1591 |
" |
|
1592 |
VT100TerminalView openShellIn:'/etc' |
|
1593 |
" |
|
1594 |
||
1595 |
"Modified: / 20.7.1998 / 18:29:46 / cg" |
|
1596 |
! ! |
|
1597 |
||
914 | 1598 |
!TerminalView methodsFor:'menu'! |
1599 |
||
3225 | 1600 |
doClear |
1601 |
"reset the scroll-range etc, clear the text buffer" |
|
1602 |
||
1603 |
rangeStartLine := 1. |
|
1604 |
rangeEndLine := numberOfLines. |
|
1605 |
||
1606 |
self normal. |
|
1607 |
self clear. |
|
1608 |
||
1609 |
"Created: / 03-04-2007 / 08:58:59 / cg" |
|
1610 |
! |
|
1611 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1612 |
doReset |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1613 |
"reset the scroll-range; |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1614 |
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
|
1615 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1616 |
rangeStartLine := 1. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1617 |
rangeEndLine := numberOfLines. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1618 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1619 |
self normal. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1620 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1621 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1622 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1623 |
doSendInterrupt |
1420 | 1624 |
"send an INT-signal to the shell (UNIX only)" |
1625 |
||
4338 | 1626 |
|status| |
1627 |
||
2597 | 1628 |
shellPid notNil ifTrue:[ |
4306 | 1629 |
OperatingSystem isUNIXlike ifTrue:[ |
1630 |
OperatingSystem sendSignal:(OperatingSystem sigINT) to:shellPid negated. |
|
4338 | 1631 |
OperatingSystem sendSignal:(OperatingSystem sigINT) to:shellPid. |
1632 |
status := OperatingSystem childProcessWait:false pid:shellPid. |
|
4306 | 1633 |
] ifFalse:[ |
1634 |
self warn:'unimplemented for DOS' |
|
1635 |
] |
|
2597 | 1636 |
]. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1637 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1638 |
"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
|
1639 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1640 |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1641 |
doSendKillSignal |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1642 |
"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
|
1643 |
|
4338 | 1644 |
|status| |
1645 |
||
2597 | 1646 |
shellPid notNil ifTrue:[ |
4306 | 1647 |
OperatingSystem isUNIXlike ifTrue:[ |
1648 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:shellPid negated. |
|
4338 | 1649 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:shellPid. |
1650 |
status := OperatingSystem childProcessWait:false pid:shellPid. |
|
1651 |
self halt. |
|
4306 | 1652 |
] ifFalse:[ |
1653 |
self warn:'unimplemented for DOS' |
|
1654 |
] |
|
2597 | 1655 |
] |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1656 |
! |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1657 |
|
914 | 1658 |
editMenu |
1659 |
"return the views middleButtonMenu" |
|
1660 |
||
1347 | 1661 |
<resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)> |
914 | 1662 |
<resource: #programMenu> |
1663 |
||
4487 | 1664 |
|items subMenu moreMenu m sensor| |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1665 |
|
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1666 |
items := #( |
3225 | 1667 |
('Interrupt' doSendInterrupt ) |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1668 |
('Kill' doSendKillSignal) |
3225 | 1669 |
('-' ) |
1670 |
('Clear' doClear ) |
|
1671 |
('Reset' doReset ) |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1672 |
). |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1673 |
subMenu := PopUpMenu itemList:items resources:resources. |
914 | 1674 |
|
4487 | 1675 |
items := #( |
1676 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
1677 |
). |
|
1678 |
moreMenu := PopUpMenu itemList:items resources:resources. |
|
1679 |
||
914 | 1680 |
((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
|
1681 |
m := subMenu. |
914 | 1682 |
] ifFalse:[ |
1683 |
items := #( |
|
2075 | 1684 |
('Copy' copySelection Copy ) |
1685 |
('Paste' pasteOrReplace Paste ) |
|
914 | 1686 |
('-' ) |
2506 | 1687 |
('Search...' search Find) |
1688 |
('-' ) |
|
2075 | 1689 |
('Font...' changeFont ) |
951 | 1690 |
('-' ) |
2448 | 1691 |
('Save As...' save SaveAs ) |
2075 | 1692 |
('Print' doPrint Print ) |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1693 |
('=' ) |
4487 | 1694 |
('More' more ) |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1695 |
('Shell' others Ctrl ) |
914 | 1696 |
). |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1697 |
m := PopUpMenu itemList:items resources:resources. |
4487 | 1698 |
m subMenuAt:#more put:moreMenu. |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
1699 |
m subMenuAt:#others put:subMenu. |
1347 | 1700 |
|
1701 |
"/ disabled - for now; |
|
1702 |
"/ need a more intelligent filtering of control characters. |
|
1703 |
"/ |
|
1704 |
"/ filterStream isNil ifTrue:[ |
|
1705 |
"/ items := items , #( |
|
1706 |
"/ ('-' ) |
|
2075 | 1707 |
"/ ('Start Save as ...' startSaveAs ) |
1708 |
"/ ('Start Print' startPrint ) |
|
1347 | 1709 |
"/ ) |
1710 |
"/ ] ifFalse:[ |
|
1711 |
"/ items := items , #( |
|
1712 |
"/ ('-' ) |
|
2075 | 1713 |
"/ ('Stop filter' stopFilter ) |
1347 | 1714 |
"/ ) |
1715 |
"/ ]. |
|
914 | 1716 |
]. |
1717 |
||
2810
d57cc02787de
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
2778
diff
changeset
|
1718 |
self hasSelection ifFalse:[ |
914 | 1719 |
m disable:#copySelection. |
1720 |
]. |
|
1721 |
^ m. |
|
1722 |
||
3225 | 1723 |
"Modified: / 03-04-2007 / 08:58:26 / cg" |
1347 | 1724 |
! |
1725 |
||
4487 | 1726 |
openFileBrowserOnIt |
1727 |
"open a fileBrowser on the selected fileName" |
|
1728 |
||
1729 |
|fileName| |
|
1730 |
||
1731 |
fileName := shellDirectory construct:self selectionAsString. |
|
1732 |
self openFileBrowserOnFileNamed:fileName |
|
1733 |
! |
|
1734 |
||
4295 | 1735 |
setGreenDisplayMode |
1736 |
self foregroundColor:Color green backgroundColor:Color black. |
|
1737 |
self cursorForegroundColor:Color black backgroundColor:Color green. |
|
1738 |
! |
|
1739 |
||
1740 |
setNormalDisplayMode |
|
1741 |
self foregroundColor:Color black backgroundColor:Color white. |
|
1742 |
self cursorForegroundColor:Color white backgroundColor:Color black. |
|
1743 |
! |
|
1744 |
||
4300 | 1745 |
setRedDisplayMode |
1746 |
self foregroundColor:(Color white) backgroundColor:(Color red:80). |
|
1747 |
self cursorForegroundColor:(Color red:80) backgroundColor:(Color white). |
|
1748 |
! |
|
1749 |
||
4295 | 1750 |
setReverseDisplayMode |
1751 |
|fg bg| |
|
1752 |
||
1753 |
fg := self foregroundColor. |
|
1754 |
bg := self backgroundColor. |
|
1755 |
self foregroundColor:bg backgroundColor:fg. |
|
1756 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
1757 |
! |
|
1758 |
||
1347 | 1759 |
startSaveAs |
1760 |
"start saving all received data to some file" |
|
1761 |
||
1762 |
|fn| |
|
1763 |
||
1764 |
fn := Dialog requestFileName:'Save received data in file:'. |
|
1765 |
fn size > 0 ifTrue:[ |
|
1766 |
filterStream := fn asFilename writeStream |
|
1767 |
]. |
|
1768 |
||
1769 |
"Created: / 29.4.1999 / 11:06:29 / cg" |
|
1770 |
! |
|
1771 |
||
1772 |
stopFilter |
|
1773 |
"stop saving/printing of received data" |
|
1774 |
||
1775 |
filterStream close. |
|
1776 |
filterStream := nil. |
|
1777 |
||
1778 |
"Created: / 29.4.1999 / 11:07:49 / cg" |
|
1779 |
"Modified: / 29.4.1999 / 11:09:52 / cg" |
|
914 | 1780 |
! ! |
1781 |
||
940 | 1782 |
!TerminalView methodsFor:'misc'! |
914 | 1783 |
|
1784 |
removeTrailingBlankLines |
|
1785 |
^ self |
|
4312 | 1786 |
! |
1787 |
||
1788 |
send:aString |
|
4313 | 1789 |
"send aString to the underlying program's stdinput" |
1790 |
||
4317 | 1791 |
aString notEmptyOrNil ifTrue:[ |
1792 |
recorderStream notNil ifTrue:[ |
|
1793 |
recorderStream nextPutAll:aString |
|
1794 |
]. |
|
4322 | 1795 |
Debug == true ifTrue:[ |
1796 |
Transcript showCR:'send <',aString,'>' |
|
1797 |
]. |
|
4317 | 1798 |
inStream nextPutAll:aString |
1799 |
]. |
|
4312 | 1800 |
|
1801 |
"Created: / 29-07-2013 / 18:18:24 / cg" |
|
1802 |
! |
|
1803 |
||
1804 |
sendCR:aString |
|
4313 | 1805 |
"send aString followed by a return to the underlying program's stdinput" |
1806 |
||
4317 | 1807 |
self send:aString. |
4312 | 1808 |
inputTranslateCRToNL ifTrue:[ |
4317 | 1809 |
self send:(String lf) |
4312 | 1810 |
] ifFalse:[ |
4317 | 1811 |
self send:(String cr) |
4312 | 1812 |
] |
1813 |
||
1814 |
"Created: / 29-07-2013 / 18:20:15 / cg" |
|
4317 | 1815 |
! |
1816 |
||
1817 |
sendCharacter:aCharacter |
|
1818 |
"send a single character to the underlying program's stdinput" |
|
1819 |
||
4479 | 1820 |
aCharacter bitsPerCharacter > 8 ifTrue:[ |
1821 |
Transcript showCR:(self class name,': invalid (non-8bit) character ignored'). |
|
1822 |
^ self |
|
1823 |
]. |
|
1824 |
||
4317 | 1825 |
recorderStream notNil ifTrue:[ |
1826 |
recorderStream nextPut:aCharacter |
|
1827 |
]. |
|
4322 | 1828 |
Debug == true ifTrue:[ |
1829 |
Transcript showCR:'send <',aCharacter,'>' |
|
1830 |
]. |
|
4593 | 1831 |
|
4321 | 1832 |
inStream nextPut:aCharacter. |
4317 | 1833 |
|
1834 |
"Created: / 29-07-2013 / 18:18:24 / cg" |
|
914 | 1835 |
! ! |
1836 |
||
2498 | 1837 |
!TerminalView methodsFor:'processing-input'! |
914 | 1838 |
|
1420 | 1839 |
doNothing |
1840 |
"private - end of an ignored escape-sequence" |
|
1841 |
||
1842 |
self endOfSequence |
|
1843 |
||
1844 |
"Created: / 12.6.1998 / 20:40:43 / cg" |
|
1845 |
! |
|
1846 |
||
1847 |
endOfSequence |
|
1848 |
"private - reset state-machine at end of escape-sequence" |
|
1849 |
||
1850 |
state := 0. |
|
1851 |
||
1852 |
"Created: / 12.6.1998 / 20:39:52 / cg" |
|
1853 |
! |
|
1854 |
||
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1855 |
nextPut:char |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1856 |
"process a character (i.e. the shells output)" |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1857 |
|
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1858 |
Debug ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1859 |
Transcript show:state; show:' '; showCR:char storeString. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1860 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1861 |
|
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1862 |
(char == Character nl) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1863 |
self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1864 |
self doCursorDown:1. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1865 |
^ self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1866 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1867 |
(char == Character return) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1868 |
self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1869 |
self cursorToBeginOfLine. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1870 |
^ self. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1871 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1872 |
(char == Character backspace) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1873 |
self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1874 |
self doCursorLeft:1. "/ doBackspace |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1875 |
^ self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1876 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1877 |
(char == Character bell) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1878 |
self beep. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1879 |
^ self |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1880 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1881 |
char asciiValue < 32 ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1882 |
char ~~ Character tab ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1883 |
char asciiValue ~~ 0 ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1884 |
Debug ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1885 |
Transcript show:'unhandled control key: '; showCR:char storeString. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1886 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1887 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1888 |
^ self. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1889 |
] |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1890 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1891 |
self show:char |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1892 |
|
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1893 |
"Modified: / 21.7.1998 / 20:06:04 / cg" |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1894 |
! |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1895 |
|
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1896 |
nextPutAll:aString |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1897 |
"/ self processInput:aString n:aString size |
2594 | 1898 |
|
4285 | 1899 |
Debug ifTrue:[ |
1900 |
Transcript |
|
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1901 |
show:(self class name); show:': nextPutAll - state: '; show:state; |
4285 | 1902 |
show:' got: '; |
1903 |
showCR:aString |
|
1904 |
]. |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1905 |
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
|
1906 |
|
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1907 |
"Created: / 27.7.1998 / 15:10:59 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1908 |
"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
|
1909 |
! |
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1910 |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1911 |
processInput:buffer n:count |
4315 | 1912 |
"actually: output coming from the connected application (aka input to me); |
1913 |
the stuff coming from the application is a mix of plain text and CSI escape sequences. |
|
1914 |
If we process each character individually, things are trivial, but slow. |
|
1915 |
Therefore, we collect big chunks of non-escaped text and buffer them to make |
|
1916 |
use of the inherited buffered output optimizations (see TextCollector). |
|
1917 |
Thus, we collect until an escape sequence is encountered, and flush the buffered stuff then, |
|
1918 |
proceed in single-character mode (processState0:) until the sequence is finished, and continue |
|
1919 |
collecting. |
|
1920 |
This makes this terminalView's speed usable and actually competitive with some existing |
|
1921 |
console applications (it is *much* faster than the MSWindows command.com window, btw.)" |
|
1922 |
||
997 | 1923 |
|sensor| |
1924 |
||
4315 | 1925 |
"/ remember how much is in the queue... |
1926 |
[ |
|
1927 |
sizeOfOutstandingInputToBeProcessed := sizeOfOutstandingInputToBeProcessed - count. |
|
1928 |
] valueUninterruptably. |
|
4449 | 1929 |
"/ Debug := true |
4450 | 1930 |
"/ Debug := false |
4285 | 1931 |
Debug ifTrue:[ |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1932 |
Transcript show:self class name; show:': processInput - state: '; show: state; |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1933 |
show:' got: '; showCR: count. |
4285 | 1934 |
]. |
1935 |
||
1347 | 1936 |
filterStream notNil ifTrue:[ |
1937 |
filterStream nextPutAll:(buffer copyTo:count). |
|
1938 |
]. |
|
4267 | 1939 |
"/ '*' print. (buffer copyTo:count) asByteArray hexPrintString printCR. |
1347 | 1940 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
1941 |
"/ self hideCursor. |
997 | 1942 |
|
1015 | 1943 |
"/ the following may not be too clean, but adds a lot of speed. |
1944 |
"/ instead of passing every individual character through the |
|
1945 |
"/ escape-state machine, collect chunks of non-control text |
|
1946 |
"/ when in state 0, and add them immediately to the pendingLines |
|
1947 |
"/ collection of the textCollectors asynchronous update mechanism. |
|
1948 |
"/ This helps a lot if you do something like "ls -lR /" ... |
|
1949 |
"/ For debugging the state machine, reenable the commented lines |
|
1950 |
"/ below. |
|
1951 |
||
1952 |
"/1 to:count do:[:i| |
|
1953 |
"/ self nextPut:(buffer at:i). |
|
1954 |
"/]. |
|
1955 |
"/self showCursor. |
|
1956 |
"/^ self. |
|
1957 |
||
1958 |
access critical:[ |
|
2191 | 1959 |
|index controlCharIndex stringWithOutControl crnlFollows| |
997 | 1960 |
|
2191 | 1961 |
index := 1. |
1962 |
[index <= count] whileTrue:[ |
|
4290 | 1963 |
stringWithOutControl := nil. |
1964 |
||
4321 | 1965 |
(state == 0) ifTrue:[ |
4267 | 1966 |
"/ in initial state: |
1015 | 1967 |
"/ quick scan forward for next control character ... |
2191 | 1968 |
controlCharIndex := buffer indexOfControlCharacterStartingAt:index. |
1969 |
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
|
1970 |
|
2191 | 1971 |
controlCharIndex == 0 ifTrue:[ |
1015 | 1972 |
"/ no control characters - simply append all |
4267 | 1973 |
"/ to the outstanding lines... |
2191 | 1974 |
stringWithOutControl := buffer copyFrom:index to:count. |
4267 | 1975 |
crnlFollows := false. |
2191 | 1976 |
index := count + 1. "/ leave loop. |
1015 | 1977 |
] ifFalse:[ |
2191 | 1978 |
controlCharIndex > index ifTrue:[ |
4267 | 1979 |
"/ some more regular character(s) before control character |
2191 | 1980 |
stringWithOutControl := buffer copyFrom:index to:controlCharIndex-1. |
1981 |
index := controlCharIndex. "/ proceed withcontrol character |
|
1015 | 1982 |
crnlFollows := false. |
2191 | 1983 |
index < (count - 1) ifTrue:[ |
1984 |
(buffer at:index) == Character return ifTrue:[ |
|
1985 |
(buffer at:index+1) == Character nl ifTrue:[ |
|
1015 | 1986 |
crnlFollows := true. |
2191 | 1987 |
index := index + 2. |
1015 | 1988 |
] |
997 | 1989 |
] |
1015 | 1990 |
]. |
4267 | 1991 |
] ifFalse:[ |
1992 |
"/ controlchr immediately follows |
|
1015 | 1993 |
] |
1994 |
]. |
|
997 | 1995 |
]. |
1996 |
||
2191 | 1997 |
stringWithOutControl notNil ifTrue:[ |
2356 | 1998 |
(cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[ |
4321 | 1999 |
"/ characterwise, for correct wrap handling at line end |
2268 | 2000 |
stringWithOutControl do:[:eachCharacter | |
2001 |
self nextPut:eachCharacter. |
|
4452 | 2002 |
self endEntry. |
2003 |
cursorCol >= numberOfColumns ifTrue:[ |
|
2004 |
self validateCursorCol:cursorCol inLine:cursorLine. |
|
2005 |
]. |
|
2268 | 2006 |
]. |
2356 | 2007 |
crnlFollows ifTrue:[ |
2008 |
self nextPut:Character return. |
|
2009 |
self nextPut:Character nl. |
|
2010 |
]. |
|
2011 |
self endEntry. |
|
997 | 2012 |
] ifFalse:[ |
2356 | 2013 |
|
2014 |
Debug ifTrue:[ |
|
2015 |
Transcript showCR:'String:<', stringWithOutControl, '>'. |
|
2016 |
]. |
|
2017 |
currentEmphasis notNil ifTrue:[ |
|
2018 |
stringWithOutControl := stringWithOutControl emphasizeAllWith:currentEmphasis |
|
2019 |
]. |
|
2020 |
||
4449 | 2021 |
access critical:[ |
2022 |
outstandingLine size > 0 ifTrue:[ |
|
2023 |
outstandingLine := outstandingLine , stringWithOutControl. |
|
2024 |
] ifFalse:[ |
|
2025 |
outstandingLine := stringWithOutControl. |
|
2026 |
]. |
|
2027 |
crnlFollows ifTrue:[ |
|
2028 |
"/ 'xp' printCR. |
|
2029 |
outstandingLines isNil ifTrue:[ |
|
2030 |
outstandingLines := OrderedCollection with:outstandingLine |
|
2031 |
] ifFalse:[ |
|
2032 |
outstandingLines add:outstandingLine. |
|
2033 |
]. |
|
2034 |
outstandingLine := ''. |
|
2035 |
]. |
|
1015 | 2036 |
]. |
4321 | 2037 |
"/ collecting ifTrue:[ |
2038 |
"/ flushPending ifFalse:[ |
|
2039 |
"/ self installDelayedUpdate |
|
2040 |
"/ ] ifTrue:[ |
|
2041 |
"/ "/ outstandingLines size > collectSize ifTrue:[ |
|
2042 |
"/ "/ self endEntry |
|
2043 |
"/ "/ ] |
|
2044 |
"/ ] |
|
2045 |
"/ ] ifFalse:[ |
|
2046 |
"/ self endEntry |
|
2047 |
"/ ]. |
|
1015 | 2048 |
]. |
997 | 2049 |
] ifFalse:[ |
1015 | 2050 |
"/ no chunk to append (in an escape sequence) |
2051 |
"/ must handle individual characters |
|
2052 |
"/ 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
|
2053 |
|
4290 | 2054 |
"/ self endEntry. |
2207 | 2055 |
self nextPut:(buffer at:index). |
2191 | 2056 |
index := index + 1. |
2057 |
[state ~~ 0 and:[index <= count]] whileTrue:[ |
|
2207 | 2058 |
self nextPut:(buffer at:index). |
2191 | 2059 |
index := index + 1. |
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2060 |
] |
1015 | 2061 |
] |
2062 |
]. |
|
4321 | 2063 |
"/ inFlush := false. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2064 |
]. |
948 | 2065 |
|
4321 | 2066 |
(state == 0 and:[self shown]) ifTrue:[ |
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2067 |
(sensor := self sensor) notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2068 |
"/ 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
|
2069 |
"/ enforce update of the view (asynchronous) |
997 | 2070 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2071 |
(sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
997 | 2072 |
self endEntry. |
2073 |
self showCursor. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2074 |
"/ self makeCursorVisible. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2075 |
] ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2076 |
"/ 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
|
2077 |
"/ 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
|
2078 |
"/ 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
|
2079 |
"/ 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
|
2080 |
"/ collectSize lines. |
1015 | 2081 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2082 |
outstandingLines size > collectSize ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2083 |
self endEntry. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2084 |
self showCursor. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2085 |
|
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2086 |
"/ 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
|
2087 |
windowGroup notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2088 |
windowGroup processRealExposeEventsFor:self. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2089 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2090 |
]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2091 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2092 |
]. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2093 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2094 |
|
4315 | 2095 |
"Created: / 10-06-1998 / 17:26:09 / cg" |
2096 |
"Modified: / 28-01-2002 / 20:41:36 / micha" |
|
2097 |
"Modified: / 30-07-2013 / 10:47:19 / cg" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2098 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2099 |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2100 |
sendLine:aString |
4285 | 2101 |
Debug ifTrue:[ |
4290 | 2102 |
'VT100: sendline: ' print. aString asByteArray hexPrintString printCR |
4285 | 2103 |
]. |
4290 | 2104 |
|
4317 | 2105 |
self send:aString. |
4215 | 2106 |
OperatingSystem isMSDOSlike ifTrue:[ |
4317 | 2107 |
self send:String crlf |
4215 | 2108 |
] ifFalse:[ |
4317 | 2109 |
self send:String cr |
4215 | 2110 |
]. |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2111 |
! |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2112 |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2113 |
sync |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2114 |
self waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2115 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2116 |
"Created: / 27.7.1998 / 23:49:44 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2117 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2118 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2119 |
waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2120 |
|sensor| |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2121 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2122 |
sensor := self sensor. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2123 |
(sensor notNil and:[sensor userEventCount > 30]) ifTrue:[ |
1323 | 2124 |
[sensor userEventCount > 5] whileTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2125 |
"/ give terminalView a chance to |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2126 |
"/ catch up. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2127 |
Delay waitForSeconds:0.1. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2128 |
] |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2129 |
]. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2130 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2131 |
"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
|
2132 |
"Modified: / 5.5.1999 / 18:51:00 / cg" |
914 | 2133 |
! ! |
2134 |
||
2135 |
!TerminalView methodsFor:'queries'! |
|
2136 |
||
2137 |
preferredExtent |
|
1420 | 2138 |
"return my preferred extent - this is computed from my numberOfLines, |
2139 |
numberOfCols and font size" |
|
2140 |
||
2268 | 2141 |
^ (fontWidth * self class defaultNumberOfColumns + (leftMargin + margin * 2)) |
951 | 2142 |
@ |
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2143 |
((self heightForLines:self class defaultNumberOfLines) + 8) |
926 | 2144 |
|
979 | 2145 |
"Modified: / 20.6.1998 / 20:06:57 / cg" |
929 | 2146 |
! |
2147 |
||
2148 |
terminalType |
|
1420 | 2149 |
"returns a string describing this terminal (usually, this is |
2150 |
passed down to the shell as TERM environment variable). |
|
2151 |
Here, 'dump' is returned." |
|
2152 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
2153 |
^ 'dump' |
929 | 2154 |
|
2155 |
"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
|
2156 |
"Modified: / 5.5.1999 / 11:22:32 / cg" |
914 | 2157 |
! ! |
2158 |
||
4265 | 2159 |
!TerminalView methodsFor:'reader process'! |
2160 |
||
4315 | 2161 |
readAnyAvailableData |
2162 |
"read data from the stream, |
|
2163 |
and sends me #processInput:n: events if something arrived. |
|
2164 |
Returns the amount of data read." |
|
2165 |
||
2166 |
|buffer n bufferSize| |
|
2167 |
||
2168 |
outStream isNil ifTrue:[^ 0]. |
|
2169 |
||
2170 |
"/ avoid too many processInput messages to be in the buffer, |
|
2171 |
"/ otherwise, the reaction on ctrl-s/ctrl-c is too slow, as |
|
2172 |
"/ many processInput messages are in the sensor's queue before the keypress |
|
2173 |
"/ event. We need another queue, actually so the sensor's keypress events |
|
2174 |
"/ are not blocked while reading a lot of input. |
|
2175 |
[sizeOfOutstandingInputToBeProcessed > 4096] whileTrue:[ |
|
2176 |
Delay waitForSeconds:0.1 |
|
2177 |
]. |
|
2178 |
||
4338 | 2179 |
bufferSize := 1024. |
4315 | 2180 |
|
2181 |
buffer := String new:bufferSize. |
|
2182 |
ExternalStream readErrorSignal handle:[:ex | |
|
2183 |
n := 0 |
|
2184 |
] do:[ |
|
2185 |
n := outStream nextAvailableBytes:bufferSize into:buffer startingAt:1. |
|
2186 |
]. |
|
2187 |
n > 0 ifTrue:[ |
|
2188 |
self pushEvent:#processInput:n: with:buffer with:n. |
|
2189 |
"/ remember how much is in the queue... |
|
2190 |
[ |
|
2191 |
sizeOfOutstandingInputToBeProcessed := sizeOfOutstandingInputToBeProcessed + n. |
|
2192 |
] valueUninterruptably |
|
2193 |
]. |
|
2194 |
||
2195 |
^ n |
|
2196 |
||
2197 |
"Created: / 05-05-1999 / 17:57:39 / cg" |
|
2198 |
"Modified: / 28-01-2002 / 21:10:25 / micha" |
|
2199 |
"Modified (comment): / 30-07-2013 / 10:50:03 / cg" |
|
2200 |
! |
|
2201 |
||
4265 | 2202 |
readerProcessLoop |
2203 |
"look for the commands output, |
|
2204 |
and send me #processInput:n: events whenever something arrives." |
|
2205 |
||
2206 |
StreamError handle:[:ex | |
|
2207 |
Transcript show:'Terminal(PTY-reader) [error]: '; showCR:ex description. |
|
2208 |
] do:[ |
|
2209 |
[true] whileTrue:[ |
|
2210 |
AbortOperationRequest handle:[:ex | |
|
2211 |
self showCursor. |
|
4457 | 2212 |
(outStream isNil or:[outStream atEnd]) ifTrue:[ ex reject ]. |
4265 | 2213 |
] do:[ |
2214 |
|n sensor| |
|
2215 |
||
2216 |
Delay waitForSeconds:0.01. |
|
2217 |
outStream readWait. |
|
2218 |
sensor := self sensor. |
|
2219 |
(sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[ |
|
2220 |
true "(sensor userEventCount > 10)" ifTrue:[ |
|
2221 |
"/ give terminalView a chance to |
|
2222 |
"/ send out the character. |
|
4321 | 2223 |
"/ Transcript showCR:'d'. |
4265 | 2224 |
Delay waitForSeconds:0.01. |
2225 |
] |
|
2226 |
] ifFalse:[ |
|
2227 |
n := self readAnyAvailableData. |
|
2228 |
n > 0 ifTrue:[ |
|
2229 |
shellPid notNil ifTrue:[ |
|
2230 |
self waitForOutputToDrain. |
|
2231 |
] |
|
2232 |
] ifFalse:[ |
|
2233 |
n == 0 ifTrue:[ |
|
2234 |
"/ Windows IPC has a bug - it always |
|
2235 |
"/ returns 0 (when the command is idle) |
|
2236 |
"/ and says its at the end (sigh) |
|
2237 |
||
2238 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
2239 |
Delay waitForSeconds:0.01 |
|
2240 |
] ifFalse:[ |
|
2241 |
outStream atEnd ifTrue:[ |
|
4327 | 2242 |
self closeStreams. |
4265 | 2243 |
Processor activeProcess terminate. |
2244 |
] ifFalse:[ |
|
2245 |
"/ this should not happen. |
|
2246 |
||
2247 |
Delay waitForSeconds:0.05 |
|
2248 |
] |
|
2249 |
]. |
|
2250 |
] |
|
2251 |
] |
|
2252 |
] |
|
2253 |
] |
|
2254 |
] |
|
2255 |
] |
|
4315 | 2256 |
|
2257 |
"Modified: / 30-07-2013 / 10:30:38 / cg" |
|
4265 | 2258 |
! |
2259 |
||
2260 |
startReaderProcess |
|
2261 |
"Start a reader process, which looks for the commands output, |
|
2262 |
and sends me #processInput:n: events whenever something arrives." |
|
2263 |
||
2264 |
self obsoleteMethodWarning. |
|
2265 |
self startReaderProcessWhenVisible. |
|
2266 |
||
2267 |
" |
|
2268 |
VT100TerminalView openShell |
|
2269 |
" |
|
2270 |
||
2271 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
|
2272 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
|
2273 |
! |
|
2274 |
||
2275 |
startReaderProcessNow |
|
2276 |
"Start a reader process, which looks for the commands output, |
|
2277 |
and sends me #processInput:n: events whenever something arrives." |
|
2278 |
||
2279 |
readerProcess isNil ifTrue:[ |
|
2280 |
readerProcess := [ |
|
2281 |
[ |
|
2282 |
self readerProcessLoop. |
|
2283 |
] ifCurtailed:[ |
|
2284 |
readerProcess := nil |
|
2285 |
] |
|
2286 |
] fork. "/ forkAt:9. |
|
2287 |
readerProcess name:'pty reader'. |
|
2288 |
] |
|
2289 |
||
2290 |
" |
|
2291 |
VT100TerminalView openShell |
|
2292 |
" |
|
2293 |
||
2294 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
|
2295 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
|
2296 |
! |
|
2297 |
||
2298 |
startReaderProcessWhenVisible |
|
2299 |
"Start a reader process, which looks for the commands output, |
|
2300 |
and sends me #processInput:n: events whenever something arrives." |
|
2301 |
||
2302 |
readerProcess isNil ifTrue:[ |
|
2303 |
readerProcess := [ |
|
2304 |
[ |
|
2305 |
self waitUntilVisible. |
|
2306 |
self readerProcessLoop. |
|
2307 |
] ifCurtailed:[ |
|
2308 |
readerProcess := nil |
|
2309 |
] |
|
2310 |
] fork. "/ forkAt:9. |
|
2311 |
readerProcess name:'pty reader'. |
|
2312 |
] |
|
2313 |
||
2314 |
" |
|
2315 |
VT100TerminalView openShell |
|
2316 |
" |
|
2317 |
||
2318 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
|
2319 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
|
2320 |
! |
|
2321 |
||
2322 |
stopReaderProcess |
|
2323 |
"stop the background reader thread" |
|
2324 |
||
2325 |
|sensor| |
|
2326 |
||
2327 |
readerProcess notNil ifTrue:[ |
|
2328 |
readerProcess terminate. |
|
2329 |
"/ give it a chance to really terminate |
|
2330 |
Processor yield. |
|
2331 |
readerProcess := nil |
|
2332 |
]. |
|
2333 |
||
2334 |
"/ flush any leftover input-processing events |
|
2335 |
(sensor := self sensor) notNil ifTrue:[ |
|
2336 |
sensor flushEventsFor:self withType:#processInput:n:. |
|
2337 |
] |
|
2338 |
"Modified: / 21.7.1998 / 19:00:13 / cg" |
|
2339 |
! ! |
|
2340 |
||
2506 | 2341 |
!TerminalView methodsFor:'searching'! |
2342 |
||
2343 |
startPositionForSearchBackward |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2344 |
^ self startPositionForSearchBackwardBasedOnSelection |
2506 | 2345 |
! |
2346 |
||
2347 |
startPositionForSearchForward |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2348 |
^ self startPositionForSearchForwardBasedOnSelection |
2506 | 2349 |
! ! |
2350 |
||
914 | 2351 |
!TerminalView methodsFor:'selection handling'! |
2352 |
||
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2353 |
autoMoveCursorToEndOfSelection |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2354 |
"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
|
2355 |
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
|
2356 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2357 |
^ false |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2358 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2359 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2360 |
|
914 | 2361 |
paste:someText |
2362 |
"paste - redefined to send the chars to the shell instead |
|
2363 |
of pasting into the view" |
|
2364 |
||
950 | 2365 |
|s nLines| |
2366 |
||
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2367 |
inStream isNil ifTrue:[ |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2368 |
self flash. |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2369 |
^ self "/ already closed |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2370 |
]. |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2371 |
|
950 | 2372 |
s := someText. |
2373 |
s isString ifTrue:[ |
|
2374 |
s := s asStringCollection |
|
2375 |
] ifFalse:[ |
|
2376 |
(s isKindOf:StringCollection) ifFalse:[ |
|
2377 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
2378 |
^ self |
|
2379 |
] |
|
2380 |
]. |
|
2381 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
2382 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
|
4285 | 2383 |
|
950 | 2384 |
s keysAndValuesDo:[:idx :line | |
4285 | 2385 |
line notNil ifTrue:[ |
2386 |
Debug ifTrue:[ |
|
2387 |
Transcript showCR:'send paste line: ',line asByteArray hexPrintString |
|
2388 |
]. |
|
2389 |
]. |
|
950 | 2390 |
idx ~~ nLines ifTrue:[ |
4317 | 2391 |
self sendLine:line |
2392 |
] ifFalse:[ |
|
2393 |
self send:line |
|
950 | 2394 |
] |
2395 |
]. |
|
2396 |
||
2397 |
"Modified: / 12.6.1998 / 22:12:47 / cg" |
|
4490 | 2398 |
! |
2399 |
||
2400 |
selection |
|
2401 |
|sel| |
|
2402 |
||
2403 |
sel := super selection. |
|
4492 | 2404 |
sel isNil ifTrue:[^ sel]. |
4490 | 2405 |
|
2406 |
"/ if it is a line-wise collection, return multiple lines; |
|
2407 |
"/ otherwise, concatenate to make it one long string. |
|
2408 |
"/ this allows for multi-line commands (many args) to be copy-pasted easily |
|
2409 |
selectionStartCol == 1 ifTrue:[ |
|
2410 |
selectionEndCol == 0 ifTrue:[ |
|
2411 |
^ sel "/ a full-line (3xclick selection) |
|
2412 |
]. |
|
2413 |
]. |
|
2414 |
^ StringCollection with:(sel asStringWith:''). |
|
914 | 2415 |
! ! |
2416 |
||
2417 |
!TerminalView class methodsFor:'documentation'! |
|
2418 |
||
2419 |
version |
|
4596 | 2420 |
^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.179 2014-06-01 15:41:38 cg Exp $' |
3758 | 2421 |
! |
2422 |
||
2423 |
version_CVS |
|
4596 | 2424 |
^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.179 2014-06-01 15:41:38 cg Exp $' |
914 | 2425 |
! ! |
2205 | 2426 |
|
4164 | 2427 |
|
2205 | 2428 |
TerminalView initialize! |