author | Claus Gittinger <cg@exept.de> |
Sat, 10 May 2014 12:45:09 +0200 | |
changeset 14342 | 29d328c916c1 |
parent 13952 | 1b127aaddf33 |
child 14460 | 13d136d2e5a9 |
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 |
||
130 |
destroy |
|
131 |
||
132 |
super destroy. |
|
133 |
pid ifNotNil: |
|
134 |
[OperatingSystem terminateProcess: pid]. |
|
135 |
||
136 |
"Created: / 25-11-2010 / 10:48:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
137 |
"Modified: / 01-06-2011 / 13:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
138 |
! |
|
139 |
||
140 |
initialize |
|
141 |
||
142 |
super initialize. |
|
143 |
wd := Filename defaultDirectory asString |
|
144 |
||
145 |
"Created: / 25-11-2010 / 12:34:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146 |
! ! |
|
147 |
||
13816 | 148 |
!XTermView methodsFor:'menu'! |
149 |
||
150 |
doClear |
|
151 |
"reset the scroll-range etc, clear the text buffer" |
|
152 |
||
153 |
"/ rangeStartLine := 1. |
|
154 |
"/ rangeEndLine := numberOfLines. |
|
155 |
"/ |
|
156 |
"/ self normal. |
|
157 |
"/ self clear. |
|
158 |
||
159 |
"Created: / 03-04-2007 / 08:58:59 / cg" |
|
160 |
"Modified: / 03-04-2012 / 10:34:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
161 |
! |
|
162 |
||
163 |
doReset |
|
164 |
"reset the scroll-range; |
|
165 |
may have to reset more in the future (current font-set; color; etc)" |
|
166 |
||
167 |
"/ rangeStartLine := 1. |
|
168 |
"/ rangeEndLine := numberOfLines. |
|
169 |
"/ |
|
170 |
"/ self normal. |
|
171 |
||
172 |
"Modified: / 03-04-2012 / 10:34:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
173 |
! |
|
174 |
||
175 |
doSendInterrupt |
|
176 |
"send an INT-signal to the shell (UNIX only)" |
|
177 |
pid notNil ifTrue:[ |
|
178 |
OperatingSystem sendSignal:(OperatingSystem sigINT) to:pid negated. |
|
179 |
]. |
|
180 |
||
181 |
"Modified: / 10-06-1998 / 17:49:49 / cg" |
|
182 |
"Modified: / 03-04-2012 / 10:34:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
183 |
! |
|
184 |
||
185 |
doSendKillSignal |
|
186 |
"send a KILL-signal to the shell (UNIX only)" |
|
187 |
||
188 |
pid notNil ifTrue:[ |
|
189 |
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:pid negated. |
|
190 |
] |
|
191 |
||
192 |
"Modified: / 03-04-2012 / 10:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
193 |
! ! |
|
194 |
||
10263 | 195 |
!XTermView methodsFor:'mimicry'! |
196 |
||
13816 | 197 |
defaultFileNameForFileDialog |
198 |
||
199 |
^nil |
|
200 |
||
201 |
"Created: / 03-05-2012 / 12:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
202 |
! |
|
203 |
||
204 |
lineLimit:aSmallInteger |
|
205 |
||
206 |
"Nothing" |
|
207 |
||
208 |
"Created: / 03-04-2012 / 10:42:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
209 |
! |
|
210 |
||
211 |
list |
|
212 |
^nil |
|
213 |
||
214 |
"Created: / 17-07-2012 / 21:11:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
215 |
! |
|
216 |
||
217 |
modified |
|
218 |
||
219 |
^false |
|
220 |
||
221 |
"Created: / 03-05-2012 / 11:42:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 |
! |
|
223 |
||
224 |
save |
|
225 |
||
226 |
Dialog warn: 'Not yet implemented for XTermView' |
|
227 |
||
228 |
"Created: / 03-04-2012 / 10:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
229 |
! |
|
230 |
||
231 |
selectionAsString |
|
13952 | 232 |
^ (self graphicsDevice getSelectionOwnerOf: #PRIMARY) = self drawableId ifTrue:[ |
233 |
self graphicsDevice getClipboardText:#selection for:self drawableId |
|
13816 | 234 |
] ifFalse:[ |
235 |
nil |
|
236 |
] |
|
237 |
||
238 |
"Created: / 03-04-2012 / 10:30:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
239 |
! |
|
240 |
||
241 |
sendLine:aString |
|
242 |
self halt:'please define sendLine: here'. |
|
243 |
||
244 |
"Created: / 03-04-2012 / 10:33:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
245 |
! |
|
246 |
||
10263 | 247 |
shellTerminateAction: aBlock |
248 |
||
249 |
"Nothing to do" |
|
250 |
||
251 |
"Created: / 25-11-2010 / 12:37:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
252 |
! |
|
253 |
||
254 |
startShellIn:aUnixFilename |
|
255 |
||
256 |
"Nothing to do. just to be compatible with TerminalView" |
|
257 |
||
258 |
"Created: / 25-11-2010 / 12:38:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
259 |
! ! |
|
260 |
||
261 |
!XTermView methodsFor:'private'! |
|
262 |
||
263 |
xcolorNameFor: aColor |
|
264 |
||
265 |
^'rgb:%1/%2/%3' |
|
266 |
bindWith: (aColor redByte printStringRadix: 16) |
|
267 |
with: (aColor greenByte printStringRadix: 16) |
|
268 |
with: (aColor blueByte printStringRadix: 16) |
|
269 |
||
270 |
"Created: / 25-11-2010 / 12:25:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
271 |
! |
|
272 |
||
273 |
xtermArgs |
|
274 |
| args | |
|
275 |
||
276 |
args := OrderedCollection new. |
|
277 |
args |
|
278 |
add: self xtermExecutable; |
|
13952 | 279 |
add: (XTermType == #xterm ifTrue:['-into'] ifFalse:['-embed']); add:self embeddingWindowId printString; |
10263 | 280 |
add: '-j'; |
13913
d4cdc5e3e3d2
Fix - removed initStyle
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13907
diff
changeset
|
281 |
"/ add: '-font'; add: (device fullFontNameOf: (font fontId)); |
10263 | 282 |
add: '-fg'; add: 'white'"(self xcolorNameFor: foreground)"; |
283 |
add: '-bg'; add: 'black'"(self xcolorNameFor: viewBackground)". |
|
284 |
||
285 |
XTermType == #rxvt ifTrue:[ |
|
286 |
args |
|
287 |
add: '-tn'; add: 'xterm' |
|
288 |
]. |
|
289 |
||
13816 | 290 |
^args asArray |
10263 | 291 |
|
13913
d4cdc5e3e3d2
Fix - removed initStyle
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13907
diff
changeset
|
292 |
"Modified: / 06-02-2014 / 20:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10263 | 293 |
! |
294 |
||
295 |
xtermExecutable |
|
296 |
||
297 |
^ XTermExecutable |
|
298 |
||
299 |
"Modified: / 09-12-2010 / 23:16:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
300 |
! ! |
|
301 |
||
302 |
!XTermView methodsFor:'queries'! |
|
303 |
||
304 |
preferredExtent |
|
305 |
"return my preferred extent - this is the minimum size I would like to have. |
|
306 |
If the preferredExtent has been set, that one is returned. |
|
307 |
Otherwise, if there are any components, a rectangle enclosing them |
|
308 |
is returned. Otherwise, the actual extent is returned." |
|
309 |
||
310 |
"/ If I have an explicit preferredExtent.. |
|
311 |
explicitExtent notNil ifTrue:[ |
|
312 |
^ explicitExtent |
|
313 |
]. |
|
314 |
||
315 |
"/ If I have a cached preferredExtent value.. |
|
316 |
preferredExtent notNil ifTrue:[ |
|
317 |
^ preferredExtent |
|
318 |
]. |
|
319 |
||
13952 | 320 |
^(gc font width * 80) @ (gc font height * 25) |
10263 | 321 |
|
322 |
"Modified: / 19-07-1996 / 20:43:32 / cg" |
|
323 |
"Created: / 25-11-2010 / 12:51:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
324 |
! ! |
|
325 |
||
326 |
!XTermView methodsFor:'realization'! |
|
327 |
||
328 |
postRealize |
|
329 |
||
330 |
super postRealize. |
|
331 |
XTermType ~= #rxvt ifTrue:[self sizeChanged: nil] |
|
332 |
||
333 |
"Created: / 25-11-2010 / 11:08:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
334 |
"Modified: / 13-12-2010 / 22:08:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
335 |
! |
|
336 |
||
337 |
preRealize |
|
338 |
super preRealize. |
|
13907 | 339 |
self startXTerm |
340 |
||
341 |
"Created: / 25-11-2010 / 10:51:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
342 |
"Modified: / 02-06-2011 / 23:27:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
343 |
! |
|
344 |
||
345 |
startXTerm |
|
10263 | 346 |
clientViewId isNil ifTrue:[ |
13907 | 347 |
pid := OperatingSystem |
10263 | 348 |
exec:self xtermExecutable |
349 |
withArguments:self xtermArgs |
|
350 |
fork:true |
|
351 |
inDirectory: wd. |
|
352 |
] |
|
353 |
||
354 |
"Created: / 25-11-2010 / 10:51:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
355 |
"Modified: / 02-06-2011 / 23:27:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
356 |
! ! |
|
357 |
||
10704
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
358 |
!XTermView methodsFor:'testing'! |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
359 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
360 |
isTextView |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
361 |
|
13816 | 362 |
^true |
10704
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
363 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
364 |
"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
|
365 |
! ! |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
366 |
|
10263 | 367 |
!XTermView class methodsFor:'documentation'! |
368 |
||
369 |
version_CVS |
|
13952 | 370 |
^ '$Header: /cvs/stx/stx/libtool/XTermView.st,v 1.8 2014-02-18 14:18:33 stefan Exp $' |
10263 | 371 |
! |
372 |
||
373 |
version_SVN |
|
13952 | 374 |
^ '$Id: XTermView.st,v 1.8 2014-02-18 14:18:33 stefan Exp $' |
10263 | 375 |
! ! |
376 |
||
13790 | 377 |
|
10263 | 378 |
XTermView initialize! |