author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 03 Apr 2012 13:32:03 +0100 | |
branch | jv |
changeset 12216 | 5698c277f043 |
parent 12201 | 283826cb8bcc |
child 12650 | e0f607754b9a |
permissions | -rw-r--r-- |
5296 | 1 |
" |
2 |
COPYRIGHT (c) 2001 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 |
||
5305 | 14 |
MultiViewToolApplication subclass:#TerminalApplication |
5300 | 15 |
instanceVariableNames:'initialDirectory' |
5296 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Smalltalk' |
|
19 |
! |
|
20 |
||
21 |
!TerminalApplication class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2001 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 |
documentation |
|
38 |
" |
|
5297 | 39 |
A simple wrapper around a Terminal-View, adding a pullDown menu. |
5296 | 40 |
|
41 |
[author:] |
|
42 |
Claus Gittinger |
|
43 |
" |
|
44 |
! ! |
|
45 |
||
46 |
!TerminalApplication class methodsFor:'interface specs'! |
|
47 |
||
48 |
windowSpec |
|
49 |
"This resource specification was automatically generated |
|
50 |
by the UIPainter of ST/X." |
|
51 |
||
52 |
"Do not manually edit this!! If it is corrupted, |
|
53 |
the UIPainter may not be able to read the specification." |
|
54 |
||
55 |
" |
|
56 |
UIPainter new openOnClass:TerminalApplication andSelector:#windowSpec |
|
57 |
TerminalApplication new openInterface:#windowSpec |
|
58 |
TerminalApplication open |
|
59 |
" |
|
60 |
||
61 |
<resource: #canvas> |
|
62 |
||
63 |
^ |
|
64 |
#(#FullSpec |
|
65 |
#name: #windowSpec |
|
66 |
#window: |
|
67 |
#(#WindowSpec |
|
68 |
#label: 'Terminal' |
|
69 |
#name: 'Terminal' |
|
70 |
#min: #(#Point 10 10) |
|
71 |
#bounds: #(#Rectangle 13 23 445 264) |
|
72 |
#menu: #mainMenu |
|
73 |
) |
|
74 |
#component: |
|
75 |
#(#SpecCollection |
|
76 |
#collection: #( |
|
77 |
#(#NoteBookViewSpec |
|
78 |
#name: 'NoteBook1' |
|
79 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
80 |
#model: #selectedWorkspaceIndexHolder |
|
81 |
#menu: #tabList |
|
82 |
#useIndex: true |
|
83 |
#accessTabMenuAction: #tabMenuAt: |
|
84 |
#canvas: #workspaceHolder |
|
85 |
#canvasInset: 0 |
|
86 |
#canvasFrameLevel: 0 |
|
87 |
#keepCanvasAlive: true |
|
88 |
#tabLevel: 1 |
|
89 |
) |
|
90 |
) |
|
91 |
||
92 |
) |
|
93 |
) |
|
94 |
! ! |
|
95 |
||
96 |
!TerminalApplication class methodsFor:'menu specs'! |
|
97 |
||
98 |
mainMenu |
|
99 |
"This resource specification was automatically generated |
|
100 |
by the MenuEditor of ST/X." |
|
101 |
||
102 |
"Do not manually edit this!! If it is corrupted, |
|
103 |
the MenuEditor may not be able to read the specification." |
|
104 |
||
105 |
" |
|
106 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#mainMenu |
|
107 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication mainMenu)) startUp |
|
108 |
" |
|
109 |
||
110 |
<resource: #menu> |
|
111 |
||
112 |
^ |
|
113 |
#(#Menu |
|
114 |
#( |
|
115 |
#(#MenuItem |
|
116 |
#label: 'File' |
|
117 |
#translateLabel: true |
|
118 |
#submenu: |
|
119 |
#(#Menu |
|
120 |
#( |
|
121 |
#(#MenuItem |
|
122 |
#label: 'New Shell' |
|
123 |
#itemValue: #newWorkspace |
|
124 |
#translateLabel: true |
|
125 |
) |
|
126 |
#(#MenuItem |
|
127 |
#label: '-' |
|
128 |
) |
|
129 |
#(#MenuItem |
|
130 |
#label: 'Playback File...' |
|
131 |
#itemValue: #menuPlayback |
|
132 |
#translateLabel: true |
|
133 |
) |
|
134 |
#(#MenuItem |
|
135 |
#label: '-' |
|
136 |
) |
|
137 |
#(#MenuItem |
|
138 |
#label: 'Save As...' |
|
139 |
#itemValue: #menuSaveAs |
|
140 |
#translateLabel: true |
|
141 |
) |
|
142 |
#(#MenuItem |
|
143 |
#enabled: #hasMultipleBuffersHolder |
|
144 |
#label: 'Save all As...' |
|
145 |
#itemValue: #menuSaveAllAs |
|
146 |
#translateLabel: true |
|
147 |
) |
|
148 |
#(#MenuItem |
|
149 |
#label: '-' |
|
150 |
) |
|
151 |
#(#MenuItem |
|
152 |
#label: 'Exit' |
|
153 |
#itemValue: #closeRequest |
|
154 |
#translateLabel: true |
|
155 |
) |
|
156 |
) |
|
157 |
nil |
|
158 |
nil |
|
159 |
) |
|
160 |
) |
|
161 |
#(#MenuItem |
|
162 |
#label: 'Buffers' |
|
163 |
#nameKey: #Buffer |
|
164 |
#translateLabel: true |
|
165 |
#submenu: |
|
166 |
#(#Menu |
|
167 |
#( |
|
168 |
#(#MenuItem |
|
169 |
#label: 'Add Buffer' |
|
170 |
#itemValue: #addWorkspace |
|
171 |
#translateLabel: true |
|
172 |
) |
|
173 |
#(#MenuItem |
|
174 |
#label: 'Rename...' |
|
175 |
#itemValue: #renameWorkspace |
|
176 |
#translateLabel: true |
|
177 |
) |
|
178 |
#(#MenuItem |
|
179 |
#label: '-' |
|
180 |
) |
|
181 |
#(#MenuItem |
|
182 |
#enabled: #canRemoveWorkspace |
|
183 |
#label: 'Remove Buffer' |
|
184 |
#itemValue: #removeWorkspace |
|
185 |
#translateLabel: true |
|
186 |
) |
|
187 |
) |
|
188 |
nil |
|
189 |
nil |
|
190 |
) |
|
191 |
) |
|
192 |
#(#MenuItem |
|
193 |
#label: 'Edit' |
|
194 |
#translateLabel: true |
|
195 |
#submenu: |
|
196 |
#(#Menu |
|
197 |
#( |
|
198 |
#(#MenuItem |
|
199 |
#enabled: #hasSelectionInActiveWorkspace |
|
200 |
#label: 'Copy' |
|
201 |
#itemValue: #copySelection |
|
202 |
#translateLabel: true |
|
203 |
) |
|
204 |
#(#MenuItem |
|
205 |
#label: 'Paste' |
|
206 |
#itemValue: #paste |
|
207 |
#translateLabel: true |
|
208 |
) |
|
209 |
#(#MenuItem |
|
210 |
#label: '-' |
|
211 |
) |
|
212 |
#(#MenuItem |
|
213 |
#label: 'Select All' |
|
214 |
#itemValue: #selectAll |
|
215 |
#translateLabel: true |
|
216 |
) |
|
217 |
) |
|
218 |
nil |
|
219 |
nil |
|
220 |
) |
|
221 |
) |
|
222 |
#(#MenuItem |
|
223 |
#label: 'Shell' |
|
224 |
#translateLabel: true |
|
225 |
#submenu: |
|
226 |
#(#Menu |
|
227 |
#( |
|
228 |
#(#MenuItem |
|
229 |
#label: 'Interrupt' |
|
230 |
#itemValue: #doSendInterrupt |
|
231 |
#translateLabel: true |
|
232 |
) |
|
233 |
#(#MenuItem |
|
234 |
#label: 'Kill' |
|
5409 | 235 |
#itemValue: #doSendKillSignal |
5296 | 236 |
#translateLabel: true |
237 |
) |
|
238 |
#(#MenuItem |
|
239 |
#label: '-' |
|
240 |
) |
|
241 |
#(#MenuItem |
|
242 |
#label: 'Reset Terminal' |
|
243 |
#itemValue: #doReset |
|
244 |
#translateLabel: true |
|
245 |
) |
|
246 |
) |
|
247 |
nil |
|
248 |
nil |
|
249 |
) |
|
250 |
) |
|
251 |
#(#MenuItem |
|
252 |
#label: 'Help' |
|
253 |
#translateLabel: true |
|
254 |
#startGroup: #right |
|
255 |
#submenu: |
|
256 |
#(#Menu |
|
257 |
#( |
|
258 |
#(#MenuItem |
|
259 |
#label: 'Documentation' |
|
260 |
#itemValue: #openDocumentation |
|
261 |
#translateLabel: true |
|
262 |
) |
|
263 |
#(#MenuItem |
|
264 |
#label: '-' |
|
265 |
) |
|
266 |
#(#MenuItem |
|
267 |
#label: 'About this Application...' |
|
268 |
#itemValue: #openAboutThisApplication |
|
269 |
#translateLabel: true |
|
270 |
) |
|
271 |
) |
|
272 |
nil |
|
273 |
nil |
|
274 |
) |
|
275 |
) |
|
276 |
) |
|
277 |
nil |
|
278 |
nil |
|
279 |
) |
|
280 |
! |
|
281 |
||
282 |
tabMenu |
|
283 |
"This resource specification was automatically generated |
|
284 |
by the MenuEditor of ST/X." |
|
285 |
||
286 |
"Do not manually edit this!! If it is corrupted, |
|
287 |
the MenuEditor may not be able to read the specification." |
|
288 |
||
289 |
" |
|
290 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#tabMenu |
|
291 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication tabMenu)) startUp |
|
292 |
" |
|
293 |
||
294 |
<resource: #menu> |
|
295 |
||
296 |
^ |
|
297 |
#(#Menu |
|
298 |
#( |
|
299 |
#(#MenuItem |
|
300 |
#label: 'Add Buffer' |
|
301 |
#translateLabel: true |
|
302 |
"/ #triggerOnDown: true |
|
303 |
#value: #addWorkspace |
|
304 |
) |
|
305 |
#(#MenuItem |
|
306 |
#label: 'Rename...' |
|
307 |
#translateLabel: true |
|
308 |
"/ #triggerOnDown: true |
|
309 |
#value: #renameWorkspace: |
|
310 |
) |
|
311 |
#(#MenuItem |
|
312 |
#label: '-' |
|
313 |
) |
|
314 |
#(#MenuItem |
|
315 |
#label: 'Remove Buffer' |
|
316 |
#translateLabel: true |
|
317 |
"/ #triggerOnDown: true |
|
318 |
#value: #removeWorkspace: |
|
319 |
#enabled: #canRemoveWorkspace: |
|
320 |
) |
|
321 |
) |
|
322 |
nil |
|
323 |
nil |
|
324 |
) |
|
325 |
! ! |
|
326 |
||
327 |
!TerminalApplication class methodsFor:'special startup'! |
|
328 |
||
5300 | 329 |
openIn:aDirectory |
330 |
"launch a new terminal in some directory" |
|
331 |
||
332 |
|terminal| |
|
5296 | 333 |
|
5300 | 334 |
terminal := self new. |
335 |
terminal initialDirectory:aDirectory. |
|
336 |
terminal open. |
|
337 |
^ terminal |
|
5296 | 338 |
|
339 |
" |
|
5300 | 340 |
TerminalApplication open |
341 |
TerminalApplication openIn:'/etc' |
|
5296 | 342 |
" |
343 |
! ! |
|
344 |
||
345 |
!TerminalApplication methodsFor:'menu-actions'! |
|
346 |
||
347 |
addWorkspace |
|
348 |
self addWindow:(self createWorkspace) named:'Terminal%1' |
|
349 |
! |
|
350 |
||
351 |
createWorkspace |
|
352 |
|scr| |
|
353 |
||
12125 | 354 |
"/ JV@2011-11-30: XTermView disabled as recent changes in |
355 |
"/ #startShellInSelectedWindow leads to infinite loop. |
|
356 |
"/ further investigation needed. |
|
9812 | 357 |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
358 |
(OperatingSystem isUNIXlike and:[XTermView notNil]) ifTrue:[ |
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
359 |
scr := XTermView new. |
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
360 |
scr workingDirectory: initialDirectory. |
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
361 |
] ifFalse:[ |
12125 | 362 |
VT100TerminalView isNil ifTrue:[ |
363 |
self error:'missing: VT100TerminalView' |
|
364 |
]. |
|
10253 | 365 |
scr := (HVScrollableView for:VT100TerminalView). |
366 |
scr autoHideScrollBars:false. |
|
367 |
scr horizontalMini:true. |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
368 |
]. |
10253 | 369 |
|
5296 | 370 |
self window realized ifTrue:[ |
371 |
self window sensor pushUserEvent:#startShellInSelectedWindow for:self. |
|
372 |
]. |
|
373 |
^ scr |
|
9812 | 374 |
|
375 |
"Modified: / 08-04-2011 / 14:56:57 / cg" |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
376 |
"Modified: / 03-04-2012 / 10:19:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5296 | 377 |
! |
378 |
||
379 |
doKill |
|
380 |
self selectedWorkspacesTextView doKill. |
|
381 |
! |
|
382 |
||
383 |
doReset |
|
384 |
self selectedWorkspacesTextView doReset. |
|
385 |
! |
|
386 |
||
387 |
doSendInterrupt |
|
388 |
self selectedWorkspacesTextView doSendInterrupt. |
|
389 |
! |
|
390 |
||
391 |
doSendKillSignal |
|
392 |
self selectedWorkspacesTextView doSendKillSignal. |
|
393 |
! |
|
394 |
||
395 |
menuPlayback |
|
396 |
|file suff| |
|
397 |
||
398 |
suff := 'sh'. |
|
399 |
||
400 |
OperatingSystem isMSDOSlike ifTrue:[ suff := 'bat' ]. |
|
401 |
file := Dialog requestFileName:'Playback file' default:('file.',suff) pattern:('*.',suff). |
|
402 |
file size > 0 ifTrue:[ |
|
403 |
self playbackFile:file |
|
404 |
] |
|
405 |
! |
|
406 |
||
407 |
openDocumentation |
|
408 |
"opens the documentation file" |
|
409 |
||
5351 | 410 |
self openHTMLDocument: 'tools/misc/TOP.html#TERMINAL' |
5296 | 411 |
! |
412 |
||
413 |
playbackFile:aFileName |
|
414 |
|file ws| |
|
415 |
||
416 |
file := aFileName asFilename. |
|
417 |
file exists ifFalse:[ |
|
418 |
Dialog warn:(resources string:'File %1 does not exist.' with:file asString). |
|
419 |
^ self |
|
420 |
]. |
|
421 |
||
422 |
ws := self selectedWorkspacesTextView. |
|
423 |
file readingLinesDo:[:eachLine | ws sendLine:eachLine] |
|
424 |
. |
|
425 |
! ! |
|
426 |
||
427 |
!TerminalApplication methodsFor:'private'! |
|
428 |
||
429 |
isModifiedWorkspace:aView |
|
430 |
^ false |
|
431 |
! ! |
|
432 |
||
433 |
!TerminalApplication methodsFor:'startup'! |
|
434 |
||
5300 | 435 |
initialDirectory:aDirectory |
436 |
initialDirectory := aDirectory |
|
437 |
! |
|
438 |
||
5299 | 439 |
postBuildWith:aBuilder |
440 |
|w h| |
|
441 |
||
442 |
super postBuildWith:aBuilder. |
|
443 |
||
444 |
w := self window width max:(workspaces first preferredExtent x). |
|
445 |
h := builder menuBar height + (workspaces first preferredExtent y). |
|
446 |
self window extent:(w@h). |
|
447 |
! |
|
448 |
||
5296 | 449 |
postOpenWith:aBuilder |
450 |
self startShellInSelectedWindow. |
|
451 |
super postOpenWith:aBuilder |
|
452 |
! |
|
453 |
||
5305 | 454 |
shellFinishedInWorkspace:aView |
455 |
"/ vt backgroundColor:(Color red). |
|
456 |
aView |
|
457 |
cr; |
|
458 |
nextPutLine:('>> shell terminated.' asText allBold colorizeAllWith:Color red). |
|
459 |
! |
|
460 |
||
5296 | 461 |
startShellInSelectedWindow |
462 |
|vt| |
|
463 |
||
464 |
vt := self selectedWorkspacesTextView. |
|
9812 | 465 |
(vt notNil and:[vt superView realized]) ifFalse:[ |
5296 | 466 |
self window sensor pushUserEvent:#startShellInSelectedWindow for:self. |
467 |
^ self. |
|
468 |
]. |
|
469 |
||
5300 | 470 |
vt startShellIn:initialDirectory. |
5305 | 471 |
vt shellTerminateAction:[self shellFinishedInWorkspace:vt]. |
9812 | 472 |
|
473 |
"Modified: / 07-04-2011 / 09:03:55 / cg" |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
474 |
"Modified: / 03-04-2012 / 10:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5296 | 475 |
! ! |
476 |
||
477 |
!TerminalApplication class methodsFor:'documentation'! |
|
478 |
||
9812 | 479 |
version_CVS |
12125 | 480 |
^ '§Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.11 2011/11/30 10:06:32 vrany Exp §' |
12144 | 481 |
! |
482 |
||
483 |
version_SVN |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
484 |
^ '$Id: TerminalApplication.st 7963 2012-04-03 12:32:03Z vranyj1 $' |
12125 | 485 |
! ! |