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