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