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