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