author | Claus Gittinger <cg@exept.de> |
Sat, 10 May 2003 13:53:37 +0200 | |
changeset 2506 | f12c7c321131 |
parent 2501 | 832cbac295b8 |
child 2538 | 2ee2ed3bad39 |
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 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
12 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
13 |
|
1833 | 14 |
"{ Package: 'stx:libwidg2' }" |
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 |
|
21 |
filterStream localEcho translateNLToCRNL inputTranslateCRToNL |
|
22 |
autoWrapFlag' |
|
23 |
classVariableNames:'Debug' |
|
24 |
poolDictionaries:'' |
|
25 |
category:'Views-TerminalViews' |
|
914 | 26 |
! |
27 |
||
28 |
!TerminalView class methodsFor:'documentation'! |
|
29 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
30 |
copyright |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
31 |
" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
32 |
COPYRIGHT (c) 1998 by eXept Software AG |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
33 |
All Rights Reserved |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
34 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
hereby transferred. |
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 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
43 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
44 |
|
914 | 45 |
documentation |
46 |
" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
47 |
I provide terminal functionality, by interpreting data |
1418 | 48 |
arriving from some stream (typically connected to a command interpreter |
49 |
via a pty, or another system via a modem) |
|
50 |
and sending my keyboard data to it. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
51 |
|
1418 | 52 |
I am abstract providing general functionality |
53 |
- concrete terminal characteristics are defined by concrete subclasses |
|
54 |
(see VT52TerminalView, VT100TerminalView). |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
55 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
56 |
Concrete applications are: |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
57 |
consoles (VT100TerminalView), |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
58 |
telnet-views (see TelnetTool) |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
59 |
editor wrappers (if you like emacs/vi) |
914 | 60 |
|
1418 | 61 |
<<although my class protocol includes common startup protocol |
62 |
(to open a terminalView with a shell or on the output of a command), |
|
63 |
I can be used as a widget within an application (Modem software). |
|
64 |
||
914 | 65 |
[author:] |
66 |
Claus Gittinger |
|
915 | 67 |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
68 |
[instance variables:] |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
69 |
inStream stream where keyboard input is |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
70 |
sent to (connected to shells or commands input) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
71 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
72 |
outStream stream where the output of the |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
73 |
shell or command arrives |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
74 |
(read here and displayed in the view) |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
75 |
|
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
76 |
readerProcess process which reads commands |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
77 |
output and sends it to the view |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
78 |
|
2204 | 79 |
[class variables]: |
80 |
Debug := true trace incoming characters |
|
81 |
||
82 |
||
915 | 83 |
[start with:] |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
84 |
VT52TerminalView open |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
85 |
VT100TerminalView open |
915 | 86 |
VT52TerminalView openShell |
919 | 87 |
VT100TerminalView openShell |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
88 |
VT100TerminalView openOnCommand:'ls -l' |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
89 |
VT100TerminalView openOnCommand:'dir' |
1418 | 90 |
|
91 |
[see also:] |
|
92 |
TelNetTool |
|
914 | 93 |
" |
94 |
! ! |
|
95 |
||
2207 | 96 |
!TerminalView class methodsFor:'initialization'! |
2205 | 97 |
|
98 |
initialize |
|
2207 | 99 |
|
2205 | 100 |
Debug := false. |
2207 | 101 |
|
102 |
" |
|
103 |
self initialize |
|
104 |
" |
|
2205 | 105 |
! ! |
106 |
||
1052 | 107 |
!TerminalView class methodsFor:'defaults'! |
108 |
||
109 |
defaultIcon |
|
110 |
^ Image fromFile:'bitmaps/xpmBitmaps/terminal_images/xterm-icon.xpm' |
|
111 |
||
112 |
"Created: / 4.8.1998 / 17:48:18 / cg" |
|
113 |
"Modified: / 4.8.1998 / 17:48:31 / cg" |
|
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
114 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
115 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
116 |
defaultNumberOfColumns |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
117 |
^ 80 |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
118 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
119 |
"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
|
120 |
"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
|
121 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
122 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
123 |
defaultNumberOfLines |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
124 |
^ 25 |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
125 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
126 |
"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
|
127 |
"Modified: / 4.8.1998 / 17:48:31 / cg" |
1052 | 128 |
! ! |
129 |
||
972 | 130 |
!TerminalView class methodsFor:'opening'! |
914 | 131 |
|
928 | 132 |
open |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
133 |
^ self openShell |
928 | 134 |
|
135 |
" |
|
136 |
VT100TerminalView open |
|
137 |
" |
|
138 |
||
139 |
"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
|
140 |
"Modified: / 9.7.1998 / 17:55:37 / cg" |
928 | 141 |
! |
142 |
||
914 | 143 |
openDummy |
972 | 144 |
"for testing purposes only - opens a dummy tty-view, which simply |
145 |
echoes whatever is typed in" |
|
146 |
||
914 | 147 |
|in vt52| |
148 |
||
149 |
vt52 := self new. |
|
150 |
in := ForwardingStream on:''. |
|
151 |
||
152 |
in fwdStream:vt52. |
|
153 |
vt52 inStream:in. |
|
154 |
vt52 outStream:in. |
|
155 |
vt52 open |
|
156 |
||
157 |
" |
|
158 |
self openDummy |
|
159 |
" |
|
160 |
! |
|
161 |
||
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
162 |
openOnCommand:aCommandString |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
163 |
"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
|
164 |
(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
|
165 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
166 |
^ self openOnCommand:aCommandString onExit:[] |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
167 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
168 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
169 |
VT100TerminalView openOnCommand:'ls -l' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
170 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
171 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
172 |
"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
|
173 |
"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
|
174 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
175 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
176 |
openOnCommand:aCommandString onExit:aBlock |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
177 |
"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
|
178 |
(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
|
179 |
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
|
180 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
181 |
|in top scr vt52| |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
182 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
183 |
top := StandardSystemView new. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
184 |
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
|
185 |
scr origin:0.0@0.0 corner:1.0@1.0. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
186 |
vt52 := scr scrolledView. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
187 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
188 |
vt52 startCommand:aCommandString. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
189 |
vt52 shellTerminateAction:[ |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
190 |
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
|
191 |
]. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
192 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
193 |
top extent:(scr preferredExtent). |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
194 |
top label:('executing: "' , aCommandString , '"'). |
1014 | 195 |
top iconLabel:'command'. |
1052 | 196 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
197 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
198 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
199 |
^ vt52 |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
200 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
201 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
202 |
VT100TerminalView openOnCommand:'ls -lR' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
203 |
VT100TerminalView openOnCommand:'vi /etc/hosts' |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
204 |
" |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
205 |
|
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
206 |
"Created: / 9.7.1998 / 17:54:34 / cg" |
1052 | 207 |
"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
|
208 |
! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
209 |
|
1014 | 210 |
openOnInput:inStream output:outStream |
972 | 211 |
"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
|
212 |
kind of socket or pty). |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
213 |
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
|
214 |
from outStream is displayed in the terminal view. |
972 | 215 |
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
|
216 |
or telnet views (if connected to a modem, a com-program can also be |
972 | 217 |
implemented this way)." |
218 |
||
2078 | 219 |
|top scr| |
972 | 220 |
|
221 |
top := StandardSystemView new. |
|
2078 | 222 |
scr := self openOnInput:inStream output:outStream in:top. |
223 |
||
224 |
top extent:(scr preferredExtent). |
|
225 |
top label:'shell'. |
|
226 |
top iconLabel:'shell'. |
|
227 |
top icon:(self defaultIcon). |
|
228 |
top open. |
|
229 |
^ top |
|
230 |
||
231 |
"Modified: / 5.5.1999 / 17:25:59 / cg" |
|
232 |
! |
|
233 |
||
234 |
openOnInput:inStream output:outStream in:aView |
|
235 |
"open a terminalView on the given streams (which are typically some |
|
236 |
kind of socket or pty). |
|
237 |
Keys pressed are sent to inStream, text appearing |
|
238 |
from outStream is displayed in the terminal view. |
|
239 |
This can be used to implement things like rlogin |
|
240 |
or telnet views (if connected to a modem, a com-program can also be |
|
241 |
implemented this way)." |
|
242 |
||
243 |
|scr vt| |
|
244 |
||
245 |
scr := ScrollableView for:self in:aView. |
|
972 | 246 |
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
|
247 |
vt := scr scrolledView. |
972 | 248 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
249 |
vt inStream:inStream. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
250 |
vt outStream:outStream. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
251 |
vt startReaderProcess. |
972 | 252 |
|
2078 | 253 |
^ scr |
974 | 254 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
255 |
"Modified: / 5.5.1999 / 17:25:59 / cg" |
972 | 256 |
! |
257 |
||
914 | 258 |
openShell |
972 | 259 |
"start a shell on a pseudo-TTY, open a terminalView on it |
260 |
(i.e. this is kind of an xterm)" |
|
261 |
||
997 | 262 |
^ self openShellIn:nil |
992 | 263 |
|
264 |
" |
|
265 |
VT100TerminalView openShell |
|
266 |
" |
|
267 |
||
997 | 268 |
"Modified: / 21.7.1998 / 18:24:55 / cg" |
992 | 269 |
! |
270 |
||
271 |
openShellIn:aDirectory |
|
272 |
"start a shell on a pseudo-TTY, open a terminalView on it |
|
273 |
(i.e. this is kind of an xterm)" |
|
274 |
||
2163 | 275 |
| top scr vt lbl| |
914 | 276 |
|
277 |
top := StandardSystemView new. |
|
948 | 278 |
scr := ScrollableView for:self in:top. |
914 | 279 |
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
|
280 |
vt := scr scrolledView. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
281 |
vt startShellIn:aDirectory. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
282 |
vt shellTerminateAction:[top destroy]. |
914 | 283 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
284 |
lbl := OperatingSystem isUNIXlike ifTrue:['shell'] ifFalse:['dos']. |
940 | 285 |
top extent:(scr preferredExtent). |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
286 |
top label:lbl. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
287 |
top iconLabel:lbl. |
1052 | 288 |
top icon:(self defaultIcon). |
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
289 |
top open. |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
290 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
291 |
^ vt |
914 | 292 |
|
293 |
" |
|
992 | 294 |
VT100TerminalView openShellIn:'/etc' |
914 | 295 |
" |
946 | 296 |
|
992 | 297 |
"Created: / 20.7.1998 / 18:28:15 / cg" |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
298 |
"Modified: / 5.5.1999 / 17:27:10 / cg" |
914 | 299 |
! ! |
300 |
||
972 | 301 |
!TerminalView class methodsFor:'queries'! |
302 |
||
303 |
isVisualStartable |
|
304 |
"returns whether this application class can be started via #open" |
|
305 |
||
306 |
self == TerminalView ifTrue:[^ false]. |
|
307 |
^ true |
|
308 |
||
309 |
"Created: / 10.6.1998 / 15:48:43 / cg" |
|
310 |
! ! |
|
311 |
||
914 | 312 |
!TerminalView methodsFor:'accessing'! |
313 |
||
2076 | 314 |
filterStream:something |
315 |
"set a filter stream; if not nil, it gets all incoming data via nextPutAll:. |
|
316 |
(added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt |
|
317 |
incoming data by some other program)" |
|
318 |
||
319 |
filterStream := something. |
|
320 |
||
321 |
"Created: / 28.1.2002 / 20:56:04 / micha" |
|
322 |
"Modified: / 28.1.2002 / 20:56:11 / micha" |
|
323 |
! |
|
324 |
||
914 | 325 |
inStream |
326 |
"return the value of the instance variable 'inStream' (automatically generated)" |
|
327 |
||
2075 | 328 |
^ inStream |
329 |
! |
|
914 | 330 |
|
331 |
inStream:something |
|
332 |
"set the value of the instance variable 'inStream' (automatically generated)" |
|
333 |
||
2075 | 334 |
inStream := something. |
335 |
! |
|
914 | 336 |
|
2078 | 337 |
inputTranslateCRToNL |
338 |
^ inputTranslateCRToNL |
|
339 |
! |
|
340 |
||
341 |
inputTranslateCRToNL:something |
|
342 |
inputTranslateCRToNL := something. |
|
343 |
! |
|
344 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
345 |
localEcho:aBoolean |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
346 |
"enable/disable local echo" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
347 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
348 |
localEcho := aBoolean |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
349 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
350 |
"Created: / 5.5.1999 / 17:53:16 / cg" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
351 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
352 |
|
914 | 353 |
outStream |
354 |
"return the value of the instance variable 'outStream' (automatically generated)" |
|
355 |
||
2075 | 356 |
^ outStream |
357 |
! |
|
914 | 358 |
|
359 |
outStream:something |
|
360 |
"set the value of the instance variable 'outStream' (automatically generated)" |
|
361 |
||
2075 | 362 |
outStream := something. |
363 |
! |
|
946 | 364 |
|
1004 | 365 |
readerProcess |
366 |
"return the value of the instance variable 'readerProcess' (automatically generated)" |
|
367 |
||
368 |
^ readerProcess |
|
369 |
! |
|
370 |
||
946 | 371 |
shellTerminateAction:aBlock |
372 |
"set the block which is evaluated when the shell terminates. |
|
373 |
Can be used to close down the application in this case." |
|
374 |
||
375 |
shellTerminateAction := aBlock. |
|
376 |
||
377 |
"Created: / 12.6.1998 / 17:02:58 / cg" |
|
2076 | 378 |
! |
379 |
||
380 |
translateNLToCRNL |
|
381 |
"return the value of the instance variable 'translateNLToCRNL' (automatically generated)" |
|
382 |
||
383 |
^ translateNLToCRNL |
|
384 |
||
385 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
386 |
! |
|
387 |
||
388 |
translateNLToCRNL:something |
|
389 |
"set the value of the instance variable 'translateNLToCRNL' (automatically generated)" |
|
390 |
||
391 |
translateNLToCRNL := something. |
|
392 |
||
393 |
"Created: / 28.1.2002 / 20:32:10 / micha" |
|
946 | 394 |
! ! |
914 | 395 |
|
396 |
!TerminalView methodsFor:'cursor handling'! |
|
397 |
||
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
398 |
cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
399 |
cursorLine + n > list size ifTrue:[ |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
400 |
list := list , (Array new:n). |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
401 |
self textChanged. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
402 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
403 |
super cursorDown:n |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
404 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
405 |
"Modified: / 10.6.1998 / 17:18:41 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
406 |
"Created: / 10.6.1998 / 17:18:50 / cg" |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
407 |
! |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
408 |
|
968
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
409 |
cursorMovementAllowed |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
410 |
"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
|
411 |
(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
|
412 |
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
|
413 |
cursor positioning escape sequences arriving from the |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
414 |
stream." |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
415 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
416 |
^ false |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
417 |
|
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
418 |
"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
|
419 |
! |
1cb313e6635b
do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents:
964
diff
changeset
|
420 |
|
2169 | 421 |
numberOfTerminalCols |
422 |
^ numberOfColumns |
|
423 |
! |
|
424 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
425 |
numberOfTerminalColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
426 |
^ numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
427 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
428 |
"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
|
429 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
430 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
431 |
numberOfTerminalLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
432 |
"/ 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
|
433 |
"/ 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
|
434 |
"/ in ListView ... |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
435 |
"/ ... 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
|
436 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
437 |
^ numberOfLines |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
438 |
|
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
439 |
"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
|
440 |
"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
|
441 |
! |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
442 |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
443 |
restoreCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
444 |
|l c| |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
445 |
|
2192 | 446 |
savedCursor isNil ifTrue:[ |
447 |
l := c := 1. |
|
448 |
] ifFalse:[ |
|
449 |
l := savedCursor y. |
|
450 |
c := savedCursor x. |
|
451 |
]. |
|
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
452 |
self cursorLine:l col:c. |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
453 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
454 |
"Created: / 14.8.1998 / 13:49:24 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
455 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
456 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
457 |
saveCursor |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
458 |
savedCursor := cursorCol @ cursorLine |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
459 |
|
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
460 |
"Created: / 14.8.1998 / 13:48:45 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
461 |
"Modified: / 14.8.1998 / 13:49:32 / cg" |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
462 |
! |
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
463 |
|
914 | 464 |
validateCursorCol:col inLine:line |
465 |
"check of col is a valid cursor position; return a new col-nr if not. |
|
466 |
Here, the linelength is enforced" |
|
467 |
||
2268 | 468 |
col > numberOfColumns ifTrue:[ |
469 |
autoWrapFlag ifTrue:[ |
|
470 |
self endEntry. |
|
471 |
self cursorLine:(self cursorLine + 1) col:(col-numberOfColumns). |
|
472 |
^ 1. |
|
473 |
]. |
|
474 |
]. |
|
926 | 475 |
^ col min:numberOfColumns |
914 | 476 |
|
926 | 477 |
"Modified: / 10.6.1998 / 15:09:41 / cg" |
914 | 478 |
! ! |
479 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
480 |
!TerminalView methodsFor:'defaults'! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
481 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
482 |
anyKeyCodes |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
483 |
^ IdentityDictionary withKeysAndValues: |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
484 |
#( |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
485 |
#Escape '\e' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
486 |
#BackSpace '\b' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
487 |
#Return '\r' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
488 |
#Delete '\0177' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
489 |
#Tab '\t' |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
490 |
) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
491 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
492 |
"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
|
493 |
! ! |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
494 |
|
914 | 495 |
!TerminalView methodsFor:'event handling'! |
496 |
||
951 | 497 |
computeNumberOfLinesShown |
498 |
|prevNLines prevNCols| |
|
499 |
||
500 |
prevNCols := (innerWidth // font width). |
|
501 |
prevNLines := nFullLinesShown. |
|
502 |
||
503 |
super computeNumberOfLinesShown. |
|
504 |
||
505 |
((innerWidth // font width) ~~ prevNCols |
|
506 |
or:[prevNLines ~~ nFullLinesShown]) ifTrue:[ |
|
507 |
self defineWindowSize. |
|
508 |
] |
|
509 |
||
510 |
"Created: / 12.6.1998 / 22:34:39 / cg" |
|
979 | 511 |
"Modified: / 20.6.1998 / 19:45:28 / cg" |
951 | 512 |
! |
513 |
||
1359 | 514 |
contentsChanged |
515 |
super contentsChanged. |
|
516 |
self defineWindowSize. |
|
517 |
||
518 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
|
519 |
"Created: / 5.5.1999 / 16:30:15 / cg" |
|
520 |
! |
|
521 |
||
943 | 522 |
defineWindowSize |
2192 | 523 |
| delta prevNumCols prevNumLines| |
1359 | 524 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
525 |
"/self halt. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
526 |
"/self realized ifFalse:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
527 |
"/ "/ iconfified |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
528 |
"/ ^ self |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
529 |
"/]. |
1359 | 530 |
prevNumCols := numberOfColumns. |
531 |
prevNumLines := numberOfLines. |
|
1161 | 532 |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
533 |
numberOfColumns := (innerWidth // font width). |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
534 |
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
|
535 |
numberOfLines := nFullLinesShown. |
1359 | 536 |
|
537 |
((prevNumCols == numberOfColumns) |
|
538 |
and:[prevNumLines == numberOfLines]) ifTrue:[ |
|
539 |
^ self |
|
540 |
]. |
|
541 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
542 |
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
|
543 |
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
|
544 |
]. |
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
545 |
|
1359 | 546 |
"/ any idea, how to do this under windows ? |
547 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
548 |
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
|
549 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
550 |
"/ 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
|
551 |
"/ 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
|
552 |
"/ |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
553 |
(inStream notNil |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
554 |
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
|
555 |
and:[inStream isOpen]]) ifTrue:[ |
2192 | 556 |
Debug ifTrue:[ |
557 |
Transcript showCR:'VT100: changed len to ', numberOfLines printString. |
|
558 |
]. |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
559 |
(OperatingSystem |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
560 |
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
|
561 |
width:numberOfColumns |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
562 |
height:numberOfLines) ifFalse:[ |
2192 | 563 |
Debug ifTrue:[ |
564 |
Transcript showCR:'VT100: cannot change windowSize'. |
|
565 |
]. |
|
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
566 |
]. |
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
567 |
|
964
43d6e33a4240
keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents:
958
diff
changeset
|
568 |
]. |
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
569 |
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
|
570 |
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
|
571 |
] |
943 | 572 |
]. |
573 |
||
574 |
"Created: / 11.6.1998 / 22:51:39 / cg" |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
575 |
"Modified: / 5.5.1999 / 19:45:09 / cg" |
943 | 576 |
! |
577 |
||
914 | 578 |
keyPress:aKey x:x y:y |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
579 |
|rest event rawKey seq| |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
580 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
581 |
"/ somewhat complicated, since some characters |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
582 |
"/ should go untranslated (CTRL-key), |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
583 |
"/ even if defined as function keys. |
914 | 584 |
|
585 |
inStream isNil ifTrue:[^ self]. |
|
586 |
||
2192 | 587 |
Debug ifTrue:[ |
588 |
Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString. |
|
589 |
]. |
|
914 | 590 |
|
591 |
aKey isCharacter ifTrue:[ |
|
2466 | 592 |
self deselect. |
593 |
||
914 | 594 |
"/ send it down to inStream ... |
595 |
inStream nextPut:aKey. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
596 |
localEcho ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
597 |
self nextPut:aKey |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
598 |
]. |
914 | 599 |
^ self |
600 |
]. |
|
601 |
||
1366 | 602 |
(#(Control Control_L Control_R |
603 |
Shift Shift_L Shift_R |
|
604 |
Alt Alt_L Alt_R |
|
605 |
Cmd Cmd_L Cmd_R |
|
606 |
Meta Meta_L Meta_R) includes:aKey) ifTrue:[ |
|
607 |
^ self |
|
608 |
]. |
|
609 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
610 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
611 |
"/ 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
|
612 |
"/ |
2078 | 613 |
(aKey == #Return |
614 |
and:[inputTranslateCRToNL]) ifTrue:[ |
|
615 |
seq := '\n'. |
|
616 |
] ifFalse:[ |
|
617 |
seq := kbdSequences at:aKey ifAbsent:nil. |
|
618 |
]. |
|
914 | 619 |
seq notNil ifTrue:[ |
2192 | 620 |
Debug ifTrue:[ |
621 |
Transcript show:'->' ; showCR:seq storeString. |
|
622 |
]. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
623 |
seq := seq withEscapes. |
2078 | 624 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
625 |
inStream nextPutAll:seq. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
626 |
localEcho ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
627 |
self nextPutAll:seq |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
628 |
]. |
914 | 629 |
^ self |
630 |
]. |
|
631 |
||
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
632 |
self sensor ctrlDown ifTrue:[ |
1366 | 633 |
(aKey startsWith:'Ctrl') ifTrue:[ |
634 |
rawKey := aKey |
|
635 |
] ifFalse:[ |
|
636 |
"/ already translated - undo it. |
|
637 |
||
638 |
event := WindowGroup lastEventQuerySignal query. |
|
639 |
rawKey := event rawKey. |
|
640 |
rawKey isCharacter ifTrue:[ |
|
641 |
rawKey := 'Ctrl' , rawKey. |
|
642 |
] |
|
1360 | 643 |
] |
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
644 |
] ifFalse:[ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
645 |
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
|
646 |
]. |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
647 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
648 |
"/ |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
649 |
"/ 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
|
650 |
"/ |
2192 | 651 |
Debug ifTrue:[ |
652 |
Transcript show:'raw ->' ; showCR:rawKey storeString. |
|
653 |
]. |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
654 |
|
914 | 655 |
seq := kbdSequences at:rawKey ifAbsent:nil. |
656 |
seq notNil ifTrue:[ |
|
2192 | 657 |
Debug ifTrue:[ |
658 |
Transcript show:'->' ; showCR:seq storeString. |
|
659 |
]. |
|
914 | 660 |
inStream nextPutAll:(seq withEscapes). |
661 |
^ self |
|
662 |
]. |
|
663 |
||
664 |
(rawKey startsWith:'Ctrl') ifTrue:[ |
|
665 |
rest := rawKey copyFrom:5. |
|
666 |
rest size == 1 ifTrue:[ |
|
667 |
rest := rest at:1. |
|
668 |
(rest >= $a and:[rest <= $z]) ifTrue:[ |
|
2192 | 669 |
Debug ifTrue:[ |
670 |
Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
|
671 |
]. |
|
914 | 672 |
inStream nextPut:(Character value:(rest - $a + 1)). |
673 |
^ self |
|
674 |
]. |
|
675 |
(rest >= $A and:[rest <= $Z]) ifTrue:[ |
|
2192 | 676 |
Debug ifTrue:[ |
677 |
Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString. |
|
678 |
]. |
|
914 | 679 |
inStream nextPut:(Character value:(rest - $A + 1)). |
680 |
^ self |
|
681 |
]. |
|
682 |
] |
|
683 |
]. |
|
684 |
||
934 | 685 |
(rawKey startsWith:'Control') ifTrue:[ |
686 |
^ self |
|
687 |
]. |
|
688 |
(rawKey startsWith:'Shift') ifTrue:[ |
|
689 |
^ self |
|
690 |
]. |
|
691 |
(rawKey startsWith:'Alt') ifTrue:[ |
|
692 |
^ self |
|
693 |
]. |
|
694 |
(rawKey startsWith:'Cmd') ifTrue:[ |
|
950 | 695 |
^ super keyPress:aKey x:x y:y |
934 | 696 |
]. |
1345 | 697 |
(rawKey = 'Ctrl') ifTrue:[ |
698 |
^ self |
|
699 |
]. |
|
934 | 700 |
|
2192 | 701 |
Debug ifTrue:[ |
702 |
Transcript show:'unhandled key: '; showCR:rawKey. |
|
703 |
]. |
|
914 | 704 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
705 |
"Modified: / 5.5.1999 / 18:32:42 / cg" |
914 | 706 |
! |
707 |
||
708 |
shellTerminated |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
709 |
"shell has terminated" |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
710 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
711 |
"/Delay waitForSeconds:10. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
712 |
[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
|
713 |
"/ |
914 | 714 |
self closeDownShell. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
715 |
|
946 | 716 |
shellTerminateAction notNil ifTrue:[ |
717 |
shellTerminateAction value |
|
718 |
] ifFalse:[ |
|
719 |
"/ may be removed ... |
|
720 |
self warn:'shell terminated'. |
|
721 |
] |
|
722 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
723 |
"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
|
724 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
725 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
726 |
sizeChanged:how |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
727 |
super sizeChanged:how. |
943 | 728 |
self defineWindowSize. |
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
729 |
|
943 | 730 |
"Modified: / 11.6.1998 / 22:51:48 / cg" |
914 | 731 |
! ! |
732 |
||
733 |
!TerminalView methodsFor:'functions'! |
|
734 |
||
735 |
doBackspace |
|
736 |
self cursorLeft. |
|
737 |
self replaceCharAtCursor:(Character space). |
|
738 |
self cursorLeft. |
|
739 |
||
931 | 740 |
"Modified: / 10.6.1998 / 17:09:12 / cg" |
914 | 741 |
! |
742 |
||
926 | 743 |
doClearDisplay |
1420 | 744 |
"clear everything" |
745 |
||
1000 | 746 |
self doClearEntireScreen. |
747 |
||
748 |
"Modified: / 21.7.1998 / 20:05:35 / cg" |
|
749 |
! |
|
750 |
||
1420 | 751 |
doClearEntireLine |
752 |
"clear the cursor line. cursor position remains unchanged" |
|
753 |
||
754 |
self at:cursorLine put:'' |
|
755 |
! |
|
756 |
||
1000 | 757 |
doClearEntireScreen |
1420 | 758 |
"clear everything" |
759 |
||
926 | 760 |
firstLineShown to:(list size) do:[:l | |
761 |
self at:l put:'' |
|
762 |
]. |
|
922 | 763 |
|
1000 | 764 |
"Modified: / 21.7.1998 / 20:00:19 / cg" |
765 |
"Created: / 21.7.1998 / 20:05:24 / cg" |
|
926 | 766 |
! |
767 |
||
1000 | 768 |
doClearFromBeginningOfLine |
1420 | 769 |
"clear from beginning of line to the cursorPosition" |
770 |
||
1000 | 771 |
|l| |
772 |
||
773 |
l := self listAt:cursorLine. |
|
774 |
l notNil ifTrue:[ |
|
775 |
(l size >= (cursorCol-1)) ifTrue:[ |
|
776 |
l := l copy from:1 to:cursorCol-1 put:(Character space). |
|
777 |
] ifFalse:[ |
|
778 |
l := nil. |
|
779 |
]. |
|
780 |
self withoutRedrawAt:cursorLine put:l. |
|
781 |
self invalidateLine:cursorLine |
|
782 |
"/ self at:cursorLine put:l. |
|
783 |
] |
|
784 |
||
785 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
|
786 |
"Created: / 21.7.1998 / 20:10:58 / cg" |
|
787 |
! |
|
788 |
||
789 |
doClearFromBeginningOfScreen |
|
1420 | 790 |
"clear from beginning of the screen to the cursorPosition" |
791 |
||
1000 | 792 |
self doClearFromBeginningOfLine. |
793 |
cursorLine-1 to:firstLineShown do:[:l | |
|
922 | 794 |
self at:l put:'' |
795 |
]. |
|
796 |
||
926 | 797 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
1000 | 798 |
"Created: / 21.7.1998 / 20:08:29 / cg" |
926 | 799 |
! |
800 |
||
801 |
doClearToEndOfLine |
|
1420 | 802 |
"clear from the cursorPosition to the end of the line" |
803 |
||
926 | 804 |
|l| |
805 |
||
806 |
l := self listAt:cursorLine. |
|
931 | 807 |
(l size >= (cursorCol-1)) ifTrue:[ |
951 | 808 |
l notNil ifTrue:[ |
809 |
l := l copyTo:cursorCol-1. |
|
979 | 810 |
self withoutRedrawAt:cursorLine put:l. |
811 |
self invalidateLine:cursorLine |
|
812 |
"/ self at:cursorLine put:l. |
|
951 | 813 |
] |
926 | 814 |
] |
815 |
||
816 |
"Created: / 10.6.1998 / 14:45:01 / cg" |
|
979 | 817 |
"Modified: / 20.6.1998 / 19:10:21 / cg" |
914 | 818 |
! |
819 |
||
1000 | 820 |
doClearToEndOfScreen |
1420 | 821 |
"clear from the cursorPosition to the end of the screen" |
822 |
||
1000 | 823 |
self doClearToEndOfLine. |
824 |
cursorLine+1 to:(list size) do:[:l | |
|
825 |
self at:l put:'' |
|
826 |
]. |
|
827 |
||
828 |
"Modified: / 10.6.1998 / 14:45:43 / cg" |
|
829 |
"Created: / 21.7.1998 / 20:06:14 / cg" |
|
830 |
! |
|
831 |
||
926 | 832 |
doCursorDown:n |
1420 | 833 |
"move the cursor down by n lines" |
834 |
||
979 | 835 |
|wasOn rEnd| |
926 | 836 |
|
979 | 837 |
"/ rangeEndLine == numberOfLines ifTrue:[ |
838 |
"/ ^ super cursorDown:n |
|
839 |
"/ ]. |
|
840 |
cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[ |
|
951 | 841 |
"/ no special action req'd |
842 |
^ super cursorDown:n |
|
843 |
]. |
|
979 | 844 |
|
951 | 845 |
n timesRepeat:[ |
846 |
wasOn := self hideCursor. |
|
979 | 847 |
rEnd := rangeEndLine+firstLineShown-1. |
848 |
cursorLine == rEnd ifTrue:[ |
|
849 |
self deleteLine:(rangeStartLine+firstLineShown-1). |
|
850 |
self insertLine:'' before:rEnd. |
|
951 | 851 |
] ifFalse:[ |
852 |
super cursorDown |
|
853 |
]. |
|
979 | 854 |
wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn. |
951 | 855 |
] |
856 |
||
979 | 857 |
"Modified: / 20.6.1998 / 20:29:39 / cg" |
926 | 858 |
! |
859 |
||
914 | 860 |
doCursorHome |
1420 | 861 |
"move the cursor to the home position" |
862 |
||
938 | 863 |
self cursorVisibleLine:1 col:1 |
864 |
"/ super cursorHome |
|
865 |
||
866 |
"Modified: / 10.6.1998 / 20:47:31 / cg" |
|
914 | 867 |
! |
868 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
869 |
doCursorLeft:n |
1420 | 870 |
"move the cursor to the left by n columns" |
871 |
||
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
872 |
n timesRepeat:[ |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
873 |
super cursorLeft |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
874 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
875 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
876 |
"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
|
877 |
! |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
878 |
|
914 | 879 |
doCursorNewLine |
1420 | 880 |
"move the cursor down to the next line (col remains unchanged)" |
881 |
||
931 | 882 |
super cursorDown:1 |
883 |
||
884 |
"Modified: / 10.6.1998 / 16:55:57 / cg" |
|
914 | 885 |
! |
886 |
||
887 |
doCursorReturn |
|
1420 | 888 |
"move the cursor down and left to the beginning to the next line" |
889 |
||
914 | 890 |
super cursorToBeginOfLine |
891 |
! |
|
892 |
||
926 | 893 |
doCursorRight:n |
1420 | 894 |
"move the cursor to the right by n columns" |
895 |
||
926 | 896 |
self cursorCol:(cursorCol + n) |
897 |
||
898 |
"Created: / 10.6.1998 / 15:10:08 / cg" |
|
899 |
! |
|
900 |
||
951 | 901 |
doCursorUp:n |
1420 | 902 |
"move the cursor up by n lines" |
903 |
||
979 | 904 |
|wasOn rStart| |
926 | 905 |
|
979 | 906 |
"/ rangeStartLine == 1 ifTrue:[ |
907 |
"/ ^ super cursorUp:n |
|
908 |
"/ ]. |
|
909 |
cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[ |
|
951 | 910 |
"/ no special action req'd |
911 |
^ super cursorUp:n |
|
912 |
]. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
913 |
n timesRepeat:[ |
951 | 914 |
wasOn := self hideCursor. |
979 | 915 |
rStart := rangeStartLine+firstLineShown-1. |
916 |
cursorLine == rStart ifTrue:[ |
|
917 |
(rangeEndLine+firstLineShown-1) <= list size ifTrue:[ |
|
918 |
self deleteLine:(rangeEndLine+firstLineShown-1). |
|
919 |
self insertLine:'' before:rStart. |
|
920 |
]. |
|
951 | 921 |
] ifFalse:[ |
922 |
super cursorUp |
|
923 |
]. |
|
924 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
942
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
925 |
] |
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
926 |
|
1f4fa3a6faec
send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents:
940
diff
changeset
|
927 |
"Created: / 11.6.1998 / 22:29:46 / cg" |
979 | 928 |
"Modified: / 20.6.1998 / 20:30:34 / cg" |
914 | 929 |
! ! |
930 |
||
2501 | 931 |
!TerminalView methodsFor:'initialization & release'! |
914 | 932 |
|
933 |
closeDownShell |
|
1420 | 934 |
"shut down my shell process and stop the background reader thread." |
935 |
||
1009 | 936 |
|pid| |
926 | 937 |
|
938 |
(pid := shellPid) notNil ifTrue:[ |
|
2192 | 939 |
Debug ifTrue:[ |
940 |
Transcript print:'killing shell pid='; showCR:pid. |
|
941 |
]. |
|
926 | 942 |
OperatingSystem terminateProcessGroup:pid. |
943 |
OperatingSystem terminateProcess:pid. |
|
925 | 944 |
Delay waitForSeconds:1. |
945 |
shellPid notNil ifTrue:[ |
|
1341
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
946 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
947 |
OperatingSystem killProcessGroup:pid. |
3467ffd6eb35
first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
948 |
]. |
926 | 949 |
OperatingSystem killProcess:pid. |
925 | 950 |
shellPid := nil. |
951 |
]. |
|
926 | 952 |
OperatingSystem closePid:pid. |
914 | 953 |
]. |
954 |
||
1009 | 955 |
self stopReaderProcess. |
956 |
||
914 | 957 |
inStream notNil ifTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
958 |
inStream isStream ifTrue:[inStream close]. |
914 | 959 |
inStream := nil |
960 |
]. |
|
961 |
outStream notNil ifTrue:[ |
|
962 |
outStream close. |
|
963 |
outStream := nil |
|
964 |
]. |
|
924 | 965 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
966 |
"Modified: / 5.5.1999 / 18:43:02 / cg" |
914 | 967 |
! |
968 |
||
969 |
escapeSequences:codes |
|
1420 | 970 |
"setup my escape sequences" |
971 |
||
914 | 972 |
|tree| |
973 |
||
974 |
tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new]. |
|
975 |
||
976 |
codes do:[:specEntry | |
|
977 |
|sequence function| |
|
978 |
||
979 |
sequence := (specEntry at:1) withEscapes. |
|
980 |
function := specEntry at:2. |
|
981 |
||
982 |
tree := escapeSequenceTree. |
|
983 |
||
984 |
sequence keysAndValuesDo:[:idx :char | |
|
985 |
|followup| |
|
986 |
||
987 |
idx == sequence size ifTrue:[ |
|
988 |
tree at:char put:function |
|
989 |
] ifFalse:[ |
|
990 |
followup := tree at:char ifAbsent:nil. |
|
991 |
followup isNil ifTrue:[ |
|
992 |
tree at:char put:(followup := IdentityDictionary new). |
|
993 |
]. |
|
994 |
tree := followup |
|
995 |
] |
|
996 |
] |
|
997 |
]. |
|
918 | 998 |
escapeLeadingChars := escapeSequenceTree keys asSet. |
999 |
escapeLeadingChars add:(Character cr). |
|
1000 |
escapeLeadingChars add:(Character return). |
|
1001 |
escapeLeadingChars add:(Character backspace). |
|
1002 |
||
1003 |
escapeLeadingChars := escapeLeadingChars asArray |
|
1004 |
||
1005 |
"Modified: / 9.6.1998 / 19:43:12 / cg" |
|
914 | 1006 |
! |
1007 |
||
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1008 |
flushInput |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1009 |
|sensor| |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1010 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1011 |
"/ flush any leftover input-processing events |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1012 |
(sensor := self sensor) notNil ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1013 |
sensor flushEventsFor:self withType:#processInput:n:. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1014 |
] |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1015 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1016 |
"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
|
1017 |
"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
|
1018 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1019 |
|
2163 | 1020 |
initStyle |
1021 |
super initStyle. |
|
1022 |
"/ self foregroundColor:Color green. |
|
1023 |
"/ self backgroundColor:Color black. |
|
1024 |
! |
|
1025 |
||
914 | 1026 |
initialize |
2194 | 1027 |
|
914 | 1028 |
super initialize. |
1029 |
||
1030 |
showMatchingParenthesis := false. |
|
1031 |
insertMode := false. |
|
936 | 1032 |
alwaysAppendAtEnd := false. |
944 | 1033 |
collectSize := 100. |
977 | 1034 |
st80Mode := false. |
1035 |
trimBlankLines := true. |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1036 |
localEcho := false. |
2078 | 1037 |
inputTranslateCRToNL := false. |
2268 | 1038 |
autoWrapFlag := true. |
1039 |
"/ cursorType := #block. |
|
914 | 1040 |
|
926 | 1041 |
numberOfColumns := 80. |
979 | 1042 |
numberOfLines := 24. |
954 | 1043 |
rangeStartLine := 1. |
1044 |
rangeEndLine := numberOfLines. |
|
926 | 1045 |
|
2423
d2685982f94f
tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents:
2356
diff
changeset
|
1046 |
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
|
1047 |
|
914 | 1048 |
self initializeKeyboardSequences. |
1049 |
list := OrderedCollection new:24 withAll:''. |
|
1050 |
||
1051 |
self initializeKeyboardMap. |
|
1052 |
||
1053 |
" |
|
1054 |
VT52TerminalView openShell |
|
926 | 1055 |
VT100TerminalView openShell |
914 | 1056 |
" |
926 | 1057 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1058 |
"Modified: / 5.5.1999 / 17:54:47 / cg" |
914 | 1059 |
! |
1060 |
||
1061 |
initializeKeyboardMap |
|
1349 | 1062 |
|keys ctrlKeys cmdKeys| |
914 | 1063 |
|
1349 | 1064 |
"/ setup my own keyboardMap, where control-keys |
1065 |
"/ (and some Cmd-keys) are not translated. |
|
914 | 1066 |
kbdMap := device keyboardMap copy. |
1349 | 1067 |
keys := kbdMap keys. |
914 | 1068 |
|
1349 | 1069 |
ctrlKeys := keys select:[:key | key startsWith:'Ctrl']. |
914 | 1070 |
ctrlKeys do:[:key | kbdMap removeKey:key]. |
950 | 1071 |
|
1349 | 1072 |
cmdKeys := keys select:[:key | key startsWith:'Cmd']. |
1073 |
cmdKeys do:[:key | |val| |
|
1074 |
val := kbdMap at:key. |
|
1075 |
val isSymbol ifTrue:[ |
|
2506 | 1076 |
(#(Copy Paste SaveAs Print Find FindNext FindPrev GotoLine) includes:val) ifFalse:[ |
1349 | 1077 |
kbdMap removeKey:key |
1078 |
] |
|
950 | 1079 |
] |
1080 |
]. |
|
914 | 1081 |
|
1082 |
kbdMap removeKey:#Delete ifAbsent:[]. |
|
1083 |
kbdMap removeKey:#BackSpace ifAbsent:[]. |
|
1084 |
||
1085 |
" |
|
1086 |
VT52TerminalView openShell |
|
1087 |
" |
|
950 | 1088 |
|
1349 | 1089 |
"Modified: / 29.4.1999 / 14:25:24 / cg" |
914 | 1090 |
! |
1091 |
||
1092 |
initializeKeyboardSequences |
|
1358
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1093 |
kbdSequences := (self anyKeyCodes) |
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1094 |
|
ec94a03e4585
Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1095 |
"Modified: / 5.5.1999 / 15:01:09 / cg" |
914 | 1096 |
! |
1097 |
||
1098 |
keyboardMap |
|
934 | 1099 |
"return my keyboard map. This has control keys removed and |
1100 |
those will be passed unchanged to the shell" |
|
1101 |
||
914 | 1102 |
^ kbdMap |
934 | 1103 |
|
1104 |
"Modified: / 10.6.1998 / 17:46:59 / cg" |
|
914 | 1105 |
! |
1106 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1107 |
reinitialize |
1833 | 1108 |
"reinit after a snapIn. |
1109 |
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
|
1110 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1111 |
super reinitialize. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1112 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1113 |
shellPid := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1114 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1115 |
self stopReaderProcess. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1116 |
self flushInput. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1117 |
|
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1118 |
readerProcess := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1119 |
inStream := outStream := nil. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1120 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1121 |
"/ 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
|
1122 |
[ |
1322 | 1123 |
"/ Delay waitForSeconds:0.5. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1124 |
self doClearEntireScreen. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1125 |
self cursorLine:1 col:1. |
1321
9a312fa98358
also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents:
1320
diff
changeset
|
1126 |
self contents:nil. |
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1127 |
self flash. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1128 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1129 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1130 |
"/ 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
|
1131 |
"/ |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1132 |
self startCommand:shellCommand in:shellDirectory. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1133 |
] forkAt:8 |
1363
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 |
"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
|
1136 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1137 |
|
2155 | 1138 |
release |
1139 |
"release myself - shut down the shell, stop the reader thread." |
|
1140 |
||
2341
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1141 |
[self closeDownShell. |
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1142 |
self flushInput. |
9b19cf22a099
release pipe in background (faster shutdown)
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1143 |
] fork. |
2155 | 1144 |
super release |
1145 |
||
1146 |
"Modified: / 5.5.1999 / 18:42:55 / cg" |
|
1147 |
! |
|
1148 |
||
914 | 1149 |
startReaderProcess |
934 | 1150 |
"Start a reader process, which looks for the commands output, |
1009 | 1151 |
and sends me #processInput:n: events whenever something arrives." |
934 | 1152 |
|
914 | 1153 |
readerProcess isNil ifTrue:[ |
1154 |
readerProcess := [ |
|
1155 |
[ |
|
947 | 1156 |
self waitUntilVisible. |
1157 |
||
940 | 1158 |
Stream streamErrorSignal handle:[:ex | |
2450
ac2ab4cbfb79
More descriptive error messages
Stefan Vogel <sv@exept.de>
parents:
2449
diff
changeset
|
1159 |
Transcript show:'Terminal(PTY-reader) [error]: '; showCR:ex errorString. |
940 | 1160 |
] do:[ |
926 | 1161 |
[true] whileTrue:[ |
1162 |
Object abortSignal handle:[:ex | |
|
1163 |
self showCursor. |
|
1164 |
] do:[ |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1165 |
|n sensor| |
948 | 1166 |
|
926 | 1167 |
outStream readWait. |
2126 | 1168 |
sensor := self sensor. |
1169 |
(sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[ |
|
1323 | 1170 |
true "(sensor userEventCount > 10)" ifTrue:[ |
997 | 1171 |
"/ give terminalView a chance to |
1172 |
"/ send out the character. |
|
1323 | 1173 |
Delay waitForSeconds:0.01. |
997 | 1174 |
] |
926 | 1175 |
] ifFalse:[ |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1176 |
n := self readAnyAvailableData. |
945 | 1177 |
n > 0 ifTrue:[ |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1178 |
shellPid notNil ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1179 |
self waitForOutputToDrain. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1180 |
] |
945 | 1181 |
] ifFalse:[ |
1182 |
n == 0 ifTrue:[ |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1183 |
"/ Windows IPC has a bug - it always |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1184 |
"/ returns 0 (when the command is idle) |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1185 |
"/ and says its at the end (sigh) |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1186 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1187 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1188 |
Delay waitForSeconds:0.01 |
1323 | 1189 |
] ifFalse:[ |
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1190 |
outStream atEnd ifTrue:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1191 |
outStream close. outStream := nil. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1192 |
inStream close. inStream := nil. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1193 |
Processor activeProcess terminate. |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1194 |
] ifFalse:[ |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1195 |
"/ this should not happen. |
1323 | 1196 |
|
1342
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1197 |
Delay waitForSeconds:0.05 |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1198 |
] |
271a9b90688a
somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
1199 |
]. |
926 | 1200 |
] |
1201 |
] |
|
914 | 1202 |
] |
1203 |
] |
|
1204 |
] |
|
1205 |
] |
|
1206 |
] valueOnUnwindDo:[ |
|
1207 |
readerProcess := nil |
|
1208 |
] |
|
997 | 1209 |
] fork. "/ forkAt:9. |
1210 |
readerProcess name:'pty reader'. |
|
914 | 1211 |
] |
1212 |
||
1213 |
" |
|
934 | 1214 |
VT100TerminalView openShell |
914 | 1215 |
" |
926 | 1216 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1217 |
"Modified: / 5.5.1999 / 17:58:02 / cg" |
2077 | 1218 |
"Modified: / 28.1.2002 / 21:10:13 / micha" |
1009 | 1219 |
! |
1220 |
||
1221 |
stopReaderProcess |
|
1420 | 1222 |
"stop the background reader thread" |
1223 |
||
1009 | 1224 |
|sensor| |
1225 |
||
1226 |
readerProcess notNil ifTrue:[ |
|
1227 |
readerProcess terminate. |
|
1228 |
"/ give it a chance to really terminate |
|
1229 |
Processor yield. |
|
1230 |
readerProcess := nil |
|
1231 |
]. |
|
1232 |
||
1233 |
"/ flush any leftover input-processing events |
|
1234 |
(sensor := self sensor) notNil ifTrue:[ |
|
1235 |
sensor flushEventsFor:self withType:#processInput:n:. |
|
1236 |
] |
|
1237 |
"Modified: / 21.7.1998 / 19:00:13 / cg" |
|
985
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
1238 |
! ! |
275897f12b52
added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents:
979
diff
changeset
|
1239 |
|
2501 | 1240 |
!TerminalView methodsFor:'initialization-shell'! |
1241 |
||
1242 |
startCommand:aCommand |
|
1243 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
1244 |
a shell is started. The command is started in the current directory. |
|
1245 |
Also fork a reader process, to read the shells output and |
|
1246 |
tell me, whenever something arrives" |
|
1247 |
||
1248 |
^ self startCommand:aCommand in:nil |
|
1249 |
||
1250 |
"Modified: / 20.7.1998 / 18:30:24 / cg" |
|
1251 |
! |
|
1252 |
||
1253 |
startCommand:aCommand in:aDirectory |
|
1254 |
"start a command on a pseudo terminal. If the command arg is nil, |
|
1255 |
a shell is started. If aDirectory is not nil, the command is |
|
1256 |
executed in that directory. |
|
1257 |
Also fork a reader process, to read the shells output and |
|
1258 |
tell me, whenever something arrives" |
|
1259 |
||
1260 |
|pty slaveFD execFdArray blocked exitStatus |
|
1261 |
stxToCommandPipe commandToStxPipe cmd shell args env shellAndArgs| |
|
1262 |
||
1263 |
shellCommand := aCommand. |
|
1264 |
shellDirectory := aDirectory. |
|
1265 |
||
1266 |
self create. "/ need my windowID (to pass down in environment) |
|
1267 |
||
1268 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1269 |
"use two pipes to COMMAND.COM" |
|
1270 |
stxToCommandPipe := ExternalStream makePipe. |
|
1271 |
stxToCommandPipe isNil ifTrue:[ |
|
1272 |
^ self warn:'Could not create pipe to COMMAND.COM.'. |
|
1273 |
]. |
|
1274 |
||
1275 |
commandToStxPipe := ExternalStream makePipe. |
|
1276 |
commandToStxPipe isNil ifTrue:[ |
|
1277 |
^ self warn:'Could not create pipe from COMMAND.COM.'. |
|
1278 |
]. |
|
1279 |
||
1280 |
"/ pipe readSide is p at:1; |
|
1281 |
"/ writeSide is p at:2 |
|
1282 |
||
1283 |
slaveFD := (commandToStxPipe at:2) fileDescriptor. |
|
1284 |
execFdArray := Array |
|
1285 |
with:(stxToCommandPipe at:1) fileDescriptor "stdin" |
|
1286 |
with:slaveFD "stdout" |
|
1287 |
with:slaveFD. "stderr" |
|
1288 |
||
1289 |
outStream := commandToStxPipe at:1. |
|
1290 |
inStream := stxToCommandPipe at:2. |
|
1291 |
outStream buffered:false. |
|
1292 |
inStream buffered:false. |
|
1293 |
||
1294 |
shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand. |
|
1295 |
shell := shellAndArgs at:1. |
|
1296 |
args := (shellAndArgs at:2) ? ''. |
|
1297 |
] ifFalse:[ |
|
1298 |
"Use a pseudo-tty" |
|
1299 |
pty := ExternalStream makePTYPair. |
|
1300 |
pty isNil ifTrue:[ |
|
1301 |
self warn:'Cannot open pty.'. |
|
1302 |
^ self. |
|
1303 |
]. |
|
1304 |
||
1305 |
"/ pty at:1 is the master; |
|
1306 |
"/ pty at:2 is the slave |
|
1307 |
inStream := outStream := (pty at:1). |
|
1308 |
inStream buffered:false. |
|
1309 |
||
1310 |
self defineWindowSize. |
|
1311 |
"/ fork a shell process on the slave-side |
|
1312 |
slaveFD := (pty at:2) fileDescriptor. |
|
1313 |
execFdArray := Array with:slaveFD with:slaveFD with:slaveFD. |
|
1314 |
||
1315 |
aCommand isNil ifTrue:[ |
|
1316 |
shell := OperatingSystem getEnvironment:'SHELL'. |
|
1317 |
shell size == 0 ifTrue:[ |
|
1318 |
shell := '/bin/sh'. |
|
1319 |
]. |
|
1320 |
cmd := shell asFilename baseName. |
|
1321 |
args := (Array with:cmd). |
|
1322 |
] ifFalse:[ |
|
1323 |
shell := '/bin/sh'. |
|
1324 |
args := (Array with:'sh' with:'-c' with:aCommand). |
|
1325 |
]. |
|
1326 |
env := Dictionary new. |
|
1327 |
env at:'SHELL' put:shell. |
|
1328 |
env at:'TERM' put:(self terminalType). |
|
1329 |
env at:'LINES' put:(numberOfLines printString). |
|
1330 |
env at:'COLUMNS' put:(numberOfColumns printString). |
|
1331 |
(device platformName = 'X11' and:[drawableId notNil]) ifTrue:[ |
|
1332 |
env at:'WINDOWID' put:(drawableId address printString). |
|
1333 |
]. |
|
1334 |
]. |
|
1335 |
||
1336 |
blocked := OperatingSystem blockInterrupts. |
|
1337 |
||
1338 |
shellPid := Processor |
|
1339 |
monitor:[ |
|
1340 |
OperatingSystem |
|
1341 |
exec:shell |
|
1342 |
withArguments:args |
|
1343 |
environment:env |
|
1344 |
fileDescriptors:execFdArray |
|
1345 |
fork:true |
|
1346 |
newPgrp:true |
|
1347 |
inDirectory:aDirectory. |
|
1348 |
] |
|
1349 |
action:[:status | |
|
1350 |
Debug ifTrue:[ |
|
1351 |
Transcript show:'pid:'; showCR:status pid. |
|
1352 |
Transcript show:'status:'; showCR:status status. |
|
1353 |
Transcript show:'code:'; showCR:status code. |
|
1354 |
Transcript show:'core:'; showCR:status core. |
|
1355 |
]. |
|
1356 |
status stillAlive ifFalse:[ |
|
1357 |
exitStatus := status. |
|
1358 |
OperatingSystem closePid:shellPid. |
|
1359 |
shellPid := nil. |
|
1360 |
self pushEvent:#shellTerminated |
|
1361 |
]. |
|
1362 |
]. |
|
1363 |
||
1364 |
blocked ifFalse:[ |
|
1365 |
OperatingSystem unblockInterrupts |
|
1366 |
]. |
|
1367 |
||
1368 |
"close the slave side of the pty/pipes (only used by the child)" |
|
1369 |
pty notNil ifTrue:[ |
|
1370 |
(pty at:2) close. |
|
1371 |
]. |
|
1372 |
||
1373 |
commandToStxPipe notNil ifTrue:[ |
|
1374 |
(commandToStxPipe at:2) close. |
|
1375 |
(stxToCommandPipe at:1) close. |
|
1376 |
]. |
|
1377 |
||
1378 |
shellPid isNil ifTrue:[ |
|
1379 |
self warn:'Cannot start shell'. |
|
1380 |
outStream close. |
|
1381 |
inStream close. |
|
1382 |
inStream := outStream := nil. |
|
1383 |
^ self. |
|
1384 |
]. |
|
1385 |
||
1386 |
self startReaderProcess. |
|
1387 |
||
1388 |
"Created: / 20.7.1998 / 18:19:32 / cg" |
|
1389 |
"Modified: / 5.5.1999 / 17:28:37 / cg" |
|
1390 |
! |
|
1391 |
||
1392 |
startShell |
|
1393 |
"start a shell on a pseudo terminal in the current directory. |
|
1394 |
Also fork a reader process, to read the shells output and |
|
1395 |
tell me, whenever something arrives" |
|
1396 |
||
1397 |
^ self startCommand:nil |
|
1398 |
||
1399 |
" |
|
1400 |
VT100TerminalView openShell |
|
1401 |
" |
|
1402 |
||
1403 |
"Modified: / 20.7.1998 / 18:29:54 / cg" |
|
1404 |
! |
|
1405 |
||
1406 |
startShellIn:aDirectory |
|
1407 |
"start a shell on a pseudo terminal in some directory. |
|
1408 |
Also fork a reader process, to read the shells output and |
|
1409 |
tell me, whenever something arrives" |
|
1410 |
||
1411 |
^ self startCommand:nil in:aDirectory |
|
1412 |
||
1413 |
" |
|
1414 |
VT100TerminalView openShellIn:'/etc' |
|
1415 |
" |
|
1416 |
||
1417 |
"Modified: / 20.7.1998 / 18:29:46 / cg" |
|
1418 |
! ! |
|
1419 |
||
914 | 1420 |
!TerminalView methodsFor:'menu'! |
1421 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1422 |
doReset |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1423 |
"reset the scroll-range; |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1424 |
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
|
1425 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1426 |
rangeStartLine := 1. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1427 |
rangeEndLine := numberOfLines. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1428 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1429 |
self normal. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1430 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1431 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1432 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1433 |
doSendInterrupt |
1420 | 1434 |
"send an INT-signal to the shell (UNIX only)" |
1435 |
||
1319
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1436 |
OperatingSystem sendSignal:(OperatingSystem sigINT) to:shellPid negated. |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1437 |
|
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1438 |
"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
|
1439 |
! |
0f19d022f577
restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents:
1317
diff
changeset
|
1440 |
|
914 | 1441 |
editMenu |
1442 |
"return the views middleButtonMenu" |
|
1443 |
||
1347 | 1444 |
<resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)> |
914 | 1445 |
<resource: #programMenu> |
1446 |
||
2075 | 1447 |
|items m sensor| |
914 | 1448 |
|
1449 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
|
1450 |
items := #( |
|
1451 |
('Interrupt' doSendInterrupt) |
|
1182 | 1452 |
('-' ) |
1453 |
('Reset' doReset) |
|
914 | 1454 |
). |
1455 |
] ifFalse:[ |
|
1456 |
items := #( |
|
2075 | 1457 |
('Copy' copySelection Copy ) |
1458 |
('Paste' pasteOrReplace Paste ) |
|
914 | 1459 |
('-' ) |
2506 | 1460 |
('Search...' search Find) |
1461 |
('Goto...' gotoLine GotoLine) |
|
1462 |
('-' ) |
|
2075 | 1463 |
('Font...' changeFont ) |
951 | 1464 |
('-' ) |
2448 | 1465 |
('Save As...' save SaveAs ) |
2075 | 1466 |
('Print' doPrint Print ) |
914 | 1467 |
). |
1347 | 1468 |
|
1469 |
"/ disabled - for now; |
|
1470 |
"/ need a more intelligent filtering of control characters. |
|
1471 |
"/ |
|
1472 |
"/ filterStream isNil ifTrue:[ |
|
1473 |
"/ items := items , #( |
|
1474 |
"/ ('-' ) |
|
2075 | 1475 |
"/ ('Start Save as ...' startSaveAs ) |
1476 |
"/ ('Start Print' startPrint ) |
|
1347 | 1477 |
"/ ) |
1478 |
"/ ] ifFalse:[ |
|
1479 |
"/ items := items , #( |
|
1480 |
"/ ('-' ) |
|
2075 | 1481 |
"/ ('Stop filter' stopFilter ) |
1347 | 1482 |
"/ ) |
1483 |
"/ ]. |
|
914 | 1484 |
]. |
1485 |
||
1486 |
m := PopUpMenu itemList:items resources:resources. |
|
1487 |
||
1488 |
self hasSelection not ifTrue:[ |
|
1489 |
m disable:#copySelection. |
|
1490 |
]. |
|
1491 |
^ m. |
|
1492 |
||
1347 | 1493 |
"Modified: / 29.4.1999 / 11:12:56 / cg" |
1494 |
! |
|
1495 |
||
1496 |
startSaveAs |
|
1497 |
"start saving all received data to some file" |
|
1498 |
||
1499 |
|fn| |
|
1500 |
||
1501 |
fn := Dialog requestFileName:'Save received data in file:'. |
|
1502 |
fn size > 0 ifTrue:[ |
|
1503 |
filterStream := fn asFilename writeStream |
|
1504 |
]. |
|
1505 |
||
1506 |
"Created: / 29.4.1999 / 11:06:29 / cg" |
|
1507 |
! |
|
1508 |
||
1509 |
stopFilter |
|
1510 |
"stop saving/printing of received data" |
|
1511 |
||
1512 |
filterStream close. |
|
1513 |
filterStream := nil. |
|
1514 |
||
1515 |
"Created: / 29.4.1999 / 11:07:49 / cg" |
|
1516 |
"Modified: / 29.4.1999 / 11:09:52 / cg" |
|
914 | 1517 |
! ! |
1518 |
||
940 | 1519 |
!TerminalView methodsFor:'misc'! |
914 | 1520 |
|
1521 |
removeTrailingBlankLines |
|
1522 |
^ self |
|
1523 |
! ! |
|
1524 |
||
2498 | 1525 |
!TerminalView methodsFor:'processing-input'! |
914 | 1526 |
|
1420 | 1527 |
doNothing |
1528 |
"private - end of an ignored escape-sequence" |
|
1529 |
||
1530 |
self endOfSequence |
|
1531 |
||
1532 |
"Created: / 12.6.1998 / 20:40:43 / cg" |
|
1533 |
! |
|
1534 |
||
1535 |
endOfSequence |
|
1536 |
"private - reset state-machine at end of escape-sequence" |
|
1537 |
||
1538 |
state := 0. |
|
1539 |
||
1540 |
"Created: / 12.6.1998 / 20:39:52 / cg" |
|
1541 |
! |
|
1542 |
||
1017
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1543 |
nextPutAll:aString |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1544 |
"/ self processInput:aString n:aString size |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1545 |
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
|
1546 |
|
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1547 |
"Created: / 27.7.1998 / 15:10:59 / cg" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1548 |
"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
|
1549 |
! |
8af14b2315fa
care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents:
1015
diff
changeset
|
1550 |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1551 |
processInput:buffer n:count |
997 | 1552 |
|sensor| |
1553 |
||
1347 | 1554 |
filterStream notNil ifTrue:[ |
1555 |
filterStream nextPutAll:(buffer copyTo:count). |
|
1556 |
]. |
|
1557 |
||
1077
49525bbae21c
added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents:
1055
diff
changeset
|
1558 |
"/ self hideCursor. |
997 | 1559 |
|
1015 | 1560 |
"/ the following may not be too clean, but adds a lot of speed. |
1561 |
"/ instead of passing every individual character through the |
|
1562 |
"/ escape-state machine, collect chunks of non-control text |
|
1563 |
"/ when in state 0, and add them immediately to the pendingLines |
|
1564 |
"/ collection of the textCollectors asynchronous update mechanism. |
|
1565 |
"/ This helps a lot if you do something like "ls -lR /" ... |
|
1566 |
"/ For debugging the state machine, reenable the commented lines |
|
1567 |
"/ below. |
|
1568 |
||
1569 |
"/1 to:count do:[:i| |
|
1570 |
"/ self nextPut:(buffer at:i). |
|
1571 |
"/]. |
|
1572 |
"/self showCursor. |
|
1573 |
"/^ self. |
|
1574 |
||
1575 |
access critical:[ |
|
2191 | 1576 |
|index controlCharIndex stringWithOutControl crnlFollows| |
997 | 1577 |
|
2191 | 1578 |
index := 1. |
1579 |
[index <= count] whileTrue:[ |
|
1015 | 1580 |
(state == 0) ifTrue:[ |
1581 |
"/ in initial state. |
|
1582 |
"/ quick scan forward for next control character ... |
|
2191 | 1583 |
controlCharIndex := buffer indexOfControlCharacterStartingAt:index. |
1584 |
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
|
1585 |
|
2191 | 1586 |
controlCharIndex == 0 ifTrue:[ |
1015 | 1587 |
"/ no control characters - simply append all |
1588 |
"/ to the outstanding lines ... |
|
2191 | 1589 |
stringWithOutControl := buffer copyFrom:index to:count. |
1590 |
index := count + 1. "/ leave loop. |
|
997 | 1591 |
crnlFollows := false. |
1015 | 1592 |
] ifFalse:[ |
2191 | 1593 |
controlCharIndex > index ifTrue:[ |
1594 |
stringWithOutControl := buffer copyFrom:index to:controlCharIndex-1. |
|
1595 |
index := controlCharIndex. "/ proceed withcontrol character |
|
1015 | 1596 |
crnlFollows := false. |
2191 | 1597 |
index < (count - 1) ifTrue:[ |
1598 |
(buffer at:index) == Character return ifTrue:[ |
|
1599 |
(buffer at:index+1) == Character nl ifTrue:[ |
|
1015 | 1600 |
crnlFollows := true. |
2191 | 1601 |
index := index + 2. |
1015 | 1602 |
] |
997 | 1603 |
] |
1015 | 1604 |
]. |
1605 |
] |
|
1606 |
]. |
|
997 | 1607 |
]. |
1608 |
||
2191 | 1609 |
stringWithOutControl notNil ifTrue:[ |
2356 | 1610 |
"/ self endEntry. |
1611 |
||
2268 | 1612 |
"/ characterwise, for correct wrap handling at line end |
2356 | 1613 |
|
1614 |
(cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[ |
|
2268 | 1615 |
self endEntry. |
1616 |
stringWithOutControl do:[:eachCharacter | |
|
1617 |
self nextPut:eachCharacter. |
|
1618 |
self endEntry |
|
1619 |
]. |
|
2356 | 1620 |
crnlFollows ifTrue:[ |
1621 |
self nextPut:Character return. |
|
1622 |
self nextPut:Character nl. |
|
1623 |
]. |
|
1624 |
self endEntry. |
|
1625 |
stringWithOutControl := nil. |
|
997 | 1626 |
] ifFalse:[ |
2356 | 1627 |
|
1628 |
Debug ifTrue:[ |
|
1629 |
Transcript showCR:'String:<', stringWithOutControl, '>'. |
|
1630 |
]. |
|
1631 |
currentEmphasis notNil ifTrue:[ |
|
1632 |
stringWithOutControl := stringWithOutControl emphasizeAllWith:currentEmphasis |
|
1633 |
]. |
|
1634 |
||
1635 |
outstandingLine size > 0 ifTrue:[ |
|
1636 |
outstandingLine := outstandingLine , stringWithOutControl. |
|
1015 | 1637 |
] ifFalse:[ |
2356 | 1638 |
outstandingLine := stringWithOutControl. |
1015 | 1639 |
]. |
2356 | 1640 |
crnlFollows ifTrue:[ |
1641 |
outstandingLines isNil ifTrue:[ |
|
1642 |
outstandingLines := OrderedCollection with:outstandingLine |
|
1643 |
] ifFalse:[ |
|
1644 |
outstandingLines add:outstandingLine. |
|
1645 |
]. |
|
1646 |
outstandingLine := ''. |
|
1647 |
]. |
|
1648 |
stringWithOutControl := nil. |
|
997 | 1649 |
|
2356 | 1650 |
collecting ifTrue:[ |
1651 |
flushPending ifFalse:[ |
|
1652 |
self installDelayedUpdate |
|
1653 |
] ifTrue:[ |
|
1654 |
"/ outstandingLines size > collectSize ifTrue:[ |
|
1655 |
"/ self endEntry |
|
1656 |
"/ ] |
|
1657 |
] |
|
1658 |
] ifFalse:[ |
|
1659 |
self endEntry |
|
1660 |
]. |
|
1015 | 1661 |
]. |
997 | 1662 |
] ifFalse:[ |
1015 | 1663 |
"/ no chunk to append (in an escape sequence) |
1664 |
"/ must handle individual characters |
|
1665 |
"/ 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
|
1666 |
|
2207 | 1667 |
self nextPut:(buffer at:index). |
2191 | 1668 |
index := index + 1. |
1669 |
[state ~~ 0 and:[index <= count]] whileTrue:[ |
|
2207 | 1670 |
self nextPut:(buffer at:index). |
2191 | 1671 |
index := index + 1. |
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1672 |
] |
1015 | 1673 |
] |
1674 |
]. |
|
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1675 |
]. |
948 | 1676 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1677 |
state == 0 ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1678 |
(sensor := self sensor) notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1679 |
"/ 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
|
1680 |
"/ enforce update of the view (asynchronous) |
997 | 1681 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1682 |
(sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
997 | 1683 |
self endEntry. |
1684 |
self showCursor. |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1685 |
"/ self makeCursorVisible. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1686 |
] ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1687 |
"/ 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
|
1688 |
"/ 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
|
1689 |
"/ 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
|
1690 |
"/ 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
|
1691 |
"/ collectSize lines. |
1015 | 1692 |
|
1055
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1693 |
outstandingLines size > collectSize ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1694 |
self endEntry. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1695 |
self showCursor. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1696 |
|
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1697 |
"/ 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
|
1698 |
windowGroup notNil ifTrue:[ |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1699 |
windowGroup processRealExposeEventsFor:self. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1700 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1701 |
]. |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1702 |
] |
eebff36e25e9
stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
1703 |
]. |
933
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1704 |
]. |
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1705 |
|
de456e07697e
much better asynchronous display
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
1706 |
"Created: / 10.6.1998 / 17:26:09 / cg" |
1347 | 1707 |
"Modified: / 29.4.1999 / 11:08:48 / cg" |
2076 | 1708 |
"Modified: / 28.1.2002 / 20:41:36 / micha" |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1709 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1710 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1711 |
readAnyAvailableData |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1712 |
"read data from the stream, |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1713 |
and sends me #processInput:n: events if something arrived. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1714 |
Returns the amount of data read." |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1715 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1716 |
|buffer n bufferSize| |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1717 |
|
1370
165f57ba2b12
care for closed stream in readAnyAvail
Claus Gittinger <cg@exept.de>
parents:
1366
diff
changeset
|
1718 |
outStream isNil ifTrue:[^ 0]. |
165f57ba2b12
care for closed stream in readAnyAvail
Claus Gittinger <cg@exept.de>
parents:
1366
diff
changeset
|
1719 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1720 |
bufferSize := 512. "/ 1024. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1721 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1722 |
buffer := String new:bufferSize. |
1371
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1723 |
ExternalStream readErrorSignal handle:[:ex | |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1724 |
n := 0 |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1725 |
] do:[ |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1726 |
n := outStream nextAvailableBytes:bufferSize into:buffer startingAt:1. |
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1727 |
]. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1728 |
n > 0 ifTrue:[ |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1729 |
self pushEvent:#processInput:n: with:buffer with:n. |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1730 |
]. |
1371
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1731 |
|
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1732 |
^ n |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1733 |
|
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1734 |
"Created: / 5.5.1999 / 17:57:39 / cg" |
1371
2b28c00660b3
handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1735 |
"Modified: / 8.5.1999 / 20:14:14 / cg" |
2077 | 1736 |
"Modified: / 28.1.2002 / 21:10:25 / micha" |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1737 |
! |
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1738 |
|
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1739 |
sync |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1740 |
self waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1741 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1742 |
"Created: / 27.7.1998 / 23:49:44 / cg" |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1743 |
! |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1744 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1745 |
waitForOutputToDrain |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1746 |
|sensor| |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1747 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1748 |
sensor := self sensor. |
1363
7297da8a2e02
dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents:
1360
diff
changeset
|
1749 |
(sensor notNil and:[sensor userEventCount > 30]) ifTrue:[ |
1323 | 1750 |
[sensor userEventCount > 5] whileTrue:[ |
1021
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1751 |
"/ give terminalView a chance to |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1752 |
"/ catch up. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1753 |
Delay waitForSeconds:0.1. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1754 |
] |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1755 |
]. |
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1756 |
|
c3963e925eb5
added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents:
1017
diff
changeset
|
1757 |
"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
|
1758 |
"Modified: / 5.5.1999 / 18:51:00 / cg" |
914 | 1759 |
! ! |
1760 |
||
1761 |
!TerminalView methodsFor:'queries'! |
|
1762 |
||
1763 |
preferredExtent |
|
1420 | 1764 |
"return my preferred extent - this is computed from my numberOfLines, |
1765 |
numberOfCols and font size" |
|
1766 |
||
2268 | 1767 |
^ (fontWidth * self class defaultNumberOfColumns + (leftMargin + margin * 2)) |
951 | 1768 |
@ |
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1769 |
((self heightForLines:self class defaultNumberOfLines) + 8) |
926 | 1770 |
|
979 | 1771 |
"Modified: / 20.6.1998 / 20:06:57 / cg" |
929 | 1772 |
! |
1773 |
||
1774 |
terminalType |
|
1420 | 1775 |
"returns a string describing this terminal (usually, this is |
1776 |
passed down to the shell as TERM environment variable). |
|
1777 |
Here, 'dump' is returned." |
|
1778 |
||
1354
94e7e8be960f
must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents:
1349
diff
changeset
|
1779 |
^ 'dump' |
929 | 1780 |
|
1781 |
"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
|
1782 |
"Modified: / 5.5.1999 / 11:22:32 / cg" |
914 | 1783 |
! ! |
1784 |
||
2506 | 1785 |
!TerminalView methodsFor:'searching'! |
1786 |
||
1787 |
startPositionForSearchBackward |
|
1788 |
"sigh - same as found in TextView" |
|
1789 |
||
1790 |
|startLine startCol| |
|
1791 |
||
1792 |
selectionStartLine notNil ifTrue:[ |
|
1793 |
startLine := selectionStartLine. |
|
1794 |
startCol := selectionStartCol |
|
1795 |
] ifFalse:[ |
|
1796 |
startLine := 1. |
|
1797 |
startCol := 1 |
|
1798 |
]. |
|
1799 |
||
1800 |
^ startCol @ startLine |
|
1801 |
! |
|
1802 |
||
1803 |
startPositionForSearchForward |
|
1804 |
"sigh - same as found in TextView" |
|
1805 |
||
1806 |
|startLine startCol| |
|
1807 |
||
1808 |
selectionStartLine notNil ifTrue:[ |
|
1809 |
startLine := selectionStartLine. |
|
1810 |
startCol := selectionStartCol |
|
1811 |
] ifFalse:[ |
|
1812 |
startLine := 1. |
|
1813 |
startCol := 1 |
|
1814 |
]. |
|
1815 |
||
1816 |
^ startCol @ startLine |
|
1817 |
! ! |
|
1818 |
||
914 | 1819 |
!TerminalView methodsFor:'selection handling'! |
1820 |
||
1317
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1821 |
autoMoveCursorToEndOfSelection |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1822 |
"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
|
1823 |
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
|
1824 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1825 |
^ false |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1826 |
|
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1827 |
! |
dace272367a7
do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents:
1316
diff
changeset
|
1828 |
|
914 | 1829 |
paste:someText |
1830 |
"paste - redefined to send the chars to the shell instead |
|
1831 |
of pasting into the view" |
|
1832 |
||
950 | 1833 |
|s nLines| |
1834 |
||
1835 |
s := someText. |
|
1836 |
s isString ifTrue:[ |
|
1837 |
s := s asStringCollection |
|
1838 |
] ifFalse:[ |
|
1839 |
(s isKindOf:StringCollection) ifFalse:[ |
|
1840 |
self warn:'selection (' , s class name , ') is not convertable to Text'. |
|
1841 |
^ self |
|
1842 |
] |
|
1843 |
]. |
|
1844 |
(nLines := s size) == 0 ifTrue:[^ self]. |
|
1845 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
|
1846 |
s keysAndValuesDo:[:idx :line | |
|
1404 | 1847 |
line notNil ifTrue:[inStream nextPutAll:line]. |
950 | 1848 |
idx ~~ nLines ifTrue:[ |
1849 |
inStream nextPut:(Character return). |
|
1850 |
] |
|
1851 |
]. |
|
1852 |
||
1853 |
"Modified: / 12.6.1998 / 22:12:47 / cg" |
|
914 | 1854 |
! ! |
1855 |
||
1856 |
!TerminalView class methodsFor:'documentation'! |
|
1857 |
||
1858 |
version |
|
2506 | 1859 |
^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.116 2003-05-10 11:53:37 cg Exp $' |
914 | 1860 |
! ! |
2205 | 1861 |
|
1862 |
TerminalView initialize! |