author | Claus Gittinger <cg@exept.de> |
Fri, 28 Jun 2019 09:21:50 +0200 | |
changeset 6078 | 08c9e2a47dc5 |
parent 6044 | e7fd53f408b8 |
child 6096 | 4de6a6b2f700 |
permissions | -rw-r--r-- |
6078 | 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 |
|
5288 | 28 |
lineBufferHistory lineBufferHistoryPosition |
29 |
lineBufferHistoryChanged maxHistorySize doUTF ignoreOutput |
|
30 |
sendControlKeys lastSelectedLineBufferHistoryPosition inputIsUTF8 |
|
31 |
outputIsUTF8 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 |
|
5307 | 114 |
lineEditMode if on, do readLine-alike input history and editing |
4598 | 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. |
5288 | 548 |
lineBufferHistoryChanged := false. |
549 |
! |
|
550 |
||
551 |
lineBufferHistoryChanged |
|
552 |
"true if it changed since either set explicitly or since the terminal was opened" |
|
553 |
||
554 |
^ lineBufferHistoryChanged ? false |
|
4639 | 555 |
! |
556 |
||
4803 | 557 |
masterWindow:aTopView |
558 |
"if set, and a corresponding osCommand escape sequence is received, |
|
559 |
that topView's title, icon or other attribute is changed. |
|
560 |
Needed to support xterm's 'set window title' escape sequence" |
|
561 |
||
562 |
masterWindow := aTopView. |
|
4299 | 563 |
! |
564 |
||
914 | 565 |
outStream |
2954 | 566 |
"return the stream, which is used to present data in the view (i.e. shell output)" |
914 | 567 |
|
2075 | 568 |
^ outStream |
569 |
! |
|
914 | 570 |
|
571 |
outStream:something |
|
2954 | 572 |
"set the stream, which is used to present data in the view (i.e. shell output)" |
914 | 573 |
|
2075 | 574 |
outStream := something. |
575 |
! |
|
946 | 576 |
|
1004 | 577 |
readerProcess |
578 |
^ readerProcess |
|
579 |
! |
|
580 |
||
4317 | 581 |
recorderStream:aWriteStream |
582 |
"set a recorder stream; if not nil, it gets all user input (keyboard) data via nextPut:. |
|
4803 | 583 |
Allows saving of user input to a file, for later replay of a session" |
4317 | 584 |
|
585 |
recorderStream := aWriteStream. |
|
586 |
! |
|
587 |
||
4803 | 588 |
shellDirectory:aPathname |
589 |
"the directory, in which the shell/command should be executed. |
|
590 |
By default, the 'current' directory is used" |
|
591 |
||
592 |
shellDirectory := aPathname. |
|
4630 | 593 |
! |
594 |
||
946 | 595 |
shellTerminateAction:aBlock |
596 |
"set the block which is evaluated when the shell terminates. |
|
5144 | 597 |
Can be used to close down the application or perform any other cleanup action. |
598 |
The default shows a dialog, that the shell/command has terminated" |
|
946 | 599 |
|
600 |
shellTerminateAction := aBlock. |
|
601 |
||
602 |
"Created: / 12.6.1998 / 17:02:58 / cg" |
|
4803 | 603 |
! ! |
604 |
||
5638 | 605 |
!TerminalView methodsFor:'accessing-behavior'! |
4803 | 606 |
|
5763 | 607 |
disableLineEditMode |
608 |
self lineEditMode:false. |
|
609 |
! |
|
610 |
||
611 |
enableLineEditMode |
|
612 |
self lineEditMode:true. |
|
613 |
! |
|
614 |
||
5249 | 615 |
filterOnly:aBoolean |
616 |
"if true, any output from the program is ONLY |
|
617 |
sent to the filterStream (if any), not to the window. |
|
618 |
Can be used to divert output to a file, without showing |
|
619 |
it (eg. for mass-data recording)" |
|
620 |
||
621 |
filterOnly := aBoolean |
|
622 |
! |
|
623 |
||
624 |
ignoreOutput:aBoolean |
|
625 |
"if true, any output from the program is ignored |
|
626 |
(not processed at all). |
|
627 |
Can be used to temporarily disable processing |
|
628 |
(for example via a button) when huge mass-output is |
|
629 |
coming which we want to ignore." |
|
630 |
||
631 |
ignoreOutput := aBoolean |
|
632 |
! |
|
633 |
||
4803 | 634 |
inputTranslateBackspaceToDelete |
5149 | 635 |
"translating backspace to delete on user input" |
5145 | 636 |
|
4803 | 637 |
^ inputTranslateBackspaceToDelete |
638 |
! |
|
639 |
||
640 |
inputTranslateBackspaceToDelete:aBoolean |
|
641 |
inputTranslateBackspaceToDelete := aBoolean. |
|
642 |
! |
|
643 |
||
644 |
inputTranslateCRToNL |
|
5149 | 645 |
"translating <RETURN> to <NL> on user input" |
5145 | 646 |
|
4803 | 647 |
^ inputTranslateCRToNL |
648 |
! |
|
649 |
||
650 |
inputTranslateCRToNL:aBoolean |
|
5149 | 651 |
"translate <RETURN> to <NL> on user input" |
652 |
||
4803 | 653 |
inputTranslateCRToNL := aBoolean. |
654 |
! |
|
655 |
||
5145 | 656 |
lineEditMode:aBoolean |
657 |
"if true, I do some limited line editing for the user's input; |
|
658 |
the user can use cursor keys to navigate in the input history and |
|
659 |
reissue a previously entered input line. |
|
660 |
Special: <SHIFT>-cursor up goes back to the previously selected history line. |
|
661 |
(not to the previous line). |
|
662 |
For example, if the user types: |
|
663 |
a <RETURN> |
|
664 |
b <RETURN> |
|
665 |
c <RETURN> |
|
666 |
<CURSOR-UP> -> shows 'c' |
|
667 |
<CURSOR-UP> -> shows 'b' |
|
668 |
<CURSOR-UP> -> shows 'a' |
|
669 |
123 <RETURN> -> resends 'a123' |
|
670 |
<SHIFT-CURSOR-UP> -> shows 'a' again which is the previously selected history line(not a123) |
|
671 |
<CURSOR-DOWN> -> shows 'b' |
|
672 |
<RETURN> -> sends 'b' |
|
673 |
" |
|
674 |
||
675 |
lineEditMode := aBoolean. |
|
4803 | 676 |
! |
677 |
||
678 |
localEcho:aBoolean |
|
679 |
"enable/disable local echo" |
|
680 |
||
681 |
localEcho := aBoolean |
|
682 |
||
683 |
"Created: / 5.5.1999 / 17:53:16 / cg" |
|
684 |
! |
|
685 |
||
686 |
noColors |
|
687 |
"the noColors boolean disables color changes (from color rendition escape sequences)" |
|
688 |
||
689 |
^ noColors |
|
690 |
! |
|
691 |
||
692 |
noColors:aBoolean |
|
693 |
"the noColors boolean disables color changes (from color rendition escape sequences)" |
|
694 |
||
695 |
noColors := aBoolean. |
|
696 |
! |
|
697 |
||
698 |
sendControlKeys |
|
699 |
"there is some conflict with control key handling, for keys such as CTRL-c: |
|
700 |
it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key). |
|
701 |
For this, we look if there is a current selection, and if so, always treat it as a |
|
702 |
shortcut (and NOT sending it to the terminal's program). |
|
703 |
Otherwise, if there is no selection, look at the 'sendControlKeys' boolean. |
|
704 |
If it is set (which is the default), then send it to the terminal, otherwise perform the editor op. |
|
705 |
Thus, an application containing me can offer a menu function (or toggle), |
|
706 |
to control this behavior on the UI level." |
|
707 |
||
708 |
^ sendControlKeys |
|
709 |
! |
|
710 |
||
711 |
sendControlKeys:aBoolean |
|
712 |
"there is some conflict with control key handling, for keys such as CTRL-c: |
|
713 |
it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key). |
|
714 |
For this, we look if there is a current selection, and if so, always treat it as a |
|
715 |
shortcut (and NOT sending it to the terminal's program). |
|
716 |
Otherwise, if there is no selection, look at the 'sendControlKeys' boolean. |
|
717 |
If it is set (which is the default), then send it to the terminal, otherwise perform the editor op. |
|
718 |
Thus, an application containing me can offer a menu function (or toggle), |
|
719 |
to control this behavior on the UI level." |
|
720 |
||
721 |
sendControlKeys := aBoolean |
|
2076 | 722 |
! |
723 |
||
5008 | 724 |
signalControlKeys |
725 |
"if true (default on Windows), CTRL-C sends an interrupt to |
|
726 |
the program. Otherwise, it is sent as a character (0x03)" |
|
727 |
||
728 |
^ signalControlKeys |
|
729 |
! |
|
730 |
||
731 |
signalControlKeys:aBoolean |
|
732 |
"if true (default on Windows), CTRL-C sends an interrupt to |
|
733 |
the program. Otherwise, it is sent as a character (0x03)" |
|
734 |
||
735 |
signalControlKeys := aBoolean |
|
736 |
! |
|
737 |
||
2076 | 738 |
translateNLToCRNL |
5145 | 739 |
"translate NL to CRNL on output" |
740 |
||
2076 | 741 |
^ translateNLToCRNL |
742 |
||
743 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
744 |
! |
|
745 |
||
4266 | 746 |
translateNLToCRNL:aBoolean |
5145 | 747 |
"translate NL to CRNL on output" |
748 |
||
4266 | 749 |
translateNLToCRNL := aBoolean. |
2076 | 750 |
|
751 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
946 | 752 |
! ! |
914 | 753 |
|
754 |
!TerminalView methodsFor:'cursor handling'! |
|
755 |
||
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
756 |
cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
757 |
cursorLine + n > list size ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
758 |
list := list , (Array new:n). |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
759 |
self textChanged. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
760 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
761 |
super cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
762 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
763 |
"Modified: / 10.6.1998 / 17:18:41 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
764 |
"Created: / 10.6.1998 / 17:18:50 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
765 |
! |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
766 |
|
968
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
767 |
cursorMovementAllowed |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
768 |
"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
|
769 |
(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
|
770 |
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
|
771 |
cursor positioning escape sequences arriving from the |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
772 |
stream." |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
773 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
774 |
^ false |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
775 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
776 |
"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
|
777 |
! |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
778 |
|
2169 | 779 |
numberOfTerminalCols |
780 |
^ numberOfColumns |
|
781 |
! |
|
782 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
783 |
numberOfTerminalColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
784 |
^ numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
785 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
786 |
"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
|
787 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
788 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
789 |
numberOfTerminalLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
790 |
"/ 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
|
791 |
"/ 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
|
792 |
"/ in ListView ... |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
793 |
"/ ... 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
|
794 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
795 |
^ numberOfLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
796 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
797 |
"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
|
798 |
"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
|
799 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
800 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
801 |
restoreCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
802 |
|l c| |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
803 |
|
2192 | 804 |
savedCursor isNil ifTrue:[ |
805 |
l := c := 1. |
|
806 |
] ifFalse:[ |
|
807 |
l := savedCursor y. |
|
808 |
c := savedCursor x. |
|
809 |
]. |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
810 |
self cursorLine:l col:c. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
811 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
812 |
"Created: / 14.8.1998 / 13:49:24 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
813 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
814 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
815 |
saveCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
816 |
savedCursor := cursorCol @ cursorLine |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
817 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
818 |
"Created: / 14.8.1998 / 13:48:45 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
819 |
"Modified: / 14.8.1998 / 13:49:32 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
820 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
821 |
|
914 | 822 |
validateCursorCol:col inLine:line |
823 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
824 |
Here, the linelength is enforced" |
|
825 |
||
2268 | 826 |
col > numberOfColumns ifTrue:[ |
827 |
autoWrapFlag ifTrue:[ |
|
828 |
self endEntry. |
|
4452 | 829 |
self cursorLine:(self cursorLine + 1) col:1 " (col-numberOfColumns) ". |
2268 | 830 |
^ 1. |
831 |
]. |
|
832 |
]. |
|
926 | 833 |
^ col min:numberOfColumns |
914 | 834 |
|
926 | 835 |
"Modified: / 10.6.1998 / 15:09:41 / cg" |
914 | 836 |
! ! |
837 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
838 |
!TerminalView methodsFor:'defaults'! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
839 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
840 |
anyKeyCodes |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
841 |
^ IdentityDictionary withKeysAndValues: |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
842 |
#( |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
843 |
#Escape '\e' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
844 |
#BackSpace '\b' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
845 |
#Return '\r' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
846 |
#Delete '\0177' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
847 |
#Tab '\t' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
848 |
) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
849 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
850 |
"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
|
851 |
! ! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
852 |
|
914 | 853 |
!TerminalView methodsFor:'event handling'! |
854 |
||
951 | 855 |
computeNumberOfLinesShown |
856 |
|prevNLines prevNCols| |
|
857 |
||
4518 | 858 |
prevNCols := (innerWidth // gc font width). |
951 | 859 |
prevNLines := nFullLinesShown. |
860 |
||
861 |
super computeNumberOfLinesShown. |
|
862 |
||
4518 | 863 |
((innerWidth // gc font width) ~~ prevNCols |
951 | 864 |
or:[prevNLines ~~ nFullLinesShown]) ifTrue:[ |
865 |
self defineWindowSize. |
|
866 |
] |
|
867 |
||
868 |
"Created: / 12.6.1998 / 22:34:39 / cg" |
|
979 | 869 |
"Modified: / 20.6.1998 / 19:45:28 / cg" |
951 | 870 |
! |
871 |
||
1359 | 872 |
contentsChanged |
4256 | 873 |
"this one is sent, whenever contents changes its size" |
874 |
||
1359 | 875 |
super contentsChanged. |
2594 | 876 |
"/ self defineWindowSize. |
1359 | 877 |
|
878 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
|
879 |
"Created: / 5.5.1999 / 16:30:15 / cg" |
|
880 |
! |
|
881 |
||
943 | 882 |
defineWindowSize |
2192 | 883 |
| delta prevNumCols prevNumLines| |
1359 | 884 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
885 |
"/self halt. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
886 |
"/self realized ifFalse:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
887 |
"/ "/ iconfified |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
888 |
"/ ^ self |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
889 |
"/]. |
4518 | 890 |
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
|
891 |
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
|
892 |
numberOfLines := nFullLinesShown. |
1359 | 893 |
((prevNumCols == numberOfColumns) |
894 |
and:[prevNumLines == numberOfLines]) ifTrue:[ |
|
895 |
^ self |
|
896 |
]. |
|
897 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
898 |
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
|
899 |
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
|
900 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
901 |
|
1359 | 902 |
"/ any idea, how to do this under windows ? |
903 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
904 |
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
|
905 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
906 |
"/ 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
|
907 |
"/ 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
|
908 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
909 |
(inStream notNil |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
910 |
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
|
911 |
and:[inStream isOpen]]) ifTrue:[ |
4285 | 912 |
Debug ifTrue:[ |
4287 | 913 |
Transcript showCR:'VT100: windowSize changed nLines to ', numberOfLines printString. |
4285 | 914 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
915 |
(OperatingSystem |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
916 |
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
|
917 |
width:numberOfColumns |
4285 | 918 |
height:numberOfLines |
919 |
) ifFalse:[ |
|
2192 | 920 |
Debug ifTrue:[ |
921 |
Transcript showCR:'VT100: cannot change windowSize'. |
|
922 |
]. |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
923 |
]. |
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
924 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
925 |
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
|
926 |
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
|
927 |
] |
943 | 928 |
]. |
929 |
||
4655 | 930 |
prevNumCols := numberOfColumns. |
931 |
prevNumLines := numberOfLines. |
|
932 |
||
933 |
"Created: / 11-06-1998 / 22:51:39 / cg" |
|
934 |
"Modified: / 17-07-2014 / 19:40:45 / cg" |
|
943 | 935 |
! |
936 |
||
914 | 937 |
keyPress:aKey x:x y:y |
4164 | 938 |
<resource: #keyboard (#Control #Control_L #Control_R |
939 |
#Shift #Shift_L #Shift_R |
|
940 |
#Alt #Alt_L #Alt_R |
|
941 |
#Cmd #Cmd_L #Cmd_R |
|
942 |
#Meta #Meta_L #Meta_R |
|
943 |
#Return)> |
|
944 |
||
4803 | 945 |
|rest event rawKey seq shortCut| |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
946 |
|
5278 | 947 |
( #(ZoomIn ZoomOut ZoomInAll ZoomOutAll) includes:aKey) ifTrue:[ |
948 |
super keyPress:aKey x:x y:y. |
|
949 |
]. |
|
950 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
951 |
"/ somewhat complicated, since some characters |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
952 |
"/ should go untranslated (CTRL-key), |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
953 |
"/ even if defined as function keys. |
914 | 954 |
|
955 |
inStream isNil ifTrue:[^ self]. |
|
956 |
||
4294 | 957 |
DebugKeyboard ifTrue:[ |
2192 | 958 |
Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString. |
959 |
]. |
|
4601 | 960 |
self shouldProcessInputInLineEditMode ifTrue:[ |
961 |
(self keyPressInLineEditMode:aKey) ifTrue:[^ self]. |
|
4593 | 962 |
]. |
914 | 963 |
|
964 |
aKey isCharacter ifTrue:[ |
|
2466 | 965 |
self deselect. |
966 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
967 |
localEcho ifTrue:[ |
3758 | 968 |
self nextPut:aKey. |
969 |
self flush. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
970 |
]. |
4290 | 971 |
"/ send it down to inStream ... |
4317 | 972 |
self sendCharacter:aKey. |
914 | 973 |
^ self |
974 |
]. |
|
975 |
||
1366 | 976 |
(#(Control Control_L Control_R |
977 |
Shift Shift_L Shift_R |
|
978 |
Alt Alt_L Alt_R |
|
979 |
Cmd Cmd_L Cmd_R |
|
980 |
Meta Meta_L Meta_R) includes:aKey) ifTrue:[ |
|
981 |
^ self |
|
982 |
]. |
|
983 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
984 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
985 |
"/ 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
|
986 |
"/ |
2078 | 987 |
(aKey == #Return |
988 |
and:[inputTranslateCRToNL]) ifTrue:[ |
|
989 |
seq := '\n'. |
|
990 |
] ifFalse:[ |
|
4324 | 991 |
(aKey == #BackSpace |
992 |
and:[inputTranslateBackspaceToDelete]) ifTrue:[ |
|
993 |
seq := kbdSequences at:#Delete ifAbsent:[ kbdSequences at:aKey ifAbsent:nil ]. |
|
994 |
] ifFalse:[ |
|
995 |
seq := kbdSequences at:aKey ifAbsent:nil. |
|
996 |
]. |
|
2078 | 997 |
]. |
3758 | 998 |
|
914 | 999 |
seq notNil ifTrue:[ |
4294 | 1000 |
DebugKeyboard ifTrue:[ |
2192 | 1001 |
Transcript show:'->' ; showCR:seq storeString. |
1002 |
]. |
|
4105 | 1003 |
seq := seq withoutCEscapes. |
2078 | 1004 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1005 |
localEcho ifTrue:[ |
3758 | 1006 |
seq do:[:k | self nextPut:k]. |
1007 |
self flush. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1008 |
]. |
4317 | 1009 |
self send:seq. |
914 | 1010 |
^ self |
1011 |
]. |
|
1012 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1013 |
self sensor ctrlDown ifTrue:[ |
1366 | 1014 |
(aKey startsWith:'Ctrl') ifTrue:[ |
1015 |
rawKey := aKey |
|
1016 |
] ifFalse:[ |
|
1017 |
"/ already translated - undo it. |
|
1018 |
||
5874 | 1019 |
event := WindowGroup lastEvent. |
1366 | 1020 |
rawKey := event rawKey. |
1021 |
rawKey isCharacter ifTrue:[ |
|
1022 |
rawKey := 'Ctrl' , rawKey. |
|
1023 |
] |
|
1360 | 1024 |
] |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1025 |
] ifFalse:[ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1026 |
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
|
1027 |
]. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1028 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1029 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1030 |
"/ 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
|
1031 |
"/ |
4294 | 1032 |
DebugKeyboard ifTrue:[ |
2192 | 1033 |
Transcript show:'raw ->' ; showCR:rawKey storeString. |
1034 |
]. |
|
4803 | 1035 |
|
1036 |
"/ there is some conflict here, for keys such as CTRL-c: |
|
1037 |
"/ it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key). |
|
1038 |
"/ For this, we look if there is a current selection, and if so, always treat it as a |
|
1039 |
"/ shortcut (and NOT sending it to the terminal's program). |
|
1040 |
"/ Otherwise, if there is no selection, look at the "sendControlKeys" boolean. |
|
1041 |
"/ If it is set (which is the default), then send it to the terminal, otherwise perform the editor op. |
|
1042 |
"/ Thus, an application containing me can offer a menu function (or toggle), to control this behavior |
|
1043 |
"/ on the UI level. |
|
1044 |
||
5006 | 1045 |
shortCut := device keyboardMap at:aKey ifAbsent:nil. |
4803 | 1046 |
(shortCut notNil and:[shortCut isSymbol]) ifTrue:[ |
4811 | 1047 |
(sendControlKeys not or:[ self hasSelection or:[ shortCut == #Paste] ]) ifTrue:[ |
5008 | 1048 |
DebugKeyboard ifTrue:[ |
1049 |
Transcript showCR:'internal handling'. |
|
1050 |
]. |
|
4811 | 1051 |
^ super keyPress:shortCut x:x y:y |
5008 | 1052 |
]. |
4803 | 1053 |
]. |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1054 |
|
914 | 1055 |
seq := kbdSequences at:rawKey ifAbsent:nil. |
1056 |
seq notNil ifTrue:[ |
|
4294 | 1057 |
DebugKeyboard ifTrue:[ |
5008 | 1058 |
Transcript show:'seq ->' ; showCR:seq storeString. |
3758 | 1059 |
]. |
4317 | 1060 |
self send:(seq withoutCEscapes). |
914 | 1061 |
^ self |
1062 |
]. |
|
6044 | 1063 |
rawKey notNil ifTrue:[ |
1064 |
(rawKey startsWith:'Ctrl') ifTrue:[ |
|
1065 |
rest := rawKey copyFrom:5. |
|
1066 |
rest size == 1 ifTrue:[ |
|
1067 |
rest := rest at:1. |
|
1068 |
(rest asLowercase between:$a and:$z) ifTrue:[ |
|
1069 |
DebugKeyboard ifTrue:[ |
|
1070 |
Transcript show:'ctrl ->' ; showCR:(Character controlCharacter:rest) storeString. |
|
1071 |
]. |
|
1072 |
(signalControlKeys and:[rawKey == #Ctrlc]) ifTrue:[ |
|
1073 |
self doSendInterrupt. |
|
1074 |
^ self. |
|
1075 |
]. |
|
1076 |
self sendCharacter:(Character controlCharacter:rest). |
|
1077 |
^ self |
|
5008 | 1078 |
]. |
6044 | 1079 |
] |
1080 |
]. |
|
1081 |
||
1082 |
((rawKey startsWith:'Control') |
|
1083 |
or:[ (rawKey startsWith:'Shift') |
|
1084 |
or:[ (rawKey startsWith:'Alt') |
|
1085 |
or:[ (rawKey = 'Ctrl') |
|
1086 |
]]]) ifTrue:[ |
|
1087 |
DebugKeyboard ifTrue:[ |
|
1088 |
Transcript showCR:'modifier ignored'. |
|
914 | 1089 |
]. |
6044 | 1090 |
^ self |
1091 |
]. |
|
1092 |
(rawKey startsWith:'Cmd') ifTrue:[ |
|
1093 |
DebugKeyboard ifTrue:[ |
|
1094 |
Transcript showCR:'CMD handled internal'. |
|
1095 |
]. |
|
1096 |
^ super keyPress:aKey x:x y:y |
|
1097 |
]. |
|
914 | 1098 |
]. |
6044 | 1099 |
|
4294 | 1100 |
DebugKeyboard ifTrue:[ |
6044 | 1101 |
Transcript showCR:'unhandled: %1' with:(rawKey ? aKey). |
2192 | 1102 |
]. |
914 | 1103 |
|
4294 | 1104 |
" |
1105 |
DebugKeyboard := true |
|
1106 |
" |
|
1107 |
||
4105 | 1108 |
"Modified: / 25-01-2012 / 10:43:06 / cg" |
6044 | 1109 |
"Modified: / 26-04-2019 / 09:55:40 / Claus Gittinger" |
914 | 1110 |
! |
1111 |
||
4593 | 1112 |
keyPressInLineEditMode:aKey |
1113 |
"readline alike line editing. |
|
4815 | 1114 |
cursorUp/down select a previous line from the history (unix shell bahevior). |
1115 |
shift cursorUp selects a previous selected history line from the history (windows shell bahevior). |
|
4816 | 1116 |
cursor left/right/^A/^E/backspace position/edit inside that line. |
4815 | 1117 |
Return true, if the character was processed, |
4593 | 1118 |
false if not. Then, the caller should proceed as usual." |
1119 |
||
1120 |
|clearLine| |
|
1121 |
||
1122 |
clearLine := |
|
1123 |
[ |
|
1124 |
lineBufferCursorPosition-1 timesRepeat:[ self deleteCharBeforeCursor ]. |
|
1125 |
(lineBuffer size-(lineBufferCursorPosition-1)) timesRepeat:[ self deleteCharAtCursor]. |
|
1126 |
]. |
|
1127 |
||
1128 |
"/ in lineEditMode, defer sending to the pty, until a newline is entered |
|
1129 |
lineBuffer isNil ifTrue:[ |
|
1130 |
lineBuffer := String new. |
|
1131 |
lineBufferCursorPosition := 1. |
|
1132 |
]. |
|
1133 |
||
1134 |
aKey isCharacter ifTrue:[ |
|
1135 |
lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-1) |
|
1136 |
, aKey |
|
1137 |
, (lineBuffer copyFrom:lineBufferCursorPosition). |
|
1138 |
self insertCharAtCursor:aKey. |
|
1139 |
lineBufferCursorPosition := lineBufferCursorPosition + 1. |
|
1140 |
^ true. |
|
1141 |
]. |
|
4601 | 1142 |
|
4593 | 1143 |
aKey == #Return ifTrue:[ |
1144 |
"/ as the pty is in echo mode, |
|
1145 |
"/ we should either disable echo for the following, |
|
1146 |
"/ or remove from the textview and let the program redraw them. |
|
1147 |
"/ the second alternative looks easier for now... |
|
1148 |
clearLine value. |
|
4604 | 1149 |
self sendCR:lineBuffer. |
1150 |
||
4815 | 1151 |
lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition. |
1152 |
||
4593 | 1153 |
lineBufferHistory isNil ifTrue:[ |
1154 |
lineBufferHistory := OrderedCollection new. |
|
1155 |
]. |
|
5904 | 1156 |
(lineBufferHistory notEmpty and:[lineBufferHistory last isEmpty]) ifTrue:[ |
5288 | 1157 |
lineBufferHistory removeLast. |
1158 |
lineBufferHistoryChanged := true. |
|
4594 | 1159 |
]. |
5234 | 1160 |
"/ do not remember blank lines |
5904 | 1161 |
(lineBuffer notNil and:[lineBuffer isBlank not]) ifTrue:[ |
5234 | 1162 |
"/ do not remember repetitions |
5904 | 1163 |
(lineBufferHistory notEmpty and:[lineBufferHistory last = lineBuffer]) ifFalse:[ |
5234 | 1164 |
lineBufferHistory addLast:lineBuffer. |
5288 | 1165 |
lineBufferHistoryChanged := true. |
5234 | 1166 |
]. |
1167 |
lineBufferHistoryPosition := lineBufferHistory size + 1. |
|
1168 |
lineBuffer := nil. |
|
1169 |
||
1170 |
maxHistorySize notNil ifTrue:[ |
|
1171 |
[ lineBufferHistory size > maxHistorySize] whileTrue:[ |
|
1172 |
lineBufferHistory removeFirst. |
|
5288 | 1173 |
lineBufferHistoryChanged := true. |
5234 | 1174 |
]. |
4602 | 1175 |
]. |
1176 |
]. |
|
4593 | 1177 |
^ true. |
1178 |
]. |
|
1179 |
||
1180 |
aKey == #BackSpace ifTrue:[ |
|
1181 |
lineBufferCursorPosition > 1 ifFalse:[ |
|
1182 |
self beep. |
|
1183 |
^ true |
|
1184 |
]. |
|
1185 |
lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-2) |
|
1186 |
, (lineBuffer copyFrom:lineBufferCursorPosition). |
|
1187 |
self deleteCharBeforeCursor. |
|
1188 |
lineBufferCursorPosition := lineBufferCursorPosition - 1. |
|
1189 |
^ true. |
|
1190 |
]. |
|
1191 |
||
4817 | 1192 |
((aKey == #BeginOfText) or:[aKey == #Ctrla]) ifTrue:[ |
4816 | 1193 |
lineBufferCursorPosition > 1 ifFalse:[ |
1194 |
self beep. |
|
1195 |
^ true |
|
1196 |
]. |
|
1197 |
lineBufferCursorPosition := 1. |
|
1198 |
self cursorToBeginOfLine. |
|
1199 |
^ true. |
|
1200 |
]. |
|
4817 | 1201 |
((aKey == #EndOfText) or:[aKey == #Ctrle]) ifTrue:[ |
4816 | 1202 |
lineBufferCursorPosition := lineBuffer size. |
1203 |
self cursorToEndOfLine. |
|
1204 |
^ true. |
|
1205 |
]. |
|
5538 | 1206 |
|
1207 |
aKey == #Ctrlr ifTrue:[ |
|
1208 |
lineBufferHistory size >= lineBufferHistoryPosition ifTrue:[ |
|
1209 |
lineBufferHistory at:lineBufferHistoryPosition put:lineBuffer. |
|
1210 |
] ifFalse:[ |
|
1211 |
lineBufferHistory add:lineBuffer. |
|
1212 |
]. |
|
1213 |
||
1214 |
clearLine value. |
|
1215 |
||
1216 |
lineBuffer := lineBufferHistory at:lineBufferHistoryPosition ifAbsent:[lineBufferHistory last]. |
|
1217 |
self insertStringAtCursor:lineBuffer. |
|
1218 |
lineBufferCursorPosition := lineBuffer size + 1. |
|
1219 |
self makeCursorVisible. |
|
1220 |
^ true. |
|
1221 |
]. |
|
1222 |
||
4593 | 1223 |
aKey == #CursorLeft ifTrue:[ |
1224 |
lineBufferCursorPosition > 1 ifFalse:[ |
|
1225 |
self beep. |
|
1226 |
^ true |
|
1227 |
]. |
|
1228 |
lineBufferCursorPosition := lineBufferCursorPosition - 1. |
|
1229 |
self cursorLeft. |
|
1230 |
^ true. |
|
1231 |
]. |
|
1232 |
aKey == #CursorRight ifTrue:[ |
|
4641 | 1233 |
lineBufferCursorPosition <= lineBuffer size ifFalse:[ |
4593 | 1234 |
self beep. |
1235 |
^ true |
|
1236 |
]. |
|
1237 |
lineBufferCursorPosition := lineBufferCursorPosition + 1. |
|
1238 |
self cursorRight. |
|
1239 |
^ true. |
|
1240 |
]. |
|
1241 |
aKey == #CursorUp ifTrue:[ |
|
5703 | 1242 |
|p| |
1243 |
||
4603 | 1244 |
(lineBufferHistoryPosition notNil and:[lineBufferHistoryPosition > 1]) ifFalse:[ |
4593 | 1245 |
self beep. |
1246 |
^ true |
|
1247 |
]. |
|
5234 | 1248 |
|
4595 | 1249 |
"/ remember the current lineBuffer (but only if it is the last) |
4593 | 1250 |
lineBufferHistoryPosition > lineBufferHistory size ifTrue:[ |
5703 | 1251 |
"/ do not remember repetitions |
5904 | 1252 |
(lineBufferHistory notEmpty and:[lineBufferHistory last = lineBuffer]) ifFalse:[ |
5703 | 1253 |
lineBufferHistory add:lineBuffer. |
1254 |
lineBufferHistoryChanged := true. |
|
1255 |
]. |
|
4593 | 1256 |
]. |
1257 |
clearLine value. |
|
1258 |
||
4815 | 1259 |
(self sensor shiftDown and:[lastSelectedLineBufferHistoryPosition notNil]) ifTrue:[ |
1260 |
lineBufferHistoryPosition := lastSelectedLineBufferHistoryPosition. |
|
1261 |
] ifFalse:[ |
|
1262 |
lineBufferHistoryPosition := lineBufferHistoryPosition - 1. |
|
1263 |
]. |
|
1264 |
"/ lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition. |
|
5703 | 1265 |
p := lineBufferHistoryPosition. |
1266 |
[ |
|
5704 | 1267 |
lineBuffer := lineBufferHistory at:p ifAbsent:[nil]. |
5703 | 1268 |
p := p - 1. |
1269 |
] doUntil:[ |
|
1270 |
p == 0 or:[ lineBuffer notEmptyOrNil ] |
|
1271 |
]. |
|
4593 | 1272 |
self insertStringAtCursor:lineBuffer. |
1273 |
lineBufferCursorPosition := lineBuffer size + 1. |
|
4819 | 1274 |
self makeCursorVisible. |
4593 | 1275 |
^ true. |
1276 |
]. |
|
1277 |
aKey == #CursorDown ifTrue:[ |
|
4603 | 1278 |
(lineBufferHistoryPosition notNil and:[lineBufferHistoryPosition < lineBufferHistory size]) ifFalse:[ |
4593 | 1279 |
self beep. |
1280 |
^ true |
|
1281 |
]. |
|
1282 |
||
1283 |
clearLine value. |
|
1284 |
||
1285 |
lineBufferHistoryPosition := lineBufferHistoryPosition + 1. |
|
4815 | 1286 |
"/ lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition. |
4593 | 1287 |
lineBuffer := lineBufferHistory at:lineBufferHistoryPosition. |
4594 | 1288 |
lineBufferHistoryPosition >= lineBufferHistory size ifTrue:[ |
1289 |
lineBufferHistory removeLast. |
|
5288 | 1290 |
lineBufferHistoryChanged := true. |
4594 | 1291 |
]. |
4593 | 1292 |
self insertStringAtCursor:lineBuffer. |
1293 |
lineBufferCursorPosition := lineBuffer size + 1. |
|
4819 | 1294 |
self makeCursorVisible. |
4593 | 1295 |
^ true. |
1296 |
]. |
|
1297 |
^ false. |
|
5538 | 1298 |
|
1299 |
"Modified: / 03-05-2017 / 16:28:56 / cg" |
|
5904 | 1300 |
"Modified: / 14-09-2018 / 17:01:39 / Stefan Vogel" |
4593 | 1301 |
! |
1302 |
||
914 | 1303 |
shellTerminated |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1304 |
"shell has terminated" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1305 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1306 |
"/Delay waitForSeconds:10. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1307 |
[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
|
1308 |
"/ |
4265 | 1309 |
self closeDownShellAndStopReaderProcess. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1310 |
|
946 | 1311 |
shellTerminateAction notNil ifTrue:[ |
1312 |
shellTerminateAction value |
|
1313 |
] |
|
1314 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1315 |
"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
|
1316 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1317 |
|
4601 | 1318 |
shouldProcessInputInLineEditMode |
1319 |
"should input be processed in the readline edit mode?" |
|
1320 |
||
1321 |
|termiosInfo| |
|
1322 |
||
1323 |
lineEditMode == true ifFalse:[^ false]. |
|
1324 |
||
1325 |
"/ check if tty is in raw mode - then don't do lineEditMode |
|
1326 |
(OperatingSystem isUNIXlike |
|
1327 |
and:[ inStream isExternalStream ]) ifTrue:[ |
|
1328 |
termiosInfo := inStream tcgetattr. |
|
1329 |
((termiosInfo at:#lflags) at:#icanon) ifFalse:[^ false]. |
|
1330 |
]. |
|
1331 |
||
1332 |
"/ don't know how to do that on non-unix systems |
|
1333 |
^ true |
|
1334 |
! |
|
1335 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1336 |
sizeChanged:how |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1337 |
super sizeChanged:how. |
943 | 1338 |
self defineWindowSize. |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1339 |
|
943 | 1340 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
914 | 1341 |
! ! |
1342 |
||
1343 |
!TerminalView methodsFor:'functions'! |
|
1344 |
||
5244 | 1345 |
autoMargin:aBoolean |
1346 |
"set/clear autowrap at end of line (not yet fully implemented). |
|
1347 |
This may come from a CSI sequence, or set programmatically." |
|
1348 |
||
1349 |
autoWrapFlag := aBoolean |
|
1350 |
! |
|
1351 |
||
914 | 1352 |
doBackspace |
1353 |
self cursorLeft. |
|
1354 |
self replaceCharAtCursor:(Character space). |
|
1355 |
self cursorLeft. |
|
1356 |
||
931 | 1357 |
"Modified: / 10.6.1998 / 17:09:12 / cg" |
914 | 1358 |
! |
1359 |
||
926 | 1360 |
doClearDisplay |
1420 | 1361 |
"clear everything" |
1362 |
||
1000 | 1363 |
self doClearEntireScreen. |
1364 |
||
1365 |
"Modified: / 21.7.1998 / 20:05:35 / cg" |
|
1366 |
! |
|
1367 |
||
1420 | 1368 |
doClearEntireLine |
1369 |
"clear the cursor line. cursor position remains unchanged" |
|
1370 |
||
1371 |
self at:cursorLine put:'' |
|
1372 |
! |
|
1373 |
||
1000 | 1374 |
doClearEntireScreen |
1420 | 1375 |
"clear everything" |
1376 |
||
4668 | 1377 |
firstLineShown to:(list size) do:[:lNr | |
1378 |
self at:lNr put:'' |
|
926 | 1379 |
]. |
922 | 1380 |
|
1000 | 1381 |
"Modified: / 21.7.1998 / 20:00:19 / cg" |
1382 |
"Created: / 21.7.1998 / 20:05:24 / cg" |
|
926 | 1383 |
! |
1384 |
||
1000 | 1385 |
doClearFromBeginningOfLine |
1420 | 1386 |
"clear from beginning of line to the cursorPosition" |
1387 |
||
1000 | 1388 |
|l| |
1389 |
||
1390 |
l := self listAt:cursorLine. |
|
1391 |
l notNil ifTrue:[ |
|
1392 |
(l size >= (cursorCol-1)) ifTrue:[ |
|
1393 |
l := l copy from:1 to:cursorCol-1 put:(Character space). |
|
1394 |
] ifFalse:[ |
|
1395 |
l := nil. |
|
1396 |
]. |
|
1397 |
self withoutRedrawAt:cursorLine put:l. |
|
1398 |
self invalidateLine:cursorLine |
|
1399 |
"/ self at:cursorLine put:l. |
|
1400 |
] |
|
1401 |
||
1402 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
|
1403 |
"Created: / 21.7.1998 / 20:10:58 / cg" |
|
1404 |
! |
|
1405 |
||
1406 |
doClearFromBeginningOfScreen |
|
1420 | 1407 |
"clear from beginning of the screen to the cursorPosition" |
1408 |
||
1000 | 1409 |
self doClearFromBeginningOfLine. |
4668 | 1410 |
cursorLine-1 to:firstLineShown do:[:lNr | |
1411 |
self at:lNr put:'' |
|
922 | 1412 |
]. |
1413 |
||
926 | 1414 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
1000 | 1415 |
"Created: / 21.7.1998 / 20:08:29 / cg" |
926 | 1416 |
! |
1417 |
||
1418 |
doClearToEndOfLine |
|
1420 | 1419 |
"clear from the cursorPosition to the end of the line" |
1420 |
||
926 | 1421 |
|l| |
1422 |
||
1423 |
l := self listAt:cursorLine. |
|
931 | 1424 |
(l size >= (cursorCol-1)) ifTrue:[ |
951 | 1425 |
l notNil ifTrue:[ |
1426 |
l := l copyTo:cursorCol-1. |
|
979 | 1427 |
self withoutRedrawAt:cursorLine put:l. |
1428 |
self invalidateLine:cursorLine |
|
1429 |
"/ self at:cursorLine put:l. |
|
951 | 1430 |
] |
926 | 1431 |
] |
1432 |
||
1433 |
"Created: / 10.6.1998 / 14:45:01 / cg" |
|
979 | 1434 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
914 | 1435 |
! |
1436 |
||
1000 | 1437 |
doClearToEndOfScreen |
1420 | 1438 |
"clear from the cursorPosition to the end of the screen" |
1439 |
||
1000 | 1440 |
self doClearToEndOfLine. |
4668 | 1441 |
cursorLine+1 to:(list size) do:[:lNr | |
1442 |
self at:lNr put:'' |
|
1000 | 1443 |
]. |
1444 |
||
1445 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
|
1446 |
"Created: / 21.7.1998 / 20:06:14 / cg" |
|
1447 |
! |
|
1448 |
||
926 | 1449 |
doCursorDown:n |
1420 | 1450 |
"move the cursor down by n lines" |
1451 |
||
979 | 1452 |
|wasOn rEnd| |
926 | 1453 |
|
979 | 1454 |
"/ rangeEndLine == numberOfLines ifTrue:[ |
1455 |
"/ ^ super cursorDown:n |
|
1456 |
"/ ]. |
|
1457 |
cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[ |
|
951 | 1458 |
"/ no special action req'd |
1459 |
^ super cursorDown:n |
|
1460 |
]. |
|
979 | 1461 |
|
951 | 1462 |
n timesRepeat:[ |
1463 |
wasOn := self hideCursor. |
|
979 | 1464 |
rEnd := rangeEndLine+firstLineShown-1. |
1465 |
cursorLine == rEnd ifTrue:[ |
|
1466 |
self deleteLine:(rangeStartLine+firstLineShown-1). |
|
1467 |
self insertLine:'' before:rEnd. |
|
951 | 1468 |
] ifFalse:[ |
1469 |
super cursorDown |
|
1470 |
]. |
|
979 | 1471 |
wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn. |
951 | 1472 |
] |
1473 |
||
979 | 1474 |
"Modified: / 20.6.1998 / 20:29:39 / cg" |
926 | 1475 |
! |
1476 |
||
914 | 1477 |
doCursorHome |
1420 | 1478 |
"move the cursor to the home position" |
1479 |
||
938 | 1480 |
self cursorVisibleLine:1 col:1 |
1481 |
"/ super cursorHome |
|
1482 |
||
1483 |
"Modified: / 10.6.1998 / 20:47:31 / cg" |
|
914 | 1484 |
! |
1485 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1486 |
doCursorLeft:n |
1420 | 1487 |
"move the cursor to the left by n columns" |
1488 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1489 |
n timesRepeat:[ |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1490 |
super cursorLeft |
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 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1493 |
"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
|
1494 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1495 |
|
914 | 1496 |
doCursorNewLine |
1420 | 1497 |
"move the cursor down to the next line (col remains unchanged)" |
1498 |
||
931 | 1499 |
super cursorDown:1 |
1500 |
||
1501 |
"Modified: / 10.6.1998 / 16:55:57 / cg" |
|
914 | 1502 |
! |
1503 |
||
1504 |
doCursorReturn |
|
1420 | 1505 |
"move the cursor down and left to the beginning to the next line" |
1506 |
||
914 | 1507 |
super cursorToBeginOfLine |
1508 |
! |
|
1509 |
||
926 | 1510 |
doCursorRight:n |
1420 | 1511 |
"move the cursor to the right by n columns" |
1512 |
||
926 | 1513 |
self cursorCol:(cursorCol + n) |
1514 |
||
1515 |
"Created: / 10.6.1998 / 15:10:08 / cg" |
|
1516 |
! |
|
1517 |
||
951 | 1518 |
doCursorUp:n |
1420 | 1519 |
"move the cursor up by n lines" |
1520 |
||
979 | 1521 |
|wasOn rStart| |
926 | 1522 |
|
979 | 1523 |
"/ rangeStartLine == 1 ifTrue:[ |
1524 |
"/ ^ super cursorUp:n |
|
1525 |
"/ ]. |
|
1526 |
cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[ |
|
951 | 1527 |
"/ no special action req'd |
1528 |
^ super cursorUp:n |
|
1529 |
]. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1530 |
n timesRepeat:[ |
951 | 1531 |
wasOn := self hideCursor. |
979 | 1532 |
rStart := rangeStartLine+firstLineShown-1. |
1533 |
cursorLine == rStart ifTrue:[ |
|
1534 |
(rangeEndLine+firstLineShown-1) <= list size ifTrue:[ |
|
1535 |
self deleteLine:(rangeEndLine+firstLineShown-1). |
|
1536 |
self insertLine:'' before:rStart. |
|
1537 |
]. |
|
951 | 1538 |
] ifFalse:[ |
1539 |
super cursorUp |
|
1540 |
]. |
|
1541 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1542 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1543 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
1544 |
"Created: / 11.6.1998 / 22:29:46 / cg" |
979 | 1545 |
"Modified: / 20.6.1998 / 20:30:34 / cg" |
914 | 1546 |
! ! |
1547 |
||
2501 | 1548 |
!TerminalView methodsFor:'initialization & release'! |
914 | 1549 |
|
1550 |
closeDownShell |
|
4265 | 1551 |
"shut down my shell process." |
1420 | 1552 |
|
1009 | 1553 |
|pid| |
926 | 1554 |
|
1555 |
(pid := shellPid) notNil ifTrue:[ |
|
2192 | 1556 |
Debug ifTrue:[ |
4265 | 1557 |
Transcript show:'killing shell pid='; showCR:pid. |
2192 | 1558 |
]. |
4958 | 1559 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
1560 |
OperatingSystem terminateProcessGroup:pid. |
|
1561 |
]. |
|
926 | 1562 |
OperatingSystem terminateProcess:pid. |
4959 | 1563 |
Delay waitForSeconds:0.2. |
925 | 1564 |
shellPid notNil ifTrue:[ |
4959 | 1565 |
"/ Delay waitForSeconds:1. |
4958 | 1566 |
shellPid notNil ifTrue:[ |
1567 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
|
1568 |
OperatingSystem killProcessGroup:pid. |
|
1569 |
]. |
|
1570 |
OperatingSystem killProcess:pid. |
|
1571 |
shellPid := nil. |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
1572 |
]. |
925 | 1573 |
]. |
926 | 1574 |
OperatingSystem closePid:pid. |
914 | 1575 |
]. |
4265 | 1576 |
! |
914 | 1577 |
|
4265 | 1578 |
closeDownShellAndStopReaderProcess |
1579 |
"shut down my shell process and stop the background reader thread." |
|
1580 |
||
1581 |
self closeDownShell. |
|
1009 | 1582 |
self stopReaderProcess. |
4265 | 1583 |
self closeStreams |
1009 | 1584 |
|
4265 | 1585 |
"Modified: / 5.5.1999 / 18:43:02 / cg" |
1586 |
! |
|
1587 |
||
1588 |
closeStreams |
|
4576 | 1589 |
|s| |
1590 |
||
1591 |
(s := inStream) notNil ifTrue:[ |
|
1592 |
inStream := nil. |
|
4654 | 1593 |
(s isStream and:[s isOpen]) ifTrue:[ |
1594 |
s close |
|
1595 |
]. |
|
914 | 1596 |
]. |
4576 | 1597 |
(s := outStream) notNil ifTrue:[ |
1598 |
outStream := nil. |
|
4654 | 1599 |
(s isStream and:[s isOpen]) ifTrue:[ |
1600 |
s close. |
|
1601 |
]. |
|
914 | 1602 |
]. |
924 | 1603 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1604 |
"Modified: / 5.5.1999 / 18:43:02 / cg" |
914 | 1605 |
! |
1606 |
||
1607 |
escapeSequences:codes |
|
1420 | 1608 |
"setup my escape sequences" |
1609 |
||
914 | 1610 |
|tree| |
1611 |
||
1612 |
tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new]. |
|
1613 |
||
1614 |
codes do:[:specEntry | |
|
1615 |
|sequence function| |
|
1616 |
||
4105 | 1617 |
sequence := (specEntry at:1) withoutCEscapes. |
914 | 1618 |
function := specEntry at:2. |
1619 |
||
1620 |
tree := escapeSequenceTree. |
|
1621 |
||
1622 |
sequence keysAndValuesDo:[:idx :char | |
|
1623 |
|followup| |
|
1624 |
||
1625 |
idx == sequence size ifTrue:[ |
|
1626 |
tree at:char put:function |
|
1627 |
] ifFalse:[ |
|
1628 |
followup := tree at:char ifAbsent:nil. |
|
1629 |
followup isNil ifTrue:[ |
|
1630 |
tree at:char put:(followup := IdentityDictionary new). |
|
1631 |
]. |
|
1632 |
tree := followup |
|
1633 |
] |
|
1634 |
] |
|
1635 |
]. |
|
918 | 1636 |
escapeLeadingChars := escapeSequenceTree keys asSet. |
1637 |
escapeLeadingChars add:(Character cr). |
|
1638 |
escapeLeadingChars add:(Character return). |
|
1639 |
escapeLeadingChars add:(Character backspace). |
|
1640 |
||
1641 |
escapeLeadingChars := escapeLeadingChars asArray |
|
1642 |
||
4105 | 1643 |
"Modified: / 25-01-2012 / 10:42:46 / cg" |
914 | 1644 |
! |
1645 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1646 |
flushInput |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1647 |
|sensor| |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1648 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1649 |
"/ flush any leftover input-processing events |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1650 |
(sensor := self sensor) notNil ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1651 |
sensor flushEventsFor:self withType:#processInput:n:. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1652 |
] |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1653 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1654 |
"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
|
1655 |
"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
|
1656 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1657 |
|
2163 | 1658 |
initStyle |
1659 |
super initStyle. |
|
1660 |
"/ self foregroundColor:Color green. |
|
1661 |
"/ self backgroundColor:Color black. |
|
1662 |
! |
|
1663 |
||
914 | 1664 |
initialize |
2194 | 1665 |
|
914 | 1666 |
super initialize. |
1667 |
||
4803 | 1668 |
sendControlKeys := true. |
5008 | 1669 |
signalControlKeys := OperatingSystem isMSWINDOWSlike. |
914 | 1670 |
showMatchingParenthesis := false. |
4288 | 1671 |
self insertMode: false. |
936 | 1672 |
alwaysAppendAtEnd := false. |
4315 | 1673 |
collectSize := 4096. |
1674 |
sizeOfOutstandingInputToBeProcessed := 0. |
|
977 | 1675 |
st80Mode := false. |
1676 |
trimBlankLines := true. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1677 |
localEcho := false. |
2078 | 1678 |
inputTranslateCRToNL := false. |
4604 | 1679 |
inputTranslateCRToCRNL := OperatingSystem isMSWINDOWSlike. |
4324 | 1680 |
inputTranslateBackspaceToDelete := false. |
5008 | 1681 |
inputIsUTF8 := UserPreferences current terminalInputIsUTF8. |
1682 |
outputIsUTF8 := false. "/ currently unused. |
|
2268 | 1683 |
autoWrapFlag := true. |
4299 | 1684 |
noColors := false. |
4612 | 1685 |
doUTF := UserPreferences current terminalOutputIsUTF8. |
4604 | 1686 |
lineEditMode := OperatingSystem isMSWINDOWSlike. |
4602 | 1687 |
maxHistorySize := maxHistorySize ? DefaultMaxHistorySize. |
4641 | 1688 |
ignoreOutput := false. |
5249 | 1689 |
filterOnly := false. |
4602 | 1690 |
|
2268 | 1691 |
"/ cursorType := #block. |
4452 | 1692 |
"/ cursorTypeNoFocus := #frame. |
1693 |
||
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
1694 |
state := 0. |
914 | 1695 |
|
926 | 1696 |
numberOfColumns := 80. |
979 | 1697 |
numberOfLines := 24. |
954 | 1698 |
rangeStartLine := 1. |
1699 |
rangeEndLine := numberOfLines. |
|
926 | 1700 |
|
2423
d2685982f94f
tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents:
2356
diff
changeset
|
1701 |
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
|
1702 |
|
914 | 1703 |
self initializeKeyboardSequences. |
6023 | 1704 |
list := OrderedCollection new:numberOfLines withAll:''. |
914 | 1705 |
|
2577 | 1706 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
1707 |
kbdSequences at:#Return put:'\r\n'. |
|
1708 |
]. |
|
914 | 1709 |
self initializeKeyboardMap. |
5144 | 1710 |
self initializeShellTerminateAction. |
1711 |
||
914 | 1712 |
" |
1713 |
VT52TerminalView openShell |
|
926 | 1714 |
VT100TerminalView openShell |
914 | 1715 |
" |
926 | 1716 |
|
4315 | 1717 |
"Modified: / 30-07-2013 / 10:43:07 / cg" |
6023 | 1718 |
"Modified: / 04-03-2019 / 08:05:34 / Claus Gittinger" |
914 | 1719 |
! |
1720 |
||
1721 |
initializeKeyboardMap |
|
5278 | 1722 |
"setup my own keyboardMap, where control-keys |
1723 |
(and some Cmd-keys) are not translated." |
|
1724 |
||
1349 | 1725 |
|keys ctrlKeys cmdKeys| |
914 | 1726 |
|
5006 | 1727 |
kbdMap := device keyboardMap copy. |
1349 | 1728 |
keys := kbdMap keys. |
914 | 1729 |
|
1349 | 1730 |
ctrlKeys := keys select:[:key | key startsWith:'Ctrl']. |
5278 | 1731 |
ctrlKeys do:[:key | |
1732 |
|val| |
|
1733 |
||
1734 |
val := kbdMap at:key. |
|
1735 |
( |
|
1736 |
#(ZoomIn ZoomOut |
|
1737 |
) includesIdentical:val) ifFalse:[ |
|
1738 |
kbdMap removeKey:key |
|
1739 |
] |
|
1740 |
]. |
|
950 | 1741 |
|
1349 | 1742 |
cmdKeys := keys select:[:key | key startsWith:'Cmd']. |
5278 | 1743 |
cmdKeys do:[:key | |
1744 |
|val| |
|
1745 |
||
1349 | 1746 |
val := kbdMap at:key. |
5278 | 1747 |
( |
1748 |
#(Copy Paste SaveAs Print Find FindNext FindPrev GotoLine |
|
1749 |
) includesIdentical:val) ifFalse:[ |
|
1750 |
kbdMap removeKey:key |
|
950 | 1751 |
] |
1752 |
]. |
|
914 | 1753 |
|
1754 |
kbdMap removeKey:#Delete ifAbsent:[]. |
|
1755 |
kbdMap removeKey:#BackSpace ifAbsent:[]. |
|
1756 |
||
1757 |
" |
|
1758 |
VT52TerminalView openShell |
|
1759 |
" |
|
950 | 1760 |
|
1349 | 1761 |
"Modified: / 29.4.1999 / 14:25:24 / cg" |
914 | 1762 |
! |
1763 |
||
1764 |
initializeKeyboardSequences |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1765 |
kbdSequences := (self anyKeyCodes) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1766 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1767 |
"Modified: / 5.5.1999 / 15:01:09 / cg" |
914 | 1768 |
! |
1769 |
||
5144 | 1770 |
initializeShellTerminateAction |
1771 |
shellTerminateAction := |
|
1772 |
[ |
|
1773 |
"/ may be removed with shellTerminateAction:... |
|
1774 |
self warn:(resources string:'shell terminated'). |
|
1775 |
] |
|
1776 |
! |
|
1777 |
||
914 | 1778 |
keyboardMap |
5278 | 1779 |
"return my own, private keyboard map. |
1780 |
This has control keys removed and |
|
934 | 1781 |
those will be passed unchanged to the shell" |
1782 |
||
914 | 1783 |
^ kbdMap |
934 | 1784 |
|
1785 |
"Modified: / 10.6.1998 / 17:46:59 / cg" |
|
914 | 1786 |
! |
1787 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1788 |
reinitialize |
1833 | 1789 |
"reinit after a snapIn. |
1790 |
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
|
1791 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1792 |
super reinitialize. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1793 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1794 |
shellPid := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1795 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1796 |
self stopReaderProcess. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1797 |
self flushInput. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1798 |
|
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1799 |
readerProcess := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1800 |
inStream := outStream := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1801 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1802 |
"/ 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
|
1803 |
[ |
1322 | 1804 |
"/ Delay waitForSeconds:0.5. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1805 |
self doClearEntireScreen. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1806 |
self cursorLine:1 col:1. |
1321
9a312fa98358
also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents:
1320
diff
changeset
|
1807 |
self contents:nil. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1808 |
self flash. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1809 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1810 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1811 |
"/ 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
|
1812 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1813 |
self startCommand:shellCommand in:shellDirectory. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1814 |
] forkAt:8 |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1815 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1816 |
"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
|
1817 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1818 |
|
2155 | 1819 |
release |
1820 |
"release myself - shut down the shell, stop the reader thread." |
|
1821 |
||
4265 | 1822 |
[ |
1823 |
self closeDownShellAndStopReaderProcess. |
|
1824 |
self flushInput. |
|
5151 | 1825 |
] forkAt:(Processor systemBackgroundPriority). |
4655 | 1826 |
super release. |
1827 |
||
1828 |
"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
|
1829 |
! ! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
1830 |
|
2501 | 1831 |
!TerminalView methodsFor:'initialization-shell'! |
1832 |
||
2778 | 1833 |
basicStartCommand:aCommand in:aDirectory |
2501 | 1834 |
"start a command on a pseudo terminal. If the command arg is nil, |
1835 |
a shell is started. If aDirectory is not nil, the command is |
|
1836 |
executed in that directory. |
|
1837 |
Also fork a reader process, to read the shells output and |
|
1838 |
tell me, whenever something arrives" |
|
1839 |
||
6012 | 1840 |
|pty master slave slaveFD slaveName execFdArray blocked exitStatus |
2501 | 1841 |
stxToCommandPipe commandToStxPipe cmd shell args env shellAndArgs| |
1842 |
||
1843 |
shellCommand := aCommand. |
|
1844 |
shellDirectory := aDirectory. |
|
1845 |
||
1846 |
self create. "/ need my windowID (to pass down in environment) |
|
1847 |
||
1848 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1849 |
"use two pipes to COMMAND.COM" |
|
2538
2ee2ed3bad39
Move makePTYPair to NonPositionableExternalStream
Stefan Vogel <sv@exept.de>
parents:
2506
diff
changeset
|
1850 |
stxToCommandPipe := NonPositionableExternalStream makePipe. |
2501 | 1851 |
stxToCommandPipe isNil ifTrue:[ |
4250 | 1852 |
self warn:(resources string:'Could not create pipe to COMMAND.COM.'). |
1853 |
^ self. |
|
2501 | 1854 |
]. |
1855 |
||
5929 | 1856 |
commandToStxPipe := PipeStream makePipe. |
2501 | 1857 |
commandToStxPipe isNil ifTrue:[ |
4250 | 1858 |
self warn:(resources string:'Could not create pipe from COMMAND.COM.'). |
1859 |
^ self. |
|
2501 | 1860 |
]. |
1861 |
||
1862 |
"/ pipe readSide is p at:1; |
|
1863 |
"/ writeSide is p at:2 |
|
1864 |
||
1865 |
slaveFD := (commandToStxPipe at:2) fileDescriptor. |
|
1866 |
execFdArray := Array |
|
1867 |
with:(stxToCommandPipe at:1) fileDescriptor "stdin" |
|
1868 |
with:slaveFD "stdout" |
|
1869 |
with:slaveFD. "stderr" |
|
1870 |
||
1871 |
outStream := commandToStxPipe at:1. |
|
1872 |
inStream := stxToCommandPipe at:2. |
|
5929 | 1873 |
inStream setCommandString:'pty -> stx'. |
1874 |
outStream setCommandString:'pty <- stx'. |
|
2501 | 1875 |
|
4655 | 1876 |
self defineWindowSize. "/ does not really work on windows (need help) |
1877 |
||
2501 | 1878 |
shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand. |
1879 |
shell := shellAndArgs at:1. |
|
1880 |
args := (shellAndArgs at:2) ? ''. |
|
1881 |
] ifFalse:[ |
|
1882 |
"Use a pseudo-tty" |
|
5929 | 1883 |
pty := PipeStream makePTYPair. |
2501 | 1884 |
pty isNil ifTrue:[ |
5062 | 1885 |
self warn:(resources string:'Cannot open pty.'). |
2501 | 1886 |
^ self. |
1887 |
]. |
|
1888 |
||
1889 |
"/ pty at:1 is the master; |
|
1890 |
"/ pty at:2 is the slave |
|
6012 | 1891 |
master := (pty at:1). |
1892 |
slave := (pty at:2). |
|
1893 |
slaveName := (pty at:3). |
|
1894 |
inStream := outStream := master. |
|
1895 |
inStream setCommandString:(slaveName ? 'pty'). |
|
2501 | 1896 |
|
1897 |
self defineWindowSize. |
|
4655 | 1898 |
|
2501 | 1899 |
"/ fork a shell process on the slave-side |
6012 | 1900 |
slaveFD := slave fileDescriptor. |
2501 | 1901 |
execFdArray := Array with:slaveFD with:slaveFD with:slaveFD. |
1902 |
||
1903 |
aCommand isNil ifTrue:[ |
|
1904 |
shell := OperatingSystem getEnvironment:'SHELL'. |
|
1905 |
shell size == 0 ifTrue:[ |
|
1906 |
shell := '/bin/sh'. |
|
1907 |
]. |
|
1908 |
cmd := shell asFilename baseName. |
|
1909 |
args := (Array with:cmd). |
|
1910 |
] ifFalse:[ |
|
1911 |
shell := '/bin/sh'. |
|
1912 |
args := (Array with:'sh' with:'-c' with:aCommand). |
|
1913 |
]. |
|
1914 |
env := Dictionary new. |
|
1915 |
env at:'SHELL' put:shell. |
|
1916 |
env at:'TERM' put:(self terminalType). |
|
4222 | 1917 |
env at:'HOME' put:(OperatingSystem getEnvironment:'HOME'). |
1918 |
env at:'USER' put:(OperatingSystem getEnvironment:'USER'). |
|
2501 | 1919 |
env at:'LINES' put:(numberOfLines printString). |
1920 |
env at:'COLUMNS' put:(numberOfColumns printString). |
|
5021 | 1921 |
(device platformName == #X11 and:[self drawableId notNil]) ifTrue:[ |
4518 | 1922 |
env at:'WINDOWID' put:(self drawableId address printString). |
2501 | 1923 |
]. |
1924 |
]. |
|
1925 |
||
1926 |
blocked := OperatingSystem blockInterrupts. |
|
1927 |
||
1928 |
shellPid := Processor |
|
1929 |
monitor:[ |
|
1930 |
OperatingSystem |
|
1931 |
exec:shell |
|
1932 |
withArguments:args |
|
1933 |
environment:env |
|
1934 |
fileDescriptors:execFdArray |
|
1935 |
fork:true |
|
1936 |
newPgrp:true |
|
5231 | 1937 |
inDirectory:aDirectory |
1938 |
showWindow:false. |
|
2501 | 1939 |
] |
1940 |
action:[:status | |
|
1941 |
Debug ifTrue:[ |
|
4325 | 1942 |
Transcript showCR:'shell status change'. |
1943 |
Transcript show:' pid:'; showCR:status pid. |
|
1944 |
Transcript show:' status:'; showCR:status status. |
|
1945 |
Transcript show:' code:'; showCR:status code. |
|
1946 |
Transcript show:' core:'; showCR:status core. |
|
2501 | 1947 |
]. |
1948 |
status stillAlive ifFalse:[ |
|
1949 |
exitStatus := status. |
|
1950 |
OperatingSystem closePid:shellPid. |
|
1951 |
shellPid := nil. |
|
1952 |
self pushEvent:#shellTerminated |
|
1953 |
]. |
|
1954 |
]. |
|
1955 |
||
1956 |
blocked ifFalse:[ |
|
1957 |
OperatingSystem unblockInterrupts |
|
1958 |
]. |
|
1959 |
||
1960 |
"close the slave side of the pty/pipes (only used by the child)" |
|
1961 |
pty notNil ifTrue:[ |
|
6012 | 1962 |
slave close. |
2501 | 1963 |
]. |
1964 |
||
1965 |
commandToStxPipe notNil ifTrue:[ |
|
1966 |
(commandToStxPipe at:2) close. |
|
1967 |
(stxToCommandPipe at:1) close. |
|
1968 |
]. |
|
1969 |
||
5930 | 1970 |
"/ release those references - the monitor block still has a reference to this (home) context, |
1971 |
"/ helps the garbage collector |
|
6012 | 1972 |
pty := master := slave := execFdArray := stxToCommandPipe := commandToStxPipe := nil. |
5930 | 1973 |
|
2501 | 1974 |
shellPid isNil ifTrue:[ |
5062 | 1975 |
self warn:(resources string:'Cannot start shell'). |
4327 | 1976 |
self closeStreams. |
2501 | 1977 |
^ self. |
1978 |
]. |
|
1979 |
||
4655 | 1980 |
"Created: / 20-07-1998 / 18:19:32 / cg" |
1981 |
"Modified: / 17-07-2014 / 19:43:00 / cg" |
|
6012 | 1982 |
"Modified: / 27-02-2019 / 19:47:02 / Claus Gittinger" |
1983 |
"Modified (comment): / 27-02-2019 / 21:46:32 / Claus Gittinger" |
|
2778 | 1984 |
! |
1985 |
||
1986 |
startCommand:aCommand |
|
1987 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
1988 |
a shell is started. The command is started in the current directory. |
|
1989 |
Also fork a reader process, to read the shells output and |
|
1990 |
tell me, whenever something arrives" |
|
1991 |
||
1992 |
self startCommand:aCommand in:nil |
|
1993 |
||
1994 |
"Modified: / 20.7.1998 / 18:30:24 / cg" |
|
1995 |
! |
|
1996 |
||
1997 |
startCommand:aCommand in:aDirectory |
|
1998 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
1999 |
a shell is started. If aDirectory is not nil, the command is |
|
2000 |
executed in that directory. |
|
2001 |
Also fork a reader process, to read the shells output and |
|
2002 |
tell me, whenever something arrives" |
|
2003 |
||
2004 |
self basicStartCommand:aCommand in:aDirectory. |
|
2005 |
self startReaderProcessWhenVisible. |
|
2501 | 2006 |
|
2007 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
|
2008 |
"Modified: / 5.5.1999 / 17:28:37 / cg" |
|
2009 |
! |
|
2010 |
||
2011 |
startShell |
|
2012 |
"start a shell on a pseudo terminal in the current directory. |
|
2013 |
Also fork a reader process, to read the shells output and |
|
2014 |
tell me, whenever something arrives" |
|
2015 |
||
2016 |
^ self startCommand:nil |
|
2017 |
||
2018 |
" |
|
2019 |
VT100TerminalView openShell |
|
2020 |
" |
|
2021 |
||
2022 |
"Modified: / 20.7.1998 / 18:29:54 / cg" |
|
2023 |
! |
|
2024 |
||
2025 |
startShellIn:aDirectory |
|
2026 |
"start a shell on a pseudo terminal in some directory. |
|
2027 |
Also fork a reader process, to read the shells output and |
|
2028 |
tell me, whenever something arrives" |
|
2029 |
||
2778 | 2030 |
self startCommand:nil in:aDirectory |
2501 | 2031 |
|
2032 |
" |
|
2033 |
VT100TerminalView openShellIn:'/etc' |
|
2034 |
" |
|
2035 |
||
2036 |
"Modified: / 20.7.1998 / 18:29:46 / cg" |
|
2037 |
! ! |
|
2038 |
||
914 | 2039 |
!TerminalView methodsFor:'menu'! |
2040 |
||
3225 | 2041 |
doClear |
2042 |
"reset the scroll-range etc, clear the text buffer" |
|
2043 |
||
2044 |
rangeStartLine := 1. |
|
2045 |
rangeEndLine := numberOfLines. |
|
2046 |
||
2047 |
self normal. |
|
2048 |
self clear. |
|
2049 |
||
2050 |
"Created: / 03-04-2007 / 08:58:59 / cg" |
|
2051 |
! |
|
2052 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2053 |
doReset |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2054 |
"reset the scroll-range; |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2055 |
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
|
2056 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2057 |
rangeStartLine := 1. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2058 |
rangeEndLine := numberOfLines. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2059 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2060 |
self normal. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2061 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2062 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2063 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2064 |
doSendInterrupt |
1420 | 2065 |
"send an INT-signal to the shell (UNIX only)" |
2066 |
||
5008 | 2067 |
DebugKeyboard ifTrue:[ |
2068 |
Transcript showCR:'interrupt!!'. |
|
2069 |
]. |
|
5151 | 2070 |
self sendInterruptSignal |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2071 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
2072 |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2073 |
doSendKillSignal |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2074 |
"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
|
2075 |
|
5008 | 2076 |
DebugKeyboard ifTrue:[ |
2077 |
Transcript showCR:'kill!!'. |
|
2078 |
]. |
|
5151 | 2079 |
self sendKillSignal |
2080 |
! |
|
2081 |
||
2082 |
doSendTerminateSignal |
|
2083 |
"send a TERM-signal to the shell (UNIX only)" |
|
2084 |
||
2085 |
DebugKeyboard ifTrue:[ |
|
2086 |
Transcript showCR:'terminate!!'. |
|
2087 |
]. |
|
2088 |
self sendTerminateSignal |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2089 |
! |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2090 |
|
5537 | 2091 |
doSetLineLimit |
2092 |
"ask for the lineLimit (the number of buffered lines)" |
|
2093 |
||
2094 |
|lineString n| |
|
2095 |
||
2096 |
lineString := Dialog request:'Number of buffered lines:' initialAnswer:(self lineLimit asString). |
|
2097 |
lineString isEmptyOrNil ifTrue:[^ self]. |
|
2098 |
n := Integer readFrom:lineString onError:[^ self]. |
|
2099 |
self lineLimit:(n max:100). |
|
2100 |
||
2101 |
"Created: / 01-05-2017 / 10:27:51 / cg" |
|
2102 |
! |
|
2103 |
||
914 | 2104 |
editMenu |
5354 | 2105 |
"return the view's middleButtonMenu" |
914 | 2106 |
|
1347 | 2107 |
<resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)> |
914 | 2108 |
<resource: #programMenu> |
2109 |
||
4487 | 2110 |
|items subMenu moreMenu m sensor| |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2111 |
|
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2112 |
items := #( |
5537 | 2113 |
('Interrupt' doSendInterrupt ) |
2114 |
('Terminate' doSendTerminateSignal ) |
|
2115 |
('Kill' doSendKillSignal) |
|
2116 |
('-' ) |
|
2117 |
('Clear' doClear ) |
|
2118 |
('Reset' doReset ) |
|
2119 |
('-' ) |
|
2120 |
('Linebuffer Size...' doSetLineLimit ) |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2121 |
). |
5763 | 2122 |
lineEditMode == true ifTrue:[ |
2123 |
items := items , #( |
|
2124 |
('Disable Line Edit Mode' disableLineEditMode ) |
|
2125 |
). |
|
2126 |
] ifFalse:[ |
|
2127 |
items := items , #( |
|
2128 |
('Enable Line Edit Mode' enableLineEditMode ) |
|
2129 |
). |
|
2130 |
]. |
|
2131 |
||
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2132 |
subMenu := PopUpMenu itemList:items resources:resources. |
914 | 2133 |
|
4487 | 2134 |
items := #( |
2135 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
2136 |
). |
|
2137 |
moreMenu := PopUpMenu itemList:items resources:resources. |
|
5753 | 2138 |
shellDirectory isNil ifTrue:[ |
2139 |
moreMenu disable:#openFileBrowserOnIt. |
|
2140 |
]. |
|
4487 | 2141 |
|
914 | 2142 |
((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
|
2143 |
m := subMenu. |
914 | 2144 |
] ifFalse:[ |
2145 |
items := #( |
|
2075 | 2146 |
('Copy' copySelection Copy ) |
2147 |
('Paste' pasteOrReplace Paste ) |
|
914 | 2148 |
('-' ) |
2506 | 2149 |
('Search...' search Find) |
2150 |
('-' ) |
|
2075 | 2151 |
('Font...' changeFont ) |
951 | 2152 |
('-' ) |
2448 | 2153 |
('Save As...' save SaveAs ) |
2075 | 2154 |
('Print' doPrint Print ) |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2155 |
('=' ) |
4487 | 2156 |
('More' more ) |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2157 |
('Shell' others Ctrl ) |
914 | 2158 |
). |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2159 |
m := PopUpMenu itemList:items resources:resources. |
4487 | 2160 |
m subMenuAt:#more put:moreMenu. |
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2161 |
m subMenuAt:#others put:subMenu. |
1347 | 2162 |
|
2163 |
"/ disabled - for now; |
|
2164 |
"/ need a more intelligent filtering of control characters. |
|
2165 |
"/ |
|
2166 |
"/ filterStream isNil ifTrue:[ |
|
2167 |
"/ items := items , #( |
|
2168 |
"/ ('-' ) |
|
2075 | 2169 |
"/ ('Start Save as ...' startSaveAs ) |
2170 |
"/ ('Start Print' startPrint ) |
|
1347 | 2171 |
"/ ) |
2172 |
"/ ] ifFalse:[ |
|
2173 |
"/ items := items , #( |
|
2174 |
"/ ('-' ) |
|
2075 | 2175 |
"/ ('Stop filter' stopFilter ) |
1347 | 2176 |
"/ ) |
2177 |
"/ ]. |
|
914 | 2178 |
]. |
2179 |
||
2810
d57cc02787de
refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
2778
diff
changeset
|
2180 |
self hasSelection ifFalse:[ |
914 | 2181 |
m disable:#copySelection. |
2182 |
]. |
|
2183 |
^ m. |
|
2184 |
||
5537 | 2185 |
"Modified: / 01-05-2017 / 10:28:30 / cg" |
1347 | 2186 |
! |
2187 |
||
4487 | 2188 |
openFileBrowserOnIt |
2189 |
"open a fileBrowser on the selected fileName" |
|
2190 |
||
4836 | 2191 |
|selection fileName| |
4487 | 2192 |
|
4630 | 2193 |
shellDirectory notNil ifTrue:[ |
4836 | 2194 |
selection := self selectionAsString. |
2195 |
fileName := selection asFilename. |
|
2196 |
fileName isAbsolute ifFalse:[ |
|
4837 | 2197 |
fileName := shellDirectory construct:selection. |
4836 | 2198 |
]. |
2199 |
self openFileBrowserOnFileNamed:fileName pathName |
|
4630 | 2200 |
]. |
4487 | 2201 |
! |
2202 |
||
5151 | 2203 |
sendInterruptSignal |
2204 |
"send an INT-signal to the shell (UNIX only)" |
|
2205 |
||
2206 |
shellPid notNil ifTrue:[ |
|
2207 |
OperatingSystem isUNIXlike ifTrue:[ |
|
2208 |
OperatingSystem interruptProcessGroup:shellPid. |
|
2209 |
OperatingSystem interruptProcess:shellPid. |
|
2210 |
"/ status := OperatingSystem childProcessWait:false pid:shellPid. |
|
2211 |
] ifFalse:[ |
|
5659 | 2212 |
'TerminalView [info]: IRQ unimplemented for DOS' infoPrintCR. |
5151 | 2213 |
] |
2214 |
] ifFalse:[ |
|
5659 | 2215 |
'TerminalView [info]: no shell' infoPrintCR. |
5151 | 2216 |
]. |
2217 |
||
2218 |
"Modified: / 10.6.1998 / 17:49:49 / cg" |
|
2219 |
! |
|
2220 |
||
2221 |
sendKillSignal |
|
2222 |
"send a KILL-signal to the shell (UNIX only)" |
|
2223 |
||
2224 |
|status| |
|
2225 |
||
2226 |
shellPid notNil ifTrue:[ |
|
2227 |
OperatingSystem isUNIXlike ifTrue:[ |
|
2228 |
OperatingSystem killProcessGroup:shellPid. |
|
2229 |
OperatingSystem killProcess:shellPid. |
|
2230 |
status := OperatingSystem childProcessWait:false pid:shellPid. |
|
2231 |
] ifFalse:[ |
|
2232 |
self warn:(resources string:'unimplemented for DOS') |
|
2233 |
] |
|
2234 |
] ifFalse:[ |
|
2235 |
'VT100: no shell' infoPrintCR. |
|
2236 |
] |
|
2237 |
! |
|
2238 |
||
2239 |
sendTerminateSignal |
|
2240 |
"send a TERM-signal to the shell (UNIX only)" |
|
2241 |
||
2242 |
shellPid notNil ifTrue:[ |
|
2243 |
OperatingSystem terminateProcessGroup:shellPid. |
|
2244 |
OperatingSystem terminateProcess:shellPid. |
|
2245 |
"/ status := OperatingSystem childProcessWait:false pid:shellPid. |
|
2246 |
] ifFalse:[ |
|
2247 |
'VT100: no shell' infoPrintCR. |
|
2248 |
]. |
|
2249 |
! |
|
2250 |
||
4295 | 2251 |
setGreenDisplayMode |
5164 | 2252 |
self foregroundColor:Color green backgroundColor:self blackColor. |
2253 |
self cursorForegroundColor:self blackColor backgroundColor:Color green. |
|
4295 | 2254 |
! |
2255 |
||
2256 |
setNormalDisplayMode |
|
5164 | 2257 |
self foregroundColor:self blackColor backgroundColor:self whiteColor. |
2258 |
self cursorForegroundColor:self whiteColor backgroundColor:self blackColor. |
|
4295 | 2259 |
! |
2260 |
||
4300 | 2261 |
setRedDisplayMode |
5164 | 2262 |
self foregroundColor:(self whiteColor) backgroundColor:(Color red:80). |
2263 |
self cursorForegroundColor:(Color red:80) backgroundColor:(self whiteColor). |
|
4300 | 2264 |
! |
2265 |
||
4295 | 2266 |
setReverseDisplayMode |
2267 |
|fg bg| |
|
2268 |
||
2269 |
fg := self foregroundColor. |
|
2270 |
bg := self backgroundColor. |
|
2271 |
self foregroundColor:bg backgroundColor:fg. |
|
2272 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
2273 |
! |
|
2274 |
||
1347 | 2275 |
startSaveAs |
2276 |
"start saving all received data to some file" |
|
2277 |
||
2278 |
|fn| |
|
2279 |
||
2280 |
fn := Dialog requestFileName:'Save received data in file:'. |
|
6017 | 2281 |
fn size ~~ 0 ifTrue:[ |
1347 | 2282 |
filterStream := fn asFilename writeStream |
2283 |
]. |
|
2284 |
||
6017 | 2285 |
"Created: / 29-04-1999 / 11:06:29 / cg" |
2286 |
"Modified: / 01-03-2019 / 16:13:13 / Claus Gittinger" |
|
1347 | 2287 |
! |
2288 |
||
2289 |
stopFilter |
|
2290 |
"stop saving/printing of received data" |
|
2291 |
||
2292 |
filterStream close. |
|
2293 |
filterStream := nil. |
|
2294 |
||
2295 |
"Created: / 29.4.1999 / 11:07:49 / cg" |
|
2296 |
"Modified: / 29.4.1999 / 11:09:52 / cg" |
|
914 | 2297 |
! ! |
2298 |
||
940 | 2299 |
!TerminalView methodsFor:'misc'! |
914 | 2300 |
|
5008 | 2301 |
debugPrintCharacter:aCharacter as:what |
2302 |
Transcript show:what; show:' <'. |
|
2303 |
aCharacter codePoint < 32 ifTrue:[ |
|
2304 |
Transcript show:'\x'; show:(aCharacter codePoint hexPrintString:2) |
|
2305 |
] ifFalse:[ |
|
2306 |
Transcript show:aCharacter |
|
2307 |
]. |
|
2308 |
Transcript showCR:'>' |
|
2309 |
! |
|
2310 |
||
914 | 2311 |
removeTrailingBlankLines |
2312 |
^ self |
|
2313 |
! ! |
|
2314 |
||
2498 | 2315 |
!TerminalView methodsFor:'processing-input'! |
914 | 2316 |
|
1420 | 2317 |
doNothing |
2318 |
"private - end of an ignored escape-sequence" |
|
2319 |
||
2320 |
self endOfSequence |
|
2321 |
||
2322 |
"Created: / 12.6.1998 / 20:40:43 / cg" |
|
2323 |
! |
|
2324 |
||
2325 |
endOfSequence |
|
2326 |
"private - reset state-machine at end of escape-sequence" |
|
2327 |
||
2328 |
state := 0. |
|
2329 |
||
2330 |
"Created: / 12.6.1998 / 20:39:52 / cg" |
|
2331 |
! |
|
2332 |
||
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2333 |
nextPut:char |
5145 | 2334 |
"process a character (i.e. the shell's output)" |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2335 |
|
4809 | 2336 |
"/ Debug := true |
2337 |
"/ Debug := false |
|
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2338 |
Debug ifTrue:[ |
4809 | 2339 |
Transcript show:state; show:' <'; show:(char codePoint hexPrintString:2); showCR:'>'. |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2340 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2341 |
|
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2342 |
(char == Character nl) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2343 |
self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2344 |
self doCursorDown:1. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2345 |
^ self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2346 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2347 |
(char == Character return) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2348 |
self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2349 |
self cursorToBeginOfLine. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2350 |
^ self. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2351 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2352 |
(char == Character backspace) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2353 |
self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2354 |
self doCursorLeft:1. "/ doBackspace |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2355 |
^ self endEntry. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2356 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2357 |
(char == Character bell) ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2358 |
self beep. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2359 |
^ self |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2360 |
]. |
5156 | 2361 |
char codePoint < 32 ifTrue:[ |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2362 |
char ~~ Character tab ifTrue:[ |
5156 | 2363 |
char codePoint ~~ 0 ifTrue:[ |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2364 |
Debug ifTrue:[ |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2365 |
Transcript show:'unhandled control key: '; showCR:char storeString. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2366 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2367 |
]. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2368 |
^ self. |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2369 |
] |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2370 |
]. |
5145 | 2371 |
self show:char; endEntry. |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2372 |
|
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2373 |
"Modified: / 21.7.1998 / 20:06:04 / cg" |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2374 |
! |
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2375 |
|
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
2376 |
nextPutAll:aString |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2377 |
"/ self processInput:aString n:aString size |
2594 | 2378 |
|
4285 | 2379 |
Debug ifTrue:[ |
2380 |
Transcript |
|
6078 | 2381 |
show:(self className); show:': nextPutAll - state: '; show:state; |
4809 | 2382 |
show:' got: <'. |
2383 |
aString do:[:ch | |
|
2384 |
Transcript show:'<'; show:(ch codePoint hexPrintString:2); show:'>' |
|
2385 |
]. |
|
2386 |
Transcript cr; endEntry. |
|
4285 | 2387 |
]. |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2388 |
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
|
2389 |
|
6078 | 2390 |
"Created: / 27-07-1998 / 15:10:59 / cg" |
2391 |
"Modified: / 27-07-1998 / 23:16:19 / cg" |
|
2392 |
"Modified: / 28-06-2019 / 09:20:08 / Claus Gittinger" |
|
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
2393 |
! |
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
2394 |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2395 |
processInput:buffer n:count |
4315 | 2396 |
"actually: output coming from the connected application (aka input to me); |
2397 |
the stuff coming from the application is a mix of plain text and CSI escape sequences. |
|
2398 |
If we process each character individually, things are trivial, but slow. |
|
2399 |
Therefore, we collect big chunks of non-escaped text and buffer them to make |
|
2400 |
use of the inherited buffered output optimizations (see TextCollector). |
|
2401 |
Thus, we collect until an escape sequence is encountered, and flush the buffered stuff then, |
|
2402 |
proceed in single-character mode (processState0:) until the sequence is finished, and continue |
|
2403 |
collecting. |
|
2404 |
This makes this terminalView's speed usable and actually competitive with some existing |
|
4612 | 2405 |
console applications. |
2406 |
BTW: It is *much* faster than the MSWindows command.com window, |
|
2407 |
- so much for the 'slow' Smalltalk ;-)" |
|
4315 | 2408 |
|
997 | 2409 |
|sensor| |
2410 |
||
4315 | 2411 |
"/ remember how much is in the queue... |
2412 |
[ |
|
2413 |
sizeOfOutstandingInputToBeProcessed := sizeOfOutstandingInputToBeProcessed - count. |
|
2414 |
] valueUninterruptably. |
|
4449 | 2415 |
"/ Debug := true |
4450 | 2416 |
"/ Debug := false |
4285 | 2417 |
Debug ifTrue:[ |
6078 | 2418 |
Transcript show:self className; show:': processInput - state: '; show: state; |
4446
02b5fbf621d3
refactored character processing
Claus Gittinger <cg@exept.de>
parents:
4338
diff
changeset
|
2419 |
show:' got: '; showCR: count. |
4285 | 2420 |
]. |
2421 |
||
1347 | 2422 |
filterStream notNil ifTrue:[ |
2423 |
filterStream nextPutAll:(buffer copyTo:count). |
|
5249 | 2424 |
filterOnly ifTrue:[^ self]. |
1347 | 2425 |
]. |
4267 | 2426 |
"/ '*' print. (buffer copyTo:count) asByteArray hexPrintString printCR. |
1347 | 2427 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
2428 |
"/ self hideCursor. |
997 | 2429 |
|
1015 | 2430 |
"/ the following may not be too clean, but adds a lot of speed. |
2431 |
"/ instead of passing every individual character through the |
|
2432 |
"/ escape-state machine, collect chunks of non-control text |
|
2433 |
"/ when in state 0, and add them immediately to the pendingLines |
|
2434 |
"/ collection of the textCollectors asynchronous update mechanism. |
|
2435 |
"/ This helps a lot if you do something like "ls -lR /" ... |
|
2436 |
"/ For debugging the state machine, reenable the commented lines |
|
2437 |
"/ below. |
|
2438 |
||
2439 |
"/1 to:count do:[:i| |
|
2440 |
"/ self nextPut:(buffer at:i). |
|
2441 |
"/]. |
|
2442 |
"/self showCursor. |
|
2443 |
"/^ self. |
|
2444 |
||
2445 |
access critical:[ |
|
5242 | 2446 |
|index controlCharIndex stringWithOutControl crnlFollows |
2447 |
nFit nCharsInLine charIdx oldCollectSize| |
|
997 | 2448 |
|
2191 | 2449 |
index := 1. |
2450 |
[index <= count] whileTrue:[ |
|
4290 | 2451 |
stringWithOutControl := nil. |
2452 |
||
4321 | 2453 |
(state == 0) ifTrue:[ |
4267 | 2454 |
"/ in initial state: |
1015 | 2455 |
"/ quick scan forward for next control character ... |
2191 | 2456 |
controlCharIndex := buffer indexOfControlCharacterStartingAt:index. |
2457 |
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
|
2458 |
|
2191 | 2459 |
controlCharIndex == 0 ifTrue:[ |
1015 | 2460 |
"/ no control characters - simply append all |
4267 | 2461 |
"/ to the outstanding lines... |
2191 | 2462 |
stringWithOutControl := buffer copyFrom:index to:count. |
4267 | 2463 |
crnlFollows := false. |
2191 | 2464 |
index := count + 1. "/ leave loop. |
1015 | 2465 |
] ifFalse:[ |
2191 | 2466 |
controlCharIndex > index ifTrue:[ |
4267 | 2467 |
"/ some more regular character(s) before control character |
2191 | 2468 |
stringWithOutControl := buffer copyFrom:index to:controlCharIndex-1. |
2469 |
index := controlCharIndex. "/ proceed withcontrol character |
|
1015 | 2470 |
crnlFollows := false. |
2191 | 2471 |
index < (count - 1) ifTrue:[ |
2472 |
(buffer at:index) == Character return ifTrue:[ |
|
2473 |
(buffer at:index+1) == Character nl ifTrue:[ |
|
1015 | 2474 |
crnlFollows := true. |
2191 | 2475 |
index := index + 2. |
1015 | 2476 |
] |
997 | 2477 |
] |
1015 | 2478 |
]. |
4267 | 2479 |
] ifFalse:[ |
2480 |
"/ controlchr immediately follows |
|
1015 | 2481 |
] |
2482 |
]. |
|
997 | 2483 |
]. |
2484 |
||
2191 | 2485 |
stringWithOutControl notNil ifTrue:[ |
4614 | 2486 |
doUTF ifTrue:[ |
2487 |
Error handle:[:ex | |
|
2488 |
] do:[ |
|
2489 |
stringWithOutControl := stringWithOutControl utf8Decoded |
|
2490 |
]. |
|
4612 | 2491 |
]. |
5242 | 2492 |
nCharsInLine := stringWithOutControl size. |
5244 | 2493 |
(autoWrapFlag |
2494 |
and:[ (cursorCol + outstandingLine size + nCharsInLine) >= numberOfColumns ] |
|
2495 |
) ifTrue:[ |
|
5242 | 2496 |
charIdx := 1. |
2497 |
nFit := numberOfColumns - outstandingLine size - cursorCol - 1. |
|
2498 |
nFit > 0 ifTrue:[ |
|
2499 |
access critical:[ |
|
6017 | 2500 |
outstandingLine size ~~ 0 ifTrue:[ |
5242 | 2501 |
outstandingLine := outstandingLine , (stringWithOutControl copyTo:nFit). |
2502 |
] ifFalse:[ |
|
2503 |
outstandingLine := (stringWithOutControl copyTo:nFit). |
|
2504 |
]. |
|
2505 |
]. |
|
2506 |
charIdx := nFit + 1. |
|
2507 |
]. |
|
2508 |
"/ Transcript show:'idx: '; show:charIdx; show:' n:'; showCR:nCharsInLine. |
|
2509 |
oldCollectSize := collectSize. |
|
2510 |
collectSize := 32*1024. |
|
4321 | 2511 |
"/ characterwise, for correct wrap handling at line end |
5242 | 2512 |
[charIdx <= nCharsInLine] whileTrue:[ |
2513 |
|eachCharacter| |
|
2514 |
||
2515 |
eachCharacter := stringWithOutControl at:charIdx. |
|
2268 | 2516 |
self nextPut:eachCharacter. |
5242 | 2517 |
"/ self endEntry. |
4452 | 2518 |
cursorCol >= numberOfColumns ifTrue:[ |
5242 | 2519 |
"/ self endEntry. |
4452 | 2520 |
self validateCursorCol:cursorCol inLine:cursorLine. |
5242 | 2521 |
"/ Transcript show:'col now: '; showCR:cursorCol. |
2522 |
nFit := numberOfColumns - cursorCol - charIdx. |
|
5243 | 2523 |
"/ Transcript show:'nFit now: '; showCR:nFit. |
4452 | 2524 |
]. |
5242 | 2525 |
charIdx := charIdx + 1. |
2268 | 2526 |
]. |
2356 | 2527 |
crnlFollows ifTrue:[ |
2528 |
self nextPut:Character return. |
|
2529 |
self nextPut:Character nl. |
|
2530 |
]. |
|
2531 |
self endEntry. |
|
5242 | 2532 |
collectSize := oldCollectSize. |
997 | 2533 |
] ifFalse:[ |
2356 | 2534 |
|
2535 |
Debug ifTrue:[ |
|
2536 |
Transcript showCR:'String:<', stringWithOutControl, '>'. |
|
4809 | 2537 |
stringWithOutControl do:[:ch | |
4811 | 2538 |
"/ ch codePoint > 255 ifTrue:[self halt]. |
4809 | 2539 |
Transcript show:'<'; show:(ch codePoint hexPrintString:2); show:'>' |
2540 |
]. |
|
2541 |
Transcript cr. |
|
2356 | 2542 |
]. |
2543 |
currentEmphasis notNil ifTrue:[ |
|
2544 |
stringWithOutControl := stringWithOutControl emphasizeAllWith:currentEmphasis |
|
2545 |
]. |
|
2546 |
||
4449 | 2547 |
access critical:[ |
6017 | 2548 |
outstandingLine size ~~ 0 ifTrue:[ |
4449 | 2549 |
outstandingLine := outstandingLine , stringWithOutControl. |
2550 |
] ifFalse:[ |
|
2551 |
outstandingLine := stringWithOutControl. |
|
2552 |
]. |
|
2553 |
crnlFollows ifTrue:[ |
|
2554 |
"/ 'xp' printCR. |
|
2555 |
outstandingLines isNil ifTrue:[ |
|
2556 |
outstandingLines := OrderedCollection with:outstandingLine |
|
2557 |
] ifFalse:[ |
|
2558 |
outstandingLines add:outstandingLine. |
|
2559 |
]. |
|
2560 |
outstandingLine := ''. |
|
2561 |
]. |
|
1015 | 2562 |
]. |
4321 | 2563 |
"/ collecting ifTrue:[ |
2564 |
"/ flushPending ifFalse:[ |
|
2565 |
"/ self installDelayedUpdate |
|
2566 |
"/ ] ifTrue:[ |
|
2567 |
"/ "/ outstandingLines size > collectSize ifTrue:[ |
|
2568 |
"/ "/ self endEntry |
|
2569 |
"/ "/ ] |
|
2570 |
"/ ] |
|
2571 |
"/ ] ifFalse:[ |
|
2572 |
"/ self endEntry |
|
2573 |
"/ ]. |
|
1015 | 2574 |
]. |
997 | 2575 |
] ifFalse:[ |
1015 | 2576 |
"/ no chunk to append (in an escape sequence) |
2577 |
"/ must handle individual characters |
|
2578 |
"/ 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
|
2579 |
|
4290 | 2580 |
"/ self endEntry. |
2207 | 2581 |
self nextPut:(buffer at:index). |
2191 | 2582 |
index := index + 1. |
2583 |
[state ~~ 0 and:[index <= count]] whileTrue:[ |
|
2207 | 2584 |
self nextPut:(buffer at:index). |
2191 | 2585 |
index := index + 1. |
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2586 |
] |
1015 | 2587 |
] |
2588 |
]. |
|
4321 | 2589 |
"/ inFlush := false. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2590 |
]. |
948 | 2591 |
|
4321 | 2592 |
(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
|
2593 |
(sensor := self sensor) notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2594 |
"/ 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
|
2595 |
"/ enforce update of the view (asynchronous) |
997 | 2596 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2597 |
(sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
997 | 2598 |
self endEntry. |
2599 |
self showCursor. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2600 |
"/ self makeCursorVisible. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2601 |
] ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2602 |
"/ 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
|
2603 |
"/ 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
|
2604 |
"/ 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
|
2605 |
"/ 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
|
2606 |
"/ collectSize lines. |
1015 | 2607 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2608 |
outstandingLines size > collectSize ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2609 |
self endEntry. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2610 |
self showCursor. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2611 |
|
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2612 |
"/ 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
|
2613 |
windowGroup notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2614 |
windowGroup processRealExposeEventsFor:self. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2615 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2616 |
]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2617 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
2618 |
]. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2619 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
2620 |
|
4315 | 2621 |
"Created: / 10-06-1998 / 17:26:09 / cg" |
2622 |
"Modified: / 28-01-2002 / 20:41:36 / micha" |
|
2623 |
"Modified: / 30-07-2013 / 10:47:19 / cg" |
|
6078 | 2624 |
"Modified: / 28-06-2019 / 09:20:12 / Claus Gittinger" |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2625 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2626 |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2627 |
sync |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2628 |
self waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2629 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2630 |
"Created: / 27.7.1998 / 23:49:44 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2631 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2632 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2633 |
waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2634 |
|sensor| |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2635 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2636 |
sensor := self sensor. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
2637 |
(sensor notNil and:[sensor userEventCount > 30]) ifTrue:[ |
1323 | 2638 |
[sensor userEventCount > 5] whileTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2639 |
"/ give terminalView a chance to |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2640 |
"/ catch up. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2641 |
Delay waitForSeconds:0.1. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2642 |
] |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2643 |
]. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2644 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
2645 |
"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
|
2646 |
"Modified: / 5.5.1999 / 18:51:00 / cg" |
914 | 2647 |
! ! |
2648 |
||
2649 |
!TerminalView methodsFor:'queries'! |
|
2650 |
||
5950 | 2651 |
computePreferredExtent |
1420 | 2652 |
"return my preferred extent - this is computed from my numberOfLines, |
2653 |
numberOfCols and font size" |
|
2654 |
||
5330 | 2655 |
^ (fontWidth * self class defaultNumberOfColumns + ((leftMargin + margin) * 2)) |
951 | 2656 |
@ |
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2657 |
((self heightForLines:self class defaultNumberOfLines) + 8) |
926 | 2658 |
|
5950 | 2659 |
"Created: / 09-11-2018 / 20:02:19 / Claus Gittinger" |
2660 |
! |
|
2661 |
||
2662 |
isKeyboardConsumer |
|
2663 |
"return true, if the receiver is a keyboard consumer; |
|
2664 |
Always return true here" |
|
2665 |
||
2666 |
^ true |
|
929 | 2667 |
! |
2668 |
||
2669 |
terminalType |
|
1420 | 2670 |
"returns a string describing this terminal (usually, this is |
2671 |
passed down to the shell as TERM environment variable). |
|
2672 |
Here, 'dump' is returned." |
|
2673 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
2674 |
^ 'dump' |
929 | 2675 |
|
2676 |
"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
|
2677 |
"Modified: / 5.5.1999 / 11:22:32 / cg" |
914 | 2678 |
! ! |
2679 |
||
4265 | 2680 |
!TerminalView methodsFor:'reader process'! |
2681 |
||
4315 | 2682 |
readAnyAvailableData |
2683 |
"read data from the stream, |
|
2684 |
and sends me #processInput:n: events if something arrived. |
|
2685 |
Returns the amount of data read." |
|
2686 |
||
2687 |
|buffer n bufferSize| |
|
2688 |
||
2689 |
outStream isNil ifTrue:[^ 0]. |
|
2690 |
||
2691 |
"/ avoid too many processInput messages to be in the buffer, |
|
2692 |
"/ otherwise, the reaction on ctrl-s/ctrl-c is too slow, as |
|
2693 |
"/ many processInput messages are in the sensor's queue before the keypress |
|
2694 |
"/ event. We need another queue, actually so the sensor's keypress events |
|
2695 |
"/ are not blocked while reading a lot of input. |
|
2696 |
[sizeOfOutstandingInputToBeProcessed > 4096] whileTrue:[ |
|
2697 |
Delay waitForSeconds:0.1 |
|
2698 |
]. |
|
2699 |
||
4641 | 2700 |
bufferSize := 1024*2. |
4315 | 2701 |
|
2702 |
buffer := String new:bufferSize. |
|
5306 | 2703 |
(StreamNotOpenError,ReadError) handle:[:ex | |
4315 | 2704 |
n := 0 |
2705 |
] do:[ |
|
2706 |
n := outStream nextAvailableBytes:bufferSize into:buffer startingAt:1. |
|
2707 |
]. |
|
2708 |
n > 0 ifTrue:[ |
|
4641 | 2709 |
ignoreOutput ifFalse:[ |
2710 |
"/ Transcript showCR:n. |
|
2711 |
self pushEvent:#processInput:n: with:buffer with:n. |
|
2712 |
"/ remember how much is in the queue... |
|
2713 |
[ |
|
2714 |
sizeOfOutstandingInputToBeProcessed := sizeOfOutstandingInputToBeProcessed + n. |
|
2715 |
] valueUninterruptably |
|
2716 |
]. |
|
4315 | 2717 |
]. |
2718 |
||
2719 |
^ n |
|
2720 |
||
2721 |
"Created: / 05-05-1999 / 17:57:39 / cg" |
|
2722 |
"Modified: / 28-01-2002 / 21:10:25 / micha" |
|
2723 |
"Modified (comment): / 30-07-2013 / 10:50:03 / cg" |
|
2724 |
! |
|
2725 |
||
4265 | 2726 |
readerProcessLoop |
4777 | 2727 |
"look for the command's output, |
4265 | 2728 |
and send me #processInput:n: events whenever something arrives." |
2729 |
||
2730 |
StreamError handle:[:ex | |
|
2731 |
Transcript show:'Terminal(PTY-reader) [error]: '; showCR:ex description. |
|
2732 |
] do:[ |
|
2733 |
[true] whileTrue:[ |
|
2734 |
AbortOperationRequest handle:[:ex | |
|
2735 |
self showCursor. |
|
4457 | 2736 |
(outStream isNil or:[outStream atEnd]) ifTrue:[ ex reject ]. |
4265 | 2737 |
] do:[ |
2738 |
|n sensor| |
|
2739 |
||
4612 | 2740 |
"/ Delay waitForSeconds:0.01. |
4265 | 2741 |
outStream readWait. |
2742 |
sensor := self sensor. |
|
2743 |
(sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[ |
|
2744 |
true "(sensor userEventCount > 10)" ifTrue:[ |
|
2745 |
"/ give terminalView a chance to |
|
2746 |
"/ send out the character. |
|
4321 | 2747 |
"/ Transcript showCR:'d'. |
4265 | 2748 |
Delay waitForSeconds:0.01. |
2749 |
] |
|
2750 |
] ifFalse:[ |
|
2751 |
n := self readAnyAvailableData. |
|
2752 |
n > 0 ifTrue:[ |
|
2753 |
shellPid notNil ifTrue:[ |
|
2754 |
self waitForOutputToDrain. |
|
2755 |
] |
|
2756 |
] ifFalse:[ |
|
2757 |
n == 0 ifTrue:[ |
|
2758 |
"/ Windows IPC has a bug - it always |
|
2759 |
"/ returns 0 (when the command is idle) |
|
4612 | 2760 |
"/ and says it's at the end (sigh) |
4265 | 2761 |
|
2762 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
2763 |
Delay waitForSeconds:0.01 |
|
2764 |
] ifFalse:[ |
|
2765 |
outStream atEnd ifTrue:[ |
|
4327 | 2766 |
self closeStreams. |
4265 | 2767 |
Processor activeProcess terminate. |
2768 |
] ifFalse:[ |
|
2769 |
"/ this should not happen. |
|
2770 |
Delay waitForSeconds:0.05 |
|
2771 |
] |
|
2772 |
]. |
|
2773 |
] |
|
2774 |
] |
|
2775 |
] |
|
2776 |
] |
|
2777 |
] |
|
2778 |
] |
|
4315 | 2779 |
|
2780 |
"Modified: / 30-07-2013 / 10:30:38 / cg" |
|
4265 | 2781 |
! |
2782 |
||
2783 |
startReaderProcess |
|
2784 |
"Start a reader process, which looks for the commands output, |
|
2785 |
and sends me #processInput:n: events whenever something arrives." |
|
2786 |
||
2787 |
self obsoleteMethodWarning. |
|
2788 |
self startReaderProcessWhenVisible. |
|
2789 |
||
2790 |
" |
|
2791 |
VT100TerminalView openShell |
|
2792 |
" |
|
2793 |
||
2794 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
|
2795 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
|
2796 |
! |
|
2797 |
||
2798 |
startReaderProcessNow |
|
2799 |
"Start a reader process, which looks for the commands output, |
|
2800 |
and sends me #processInput:n: events whenever something arrives." |
|
2801 |
||
4612 | 2802 |
self startReaderProcessWhenVisible:false |
4265 | 2803 |
|
2804 |
" |
|
2805 |
VT100TerminalView openShell |
|
2806 |
" |
|
2807 |
||
2808 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
|
2809 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
|
2810 |
! |
|
2811 |
||
2812 |
startReaderProcessWhenVisible |
|
2813 |
"Start a reader process, which looks for the commands output, |
|
2814 |
and sends me #processInput:n: events whenever something arrives." |
|
2815 |
||
4612 | 2816 |
self startReaderProcessWhenVisible:true |
2817 |
||
2818 |
" |
|
2819 |
VT100TerminalView openShell |
|
2820 |
" |
|
2821 |
||
2822 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
|
2823 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
|
2824 |
! |
|
2825 |
||
2826 |
startReaderProcessWhenVisible:whenVisible |
|
2827 |
"Start a reader process, which looks for the commands output, |
|
2828 |
and sends me #processInput:n: events whenever something arrives." |
|
2829 |
||
4265 | 2830 |
readerProcess isNil ifTrue:[ |
2831 |
readerProcess := [ |
|
2832 |
[ |
|
4612 | 2833 |
whenVisible ifTrue:[self waitUntilVisible]. |
4265 | 2834 |
self readerProcessLoop. |
2835 |
] ifCurtailed:[ |
|
2836 |
readerProcess := nil |
|
2837 |
] |
|
2838 |
] fork. "/ forkAt:9. |
|
5888 | 2839 |
readerProcess name:'Terminal: pty reader'. |
4265 | 2840 |
] |
2841 |
||
2842 |
" |
|
2843 |
VT100TerminalView openShell |
|
2844 |
" |
|
2845 |
||
5888 | 2846 |
"Modified: / 05-05-1999 / 17:58:02 / cg" |
2847 |
"Modified: / 28-01-2002 / 21:10:13 / micha" |
|
2848 |
"Modified: / 16-08-2018 / 13:22:32 / Claus Gittinger" |
|
4265 | 2849 |
! |
2850 |
||
2851 |
stopReaderProcess |
|
2852 |
"stop the background reader thread" |
|
2853 |
||
2854 |
|sensor| |
|
2855 |
||
2856 |
readerProcess notNil ifTrue:[ |
|
2857 |
readerProcess terminate. |
|
2858 |
"/ give it a chance to really terminate |
|
2859 |
Processor yield. |
|
2860 |
readerProcess := nil |
|
2861 |
]. |
|
2862 |
||
2863 |
"/ flush any leftover input-processing events |
|
2864 |
(sensor := self sensor) notNil ifTrue:[ |
|
2865 |
sensor flushEventsFor:self withType:#processInput:n:. |
|
2866 |
] |
|
2867 |
"Modified: / 21.7.1998 / 19:00:13 / cg" |
|
2868 |
! ! |
|
2869 |
||
2506 | 2870 |
!TerminalView methodsFor:'searching'! |
2871 |
||
2872 |
startPositionForSearchBackward |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2873 |
^ self startPositionForSearchBackwardBasedOnSelection |
2506 | 2874 |
! |
2875 |
||
2876 |
startPositionForSearchForward |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2877 |
^ self startPositionForSearchForwardBasedOnSelection |
2506 | 2878 |
! ! |
2879 |
||
914 | 2880 |
!TerminalView methodsFor:'selection handling'! |
2881 |
||
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2882 |
autoMoveCursorToEndOfSelection |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2883 |
"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
|
2884 |
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
|
2885 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2886 |
^ false |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2887 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2888 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
2889 |
|
5151 | 2890 |
copySelection |
5716 | 2891 |
"the inherited code would leave the cursor behin the selection; |
2892 |
we always want it to stay at the end. |
|
2893 |
However: cursorToEndOfText ignores trailing spaces!! |
|
2894 |
" |
|
2895 |
||
2896 |
|cLine cCol| |
|
2897 |
||
2898 |
cLine := cursorLine. |
|
2899 |
cCol := cursorCol. |
|
5151 | 2900 |
super copySelection. |
5716 | 2901 |
"/ self cursorToEndOfText |
2902 |
self cursorLine:cLine col:cCol. |
|
5151 | 2903 |
! |
2904 |
||
914 | 2905 |
paste:someText |
2906 |
"paste - redefined to send the chars to the shell instead |
|
2907 |
of pasting into the view" |
|
2908 |
||
5223 | 2909 |
|s nLines doLineEditMode| |
950 | 2910 |
|
2573
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2911 |
inStream isNil ifTrue:[ |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2912 |
self flash. |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2913 |
^ self "/ already closed |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2914 |
]. |
9ef4727d2a57
menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents:
2539
diff
changeset
|
2915 |
|
950 | 2916 |
s := someText. |
2917 |
s isString ifTrue:[ |
|
2918 |
s := s asStringCollection |
|
2919 |
] ifFalse:[ |
|
2920 |
(s isKindOf:StringCollection) ifFalse:[ |
|
2921 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
2922 |
^ self |
|
2923 |
] |
|
2924 |
]. |
|
2925 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
5223 | 2926 |
(nLines == 1 and:[(s at:1) isEmptyOrNil]) ifTrue:[^ self]. |
2927 |
||
2928 |
doLineEditMode := ((nLines == 1) and:[self shouldProcessInputInLineEditMode]). |
|
2929 |
||
950 | 2930 |
s keysAndValuesDo:[:idx :line | |
4285 | 2931 |
line notNil ifTrue:[ |
5008 | 2932 |
(Debug or:[DebugKeyboard]) ifTrue:[ |
4285 | 2933 |
Transcript showCR:'send paste line: ',line asByteArray hexPrintString |
2934 |
]. |
|
2935 |
]. |
|
5223 | 2936 |
doLineEditMode ifTrue:[ |
4601 | 2937 |
line do:[:ch | self keyPressInLineEditMode:ch ]. |
2938 |
idx ~~ nLines ifTrue:[ |
|
2939 |
self keyPressInLineEditMode:#Return |
|
2940 |
] |
|
4317 | 2941 |
] ifFalse:[ |
5223 | 2942 |
self send:(line ? ''). |
4601 | 2943 |
idx ~~ nLines ifTrue:[ |
2944 |
self sendLineEnd |
|
2945 |
] |
|
950 | 2946 |
] |
2947 |
]. |
|
2948 |
||
2949 |
"Modified: / 12.6.1998 / 22:12:47 / cg" |
|
4490 | 2950 |
! |
2951 |
||
2952 |
selection |
|
2953 |
|sel| |
|
2954 |
||
2955 |
sel := super selection. |
|
4492 | 2956 |
sel isNil ifTrue:[^ sel]. |
4490 | 2957 |
|
2958 |
"/ if it is a line-wise collection, return multiple lines; |
|
2959 |
"/ otherwise, concatenate to make it one long string. |
|
2960 |
"/ this allows for multi-line commands (many args) to be copy-pasted easily |
|
2961 |
selectionStartCol == 1 ifTrue:[ |
|
2962 |
selectionEndCol == 0 ifTrue:[ |
|
2963 |
^ sel "/ a full-line (3xclick selection) |
|
2964 |
]. |
|
2965 |
]. |
|
2966 |
^ StringCollection with:(sel asStringWith:''). |
|
914 | 2967 |
! ! |
2968 |
||
4604 | 2969 |
!TerminalView methodsFor:'sending'! |
2970 |
||
2971 |
send:aString |
|
2972 |
"send aString to the underlying program's stdinput" |
|
2973 |
||
2974 |
aString notEmptyOrNil ifTrue:[ |
|
4809 | 2975 |
aString containsNon7BitAscii ifTrue:[ |
2976 |
aString do:[:each | |
|
2977 |
self sendCharacter:each |
|
2978 |
]. |
|
2979 |
] ifFalse:[ |
|
2980 |
recorderStream notNil ifTrue:[ |
|
2981 |
recorderStream nextPutAll:aString |
|
2982 |
]. |
|
5008 | 2983 |
(Debug or:[DebugKeyboard]) ifTrue:[ |
4809 | 2984 |
Transcript showCR:'send <',aString,'>' |
2985 |
]. |
|
2986 |
inStream nextPutAll:aString |
|
4604 | 2987 |
]. |
2988 |
]. |
|
2989 |
||
2990 |
"Created: / 29-07-2013 / 18:18:24 / cg" |
|
2991 |
! |
|
2992 |
||
2993 |
sendCR:aString |
|
2994 |
"send aString followed by a return to the underlying program's stdinput" |
|
2995 |
||
2996 |
self send:aString. |
|
4983 | 2997 |
self sendLineEnd. |
4604 | 2998 |
! |
2999 |
||
3000 |
sendCharacter:aCharacter |
|
4809 | 3001 |
"send a single character to the underlying program's stdin" |
4604 | 3002 |
|
5008 | 3003 |
aCharacter codePoint > 16r7F ifTrue:[ |
3004 |
inputIsUTF8 ifTrue:[ |
|
3005 |
aCharacter utf8Encoded do:[:eachUTFChar| |
|
3006 |
(Debug or:[DebugKeyboard]) ifTrue:[ |
|
3007 |
self debugPrintCharacter:eachUTFChar as:'send utf'. |
|
3008 |
]. |
|
3009 |
recorderStream notNil ifTrue:[ |
|
3010 |
recorderStream nextPut:eachUTFChar |
|
3011 |
]. |
|
3012 |
inStream nextPut:eachUTFChar. |
|
4809 | 3013 |
]. |
5008 | 3014 |
^ self |
3015 |
]. |
|
3016 |
aCharacter bitsPerCharacter > 8 ifTrue:[ |
|
4809 | 3017 |
"/ ignore |
6078 | 3018 |
Transcript showCR:(self className,': invalid (non-8bit) character ignored'). |
5008 | 3019 |
^ self |
4809 | 3020 |
]. |
5008 | 3021 |
"/ send normal |
4604 | 3022 |
]. |
3023 |
||
3024 |
recorderStream notNil ifTrue:[ |
|
3025 |
recorderStream nextPut:aCharacter |
|
3026 |
]. |
|
5008 | 3027 |
(Debug or:[DebugKeyboard]) ifTrue:[ |
3028 |
self debugPrintCharacter:aCharacter as:'send'. |
|
4604 | 3029 |
]. |
3030 |
||
3031 |
inStream nextPut:aCharacter. |
|
3032 |
||
3033 |
"Created: / 29-07-2013 / 18:18:24 / cg" |
|
6078 | 3034 |
"Modified: / 28-06-2019 / 09:20:15 / Claus Gittinger" |
4604 | 3035 |
! |
3036 |
||
3037 |
sendLine:aString |
|
5008 | 3038 |
(Debug or:[DebugKeyboard]) ifTrue:[ |
4604 | 3039 |
'VT100: sendline: ' print. aString asByteArray hexPrintString printCR |
3040 |
]. |
|
3041 |
||
3042 |
self send:aString. |
|
3043 |
self sendLineEnd |
|
3044 |
! |
|
3045 |
||
3046 |
sendLineEnd |
|
4983 | 3047 |
inputTranslateCRToNL ifTrue:[ |
3048 |
self sendCharacter:(Character nl). |
|
4604 | 3049 |
] ifFalse:[ |
4983 | 3050 |
inputTranslateCRToCRNL ifTrue:[ |
3051 |
self send:(String crlf). |
|
3052 |
] ifFalse:[ |
|
3053 |
self sendCharacter:(Character return). |
|
3054 |
] |
|
3055 |
] |
|
3056 |
"/ OperatingSystem isMSDOSlike ifTrue:[ |
|
3057 |
"/ self send:String crlf. |
|
3058 |
"/ ] ifFalse:[ |
|
3059 |
"/ self send:String return. |
|
3060 |
"/ ]. |
|
4604 | 3061 |
! ! |
3062 |
||
914 | 3063 |
!TerminalView class methodsFor:'documentation'! |
3064 |
||
3065 |
version |
|
4799 | 3066 |
^ '$Header$' |
3758 | 3067 |
! |
3068 |
||
3069 |
version_CVS |
|
4799 | 3070 |
^ '$Header$' |
914 | 3071 |
! ! |
2205 | 3072 |
|
4164 | 3073 |
|
2205 | 3074 |
TerminalView initialize! |