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