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