author | Claus Gittinger <cg@exept.de> |
Sat, 13 Jul 2019 16:02:10 +0200 | |
changeset 18898 | e786d72d82ef |
parent 14461 | 5dfe30926b88 |
child 15566 | 184cea584be5 |
permissions | -rw-r--r-- |
10263 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libtool' }" |
|
13 |
||
14 |
XEmbedContainerView subclass:#XTermView |
|
15 |
instanceVariableNames:'pid wid wd' |
|
16 |
classVariableNames:'XTermType XTermExecutable' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Tools-Terminal' |
|
19 |
! |
|
20 |
||
21 |
!XTermView class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
13907 | 35 |
! |
36 |
||
37 |
examples |
|
38 |
" |
|
39 |
self new open |
|
40 |
" |
|
10263 | 41 |
! ! |
42 |
||
43 |
!XTermView class methodsFor:'class initialization'! |
|
44 |
||
45 |
initialize |
|
46 |
||
47 |
XTermType := #unavailable. |
|
13907 | 48 |
#(urxvt rxvt xterm uxterm) do:[:eachXtermCommandSymbol| |
49 |
(XTermExecutable := OperatingSystem pathOfCommand:eachXtermCommandSymbol) notNil ifTrue:[ |
|
50 |
XTermType := eachXtermCommandSymbol. |
|
11831 | 51 |
^ self |
13907 | 52 |
]. |
10263 | 53 |
]. |
54 |
||
55 |
" |
|
56 |
XTermView initialize |
|
57 |
" |
|
58 |
||
59 |
"Created: / 09-12-2010 / 23:15:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
60 |
! ! |
|
61 |
||
62 |
!XTermView class methodsFor:'defaults'! |
|
63 |
||
64 |
defaultFont |
|
65 |
||
66 |
DefaultFont ifNotNil:[^CodeView defaultFont]. |
|
67 |
^super defaultFont. |
|
68 |
||
69 |
"Created: / 25-11-2010 / 12:50:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
70 |
! |
|
71 |
||
72 |
updateStyleCache |
|
73 |
||
74 |
super updateStyleCache. |
|
75 |
"/DefaultViewBackgroundColor := Color black. |
|
76 |
||
77 |
"Created: / 25-11-2010 / 12:21:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
78 |
! ! |
|
79 |
||
80 |
!XTermView class methodsFor:'queries'! |
|
81 |
||
82 |
isAvailable |
|
83 |
||
84 |
^XTermType ~= #unavailable |
|
85 |
||
86 |
"Created: / 09-12-2010 / 23:21:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
87 |
! ! |
|
88 |
||
89 |
!XTermView methodsFor:'accessing'! |
|
90 |
||
91 |
workingDirectory: aStringOrFilename |
|
92 |
||
93 |
aStringOrFilename ifNotNil: |
|
94 |
[wd := aStringOrFilename asString]. |
|
95 |
||
96 |
"Created: / 25-11-2010 / 12:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
97 |
! ! |
|
98 |
||
99 |
!XTermView methodsFor:'event handling'! |
|
100 |
||
101 |
clientUnplugged: clientInitiated |
|
102 |
||
103 |
| app | |
|
104 |
||
105 |
super clientUnplugged: clientInitiated. |
|
106 |
||
107 |
clientInitiated ifFalse:[^self]. |
|
108 |
||
109 |
"But hackish..." |
|
110 |
app := self application. |
|
111 |
app ifNil:[^self]. |
|
13816 | 112 |
(app class == FileApplicationNoteBook::Terminal) ifTrue:[ |
113 |
app doClose. |
|
114 |
^self. |
|
115 |
]. |
|
10263 | 116 |
#(removeWorkspace "WorkspaceApplication" |
117 |
bufferMenuRemoveCurrentBuffer "NewSystemBrowser" |
|
118 |
) do:[:closeSelector| |
|
13816 | 119 |
(app topApplication respondsTo: closeSelector) ifTrue: [ |
120 |
app topApplication perform: closeSelector. |
|
121 |
^self |
|
122 |
] |
|
123 |
]. |
|
10263 | 124 |
|
125 |
"Created: / 06-06-2011 / 10:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
126 |
! ! |
|
127 |
||
128 |
!XTermView methodsFor:'initialization & release'! |
|
129 |
||
14461 | 130 |
closeDownShell |
131 |
"shut down my shell process." |
|
132 |
||
14460 | 133 |
|p| |
10263 | 134 |
|
14460 | 135 |
(p := pid) notNil ifTrue:[ |
136 |
pid := nil. |
|
137 |
OperatingSystem terminateProcess: p |
|
138 |
]. |
|
14461 | 139 |
! |
140 |
||
141 |
destroy |
|
142 |
self closeDownShell. |
|
143 |
super destroy. |
|
10263 | 144 |
|
145 |
"Created: / 25-11-2010 / 10:48:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146 |
"Modified: / 01-06-2011 / 13:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
initialize |
|
150 |
||
151 |
super initialize. |
|
152 |
wd := Filename defaultDirectory asString |
|
153 |
||
154 |
"Created: / 25-11-2010 / 12:34:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
155 |
! ! |
|
156 |
||
13816 | 157 |
!XTermView methodsFor:'menu'! |
158 |
||
159 |
doClear |
|
160 |
"reset the scroll-range etc, clear the text buffer" |
|
161 |
||
162 |
"/ rangeStartLine := 1. |
|
163 |
"/ rangeEndLine := numberOfLines. |
|
164 |
"/ |
|
165 |
"/ self normal. |
|
166 |
"/ self clear. |
|
167 |
||
168 |
"Created: / 03-04-2007 / 08:58:59 / cg" |
|
169 |
"Modified: / 03-04-2012 / 10:34:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
170 |
! |
|
171 |
||
172 |
doReset |
|
173 |
"reset the scroll-range; |
|
174 |
may have to reset more in the future (current font-set; color; etc)" |
|
175 |
||
176 |
"/ rangeStartLine := 1. |
|
177 |
"/ rangeEndLine := numberOfLines. |
|
178 |
"/ |
|
179 |
"/ self normal. |
|
180 |
||
181 |
"Modified: / 03-04-2012 / 10:34:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
182 |
! |
|
183 |
||
184 |
doSendInterrupt |
|
185 |
"send an INT-signal to the shell (UNIX only)" |
|
186 |
pid notNil ifTrue:[ |
|
187 |
OperatingSystem sendSignal:(OperatingSystem sigINT) to:pid negated. |
|
188 |
]. |
|
189 |
||
190 |
"Modified: / 10-06-1998 / 17:49:49 / cg" |
|
191 |
"Modified: / 03-04-2012 / 10:34:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
192 |
! |
|
193 |
||
194 |
doSendKillSignal |
|
195 |
"send a KILL-signal to the shell (UNIX only)" |
|
196 |
||
197 |
pid notNil ifTrue:[ |
|
198 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:pid negated. |
|
199 |
] |
|
200 |
||
201 |
"Modified: / 03-04-2012 / 10:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
202 |
! ! |
|
203 |
||
10263 | 204 |
!XTermView methodsFor:'mimicry'! |
205 |
||
13816 | 206 |
defaultFileNameForFileDialog |
207 |
||
208 |
^nil |
|
209 |
||
210 |
"Created: / 03-05-2012 / 12:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
211 |
! |
|
212 |
||
213 |
lineLimit:aSmallInteger |
|
214 |
||
215 |
"Nothing" |
|
216 |
||
217 |
"Created: / 03-04-2012 / 10:42:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
218 |
! |
|
219 |
||
220 |
list |
|
221 |
^nil |
|
222 |
||
223 |
"Created: / 17-07-2012 / 21:11:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
224 |
! |
|
225 |
||
226 |
modified |
|
227 |
||
228 |
^false |
|
229 |
||
230 |
"Created: / 03-05-2012 / 11:42:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
231 |
! |
|
232 |
||
233 |
save |
|
234 |
||
235 |
Dialog warn: 'Not yet implemented for XTermView' |
|
236 |
||
237 |
"Created: / 03-04-2012 / 10:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
238 |
! |
|
239 |
||
240 |
selectionAsString |
|
13952 | 241 |
^ (self graphicsDevice getSelectionOwnerOf: #PRIMARY) = self drawableId ifTrue:[ |
242 |
self graphicsDevice getClipboardText:#selection for:self drawableId |
|
13816 | 243 |
] ifFalse:[ |
244 |
nil |
|
245 |
] |
|
246 |
||
247 |
"Created: / 03-04-2012 / 10:30:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
248 |
! |
|
249 |
||
250 |
sendLine:aString |
|
251 |
self halt:'please define sendLine: here'. |
|
252 |
||
253 |
"Created: / 03-04-2012 / 10:33:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
254 |
! |
|
255 |
||
10263 | 256 |
shellTerminateAction: aBlock |
257 |
||
258 |
"Nothing to do" |
|
259 |
||
260 |
"Created: / 25-11-2010 / 12:37:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
261 |
! |
|
262 |
||
263 |
startShellIn:aUnixFilename |
|
264 |
||
265 |
"Nothing to do. just to be compatible with TerminalView" |
|
266 |
||
267 |
"Created: / 25-11-2010 / 12:38:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
268 |
! ! |
|
269 |
||
270 |
!XTermView methodsFor:'private'! |
|
271 |
||
272 |
xcolorNameFor: aColor |
|
273 |
||
274 |
^'rgb:%1/%2/%3' |
|
275 |
bindWith: (aColor redByte printStringRadix: 16) |
|
276 |
with: (aColor greenByte printStringRadix: 16) |
|
277 |
with: (aColor blueByte printStringRadix: 16) |
|
278 |
||
279 |
"Created: / 25-11-2010 / 12:25:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
280 |
! |
|
281 |
||
282 |
xtermArgs |
|
283 |
| args | |
|
284 |
||
285 |
args := OrderedCollection new. |
|
286 |
args |
|
287 |
add: self xtermExecutable; |
|
13952 | 288 |
add: (XTermType == #xterm ifTrue:['-into'] ifFalse:['-embed']); add:self embeddingWindowId printString; |
10263 | 289 |
add: '-j'; |
13913
d4cdc5e3e3d2
Fix - removed initStyle
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13907
diff
changeset
|
290 |
"/ add: '-font'; add: (device fullFontNameOf: (font fontId)); |
10263 | 291 |
add: '-fg'; add: 'white'"(self xcolorNameFor: foreground)"; |
292 |
add: '-bg'; add: 'black'"(self xcolorNameFor: viewBackground)". |
|
293 |
||
294 |
XTermType == #rxvt ifTrue:[ |
|
295 |
args |
|
296 |
add: '-tn'; add: 'xterm' |
|
297 |
]. |
|
298 |
||
13816 | 299 |
^args asArray |
10263 | 300 |
|
13913
d4cdc5e3e3d2
Fix - removed initStyle
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13907
diff
changeset
|
301 |
"Modified: / 06-02-2014 / 20:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10263 | 302 |
! |
303 |
||
304 |
xtermExecutable |
|
305 |
||
306 |
^ XTermExecutable |
|
307 |
||
308 |
"Modified: / 09-12-2010 / 23:16:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
309 |
! ! |
|
310 |
||
311 |
!XTermView methodsFor:'queries'! |
|
312 |
||
313 |
preferredExtent |
|
314 |
"return my preferred extent - this is the minimum size I would like to have. |
|
315 |
If the preferredExtent has been set, that one is returned. |
|
316 |
Otherwise, if there are any components, a rectangle enclosing them |
|
317 |
is returned. Otherwise, the actual extent is returned." |
|
318 |
||
319 |
"/ If I have an explicit preferredExtent.. |
|
320 |
explicitExtent notNil ifTrue:[ |
|
321 |
^ explicitExtent |
|
322 |
]. |
|
323 |
||
324 |
"/ If I have a cached preferredExtent value.. |
|
325 |
preferredExtent notNil ifTrue:[ |
|
326 |
^ preferredExtent |
|
327 |
]. |
|
328 |
||
13952 | 329 |
^(gc font width * 80) @ (gc font height * 25) |
10263 | 330 |
|
331 |
"Modified: / 19-07-1996 / 20:43:32 / cg" |
|
332 |
"Created: / 25-11-2010 / 12:51:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
333 |
! ! |
|
334 |
||
335 |
!XTermView methodsFor:'realization'! |
|
336 |
||
337 |
postRealize |
|
338 |
||
339 |
super postRealize. |
|
340 |
XTermType ~= #rxvt ifTrue:[self sizeChanged: nil] |
|
341 |
||
342 |
"Created: / 25-11-2010 / 11:08:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
343 |
"Modified: / 13-12-2010 / 22:08:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
344 |
! |
|
345 |
||
346 |
preRealize |
|
347 |
super preRealize. |
|
13907 | 348 |
self startXTerm |
349 |
||
350 |
"Created: / 25-11-2010 / 10:51:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
351 |
"Modified: / 02-06-2011 / 23:27:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
352 |
! |
|
353 |
||
354 |
startXTerm |
|
10263 | 355 |
clientViewId isNil ifTrue:[ |
13907 | 356 |
pid := OperatingSystem |
10263 | 357 |
exec:self xtermExecutable |
358 |
withArguments:self xtermArgs |
|
359 |
fork:true |
|
360 |
inDirectory: wd. |
|
361 |
] |
|
362 |
||
363 |
"Created: / 25-11-2010 / 10:51:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
364 |
"Modified: / 02-06-2011 / 23:27:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
365 |
! ! |
|
366 |
||
10704
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
367 |
!XTermView methodsFor:'testing'! |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
368 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
369 |
isTextView |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
370 |
|
13816 | 371 |
^true |
10704
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
372 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
373 |
"Created: / 13-09-2011 / 11:22:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
374 |
! ! |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
375 |
|
10263 | 376 |
!XTermView class methodsFor:'documentation'! |
377 |
||
14461 | 378 |
version |
379 |
^ '$Header: /cvs/stx/stx/libtool/XTermView.st,v 1.10 2014-06-05 18:25:15 cg Exp $' |
|
380 |
! |
|
381 |
||
10263 | 382 |
version_CVS |
14461 | 383 |
^ '$Header: /cvs/stx/stx/libtool/XTermView.st,v 1.10 2014-06-05 18:25:15 cg Exp $' |
10263 | 384 |
! |
385 |
||
386 |
version_SVN |
|
14461 | 387 |
^ '$Id: XTermView.st,v 1.10 2014-06-05 18:25:15 cg Exp $' |
10263 | 388 |
! ! |
389 |
||
13790 | 390 |
|
10263 | 391 |
XTermView initialize! |