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