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