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