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