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