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