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