author | Claus Gittinger <cg@exept.de> |
Sat, 14 Jan 2012 21:01:33 +0100 | |
changeset 11125 | 59ee0c157f3c |
parent 10704 | 015027d5c1a2 |
child 11831 | f2e23f8433f1 |
child 12123 | 4bde08cebd48 |
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 |
" |
|
35 |
! ! |
|
36 |
||
37 |
!XTermView class methodsFor:'class initialization'! |
|
38 |
||
39 |
initialize |
|
40 |
||
41 |
XTermType := #unavailable. |
|
42 |
||
43 |
(XTermExecutable := OperatingSystem pathOfCommand:'urxvt') ifNotNil:[ |
|
44 |
XTermType := #rxvt. |
|
45 |
^self |
|
46 |
]. |
|
47 |
||
48 |
(XTermExecutable := OperatingSystem pathOfCommand:'rxvt') ifNotNil:[ |
|
49 |
XTermType := #rxvt. |
|
50 |
^self |
|
51 |
]. |
|
52 |
||
53 |
(XTermExecutable := OperatingSystem pathOfCommand:'xterm') ifNotNil:[ |
|
54 |
XTermType := #xterm. |
|
55 |
^self |
|
56 |
]. |
|
57 |
||
58 |
" |
|
59 |
XTermView initialize |
|
60 |
" |
|
61 |
||
62 |
"Created: / 09-12-2010 / 23:15:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
63 |
! ! |
|
64 |
||
65 |
!XTermView class methodsFor:'defaults'! |
|
66 |
||
67 |
defaultFont |
|
68 |
||
69 |
DefaultFont ifNotNil:[^CodeView defaultFont]. |
|
70 |
^super defaultFont. |
|
71 |
||
72 |
"Created: / 25-11-2010 / 12:50:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
73 |
! |
|
74 |
||
75 |
updateStyleCache |
|
76 |
||
77 |
super updateStyleCache. |
|
78 |
"/DefaultViewBackgroundColor := Color black. |
|
79 |
||
80 |
"Created: / 25-11-2010 / 12:21:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
81 |
! ! |
|
82 |
||
83 |
!XTermView class methodsFor:'queries'! |
|
84 |
||
85 |
isAvailable |
|
86 |
||
87 |
^XTermType ~= #unavailable |
|
88 |
||
89 |
"Created: / 09-12-2010 / 23:21:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
90 |
! ! |
|
91 |
||
92 |
!XTermView methodsFor:'accessing'! |
|
93 |
||
94 |
workingDirectory: aStringOrFilename |
|
95 |
||
96 |
aStringOrFilename ifNotNil: |
|
97 |
[wd := aStringOrFilename asString]. |
|
98 |
||
99 |
"Created: / 25-11-2010 / 12:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
100 |
! ! |
|
101 |
||
102 |
!XTermView methodsFor:'event handling'! |
|
103 |
||
104 |
clientUnplugged: clientInitiated |
|
105 |
||
106 |
| app | |
|
107 |
||
108 |
super clientUnplugged: clientInitiated. |
|
109 |
||
110 |
clientInitiated ifFalse:[^self]. |
|
111 |
||
112 |
"But hackish..." |
|
113 |
app := self application. |
|
114 |
app ifNil:[^self]. |
|
115 |
#(removeWorkspace "WorkspaceApplication" |
|
116 |
doCloseApplication "FileBrowserNotebook" |
|
117 |
bufferMenuRemoveCurrentBuffer "NewSystemBrowser" |
|
118 |
) do:[:closeSelector| |
|
119 |
(app topApplication respondsTo: closeSelector) ifTrue: |
|
120 |
[app topApplication perform: closeSelector]]. |
|
121 |
||
122 |
"Created: / 06-06-2011 / 10:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
123 |
! ! |
|
124 |
||
125 |
!XTermView methodsFor:'initialization & release'! |
|
126 |
||
127 |
destroy |
|
128 |
||
129 |
super destroy. |
|
130 |
pid ifNotNil: |
|
131 |
[OperatingSystem terminateProcess: pid]. |
|
132 |
||
133 |
"Created: / 25-11-2010 / 10:48:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
134 |
"Modified: / 01-06-2011 / 13:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 |
! |
|
136 |
||
137 |
initStyle |
|
138 |
||
139 |
"Created: / 25-11-2010 / 12:14:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
! |
|
141 |
||
142 |
initialize |
|
143 |
||
144 |
super initialize. |
|
145 |
wd := Filename defaultDirectory asString |
|
146 |
||
147 |
"Created: / 25-11-2010 / 12:34:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
148 |
! ! |
|
149 |
||
150 |
!XTermView methodsFor:'mimicry'! |
|
151 |
||
152 |
shellTerminateAction: aBlock |
|
153 |
||
154 |
"Nothing to do" |
|
155 |
||
156 |
"Created: / 25-11-2010 / 12:37:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
157 |
! |
|
158 |
||
159 |
startShellIn:aUnixFilename |
|
160 |
||
161 |
"Nothing to do. just to be compatible with TerminalView" |
|
162 |
||
163 |
"Created: / 25-11-2010 / 12:38:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
164 |
! ! |
|
165 |
||
166 |
!XTermView methodsFor:'private'! |
|
167 |
||
168 |
xcolorNameFor: aColor |
|
169 |
||
170 |
^'rgb:%1/%2/%3' |
|
171 |
bindWith: (aColor redByte printStringRadix: 16) |
|
172 |
with: (aColor greenByte printStringRadix: 16) |
|
173 |
with: (aColor blueByte printStringRadix: 16) |
|
174 |
||
175 |
"Created: / 25-11-2010 / 12:25:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
176 |
! |
|
177 |
||
178 |
xtermArgs |
|
179 |
||
180 |
| args | |
|
181 |
||
182 |
args := OrderedCollection new. |
|
183 |
args |
|
184 |
add: self xtermExecutable; |
|
185 |
add: (XTermType == #rxvt ifTrue:['-embed'] ifFalse:['-into']); add: drawableId address printString; |
|
186 |
add: '-j'; |
|
187 |
add: '-font'; add: (device fullFontNameOf: (font fontId)); |
|
188 |
add: '-fg'; add: 'white'"(self xcolorNameFor: foreground)"; |
|
189 |
add: '-bg'; add: 'black'"(self xcolorNameFor: viewBackground)". |
|
190 |
||
191 |
XTermType == #rxvt ifTrue:[ |
|
192 |
args |
|
193 |
add: '-tn'; add: 'xterm' |
|
194 |
]. |
|
195 |
||
196 |
^args asArray |
|
197 |
||
198 |
"Modified: / 10-06-2011 / 19:51:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
199 |
! |
|
200 |
||
201 |
xtermExecutable |
|
202 |
||
203 |
^ XTermExecutable |
|
204 |
||
205 |
"Modified: / 09-12-2010 / 23:16:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
206 |
! ! |
|
207 |
||
208 |
!XTermView methodsFor:'queries'! |
|
209 |
||
210 |
preferredExtent |
|
211 |
"return my preferred extent - this is the minimum size I would like to have. |
|
212 |
If the preferredExtent has been set, that one is returned. |
|
213 |
Otherwise, if there are any components, a rectangle enclosing them |
|
214 |
is returned. Otherwise, the actual extent is returned." |
|
215 |
||
216 |
"/ If I have an explicit preferredExtent.. |
|
217 |
explicitExtent notNil ifTrue:[ |
|
218 |
^ explicitExtent |
|
219 |
]. |
|
220 |
||
221 |
"/ If I have a cached preferredExtent value.. |
|
222 |
preferredExtent notNil ifTrue:[ |
|
223 |
^ preferredExtent |
|
224 |
]. |
|
225 |
||
226 |
^(font width * 80) @ (font height * 25) |
|
227 |
||
228 |
"Modified: / 19-07-1996 / 20:43:32 / cg" |
|
229 |
"Created: / 25-11-2010 / 12:51:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
230 |
! ! |
|
231 |
||
232 |
!XTermView methodsFor:'realization'! |
|
233 |
||
234 |
postRealize |
|
235 |
||
236 |
super postRealize. |
|
237 |
XTermType ~= #rxvt ifTrue:[self sizeChanged: nil] |
|
238 |
||
239 |
"Created: / 25-11-2010 / 11:08:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
240 |
"Modified: / 13-12-2010 / 22:08:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
241 |
! |
|
242 |
||
243 |
preRealize |
|
244 |
super preRealize. |
|
245 |
clientViewId isNil ifTrue:[ |
|
246 |
pid := OperatingSystem |
|
247 |
exec:self xtermExecutable |
|
248 |
withArguments:self xtermArgs |
|
249 |
fork:true |
|
250 |
inDirectory: wd. |
|
251 |
] |
|
252 |
||
253 |
"Created: / 25-11-2010 / 10:51:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
254 |
"Modified: / 02-06-2011 / 23:27:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
255 |
! ! |
|
256 |
||
10704
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
257 |
!XTermView methodsFor:'testing'! |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
258 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
259 |
isTextView |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
260 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
261 |
^false |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
262 |
|
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
263 |
"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
|
264 |
! ! |
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
265 |
|
10263 | 266 |
!XTermView class methodsFor:'documentation'! |
267 |
||
268 |
version_CVS |
|
10704
015027d5c1a2
added: #isTextView (sent by recent WorkspaceApplication)
vrany
parents:
10263
diff
changeset
|
269 |
^ '$Header: /cvs/stx/stx/libtool/XTermView.st,v 1.2 2011-09-13 10:24:04 vrany Exp $' |
10263 | 270 |
! |
271 |
||
272 |
version_SVN |
|
273 |
^ '§Id: XTermView.st 7802 2011-07-05 18:33:36Z vranyj1 §' |
|
274 |
! ! |
|
275 |
||
276 |
XTermView initialize! |