author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 24 Jul 2013 11:15:26 +0100 | |
branch | jv |
changeset 13250 | 0decde6c459d |
parent 13182 | bc686a7cc736 |
parent 13214 | 7727357e3c6f |
child 13289 | cc75e3cd0362 |
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 |
||
13214 | 105 |
|
5296 | 106 |
" |
13214 | 107 |
MenuEditor new openOnClass:TerminalApplication andSelector:#mainMenu |
108 |
(Menu new fromLiteralArrayEncoding:(TerminalApplication mainMenu)) startUp |
|
5296 | 109 |
" |
110 |
||
111 |
<resource: #menu> |
|
112 |
||
113 |
^ |
|
13214 | 114 |
#(Menu |
115 |
( |
|
116 |
(MenuItem |
|
117 |
label: 'File' |
|
118 |
submenu: |
|
119 |
(Menu |
|
120 |
( |
|
121 |
(MenuItem |
|
122 |
label: 'New Shell' |
|
123 |
itemValue: newWorkspace |
|
5296 | 124 |
) |
13214 | 125 |
(MenuItem |
126 |
label: '-' |
|
127 |
) |
|
128 |
(MenuItem |
|
129 |
label: 'Playback File...' |
|
130 |
itemValue: menuPlayback |
|
5296 | 131 |
) |
13214 | 132 |
(MenuItem |
133 |
label: '-' |
|
134 |
) |
|
135 |
(MenuItem |
|
136 |
label: 'Save As...' |
|
137 |
itemValue: menuSaveAs |
|
5296 | 138 |
) |
13214 | 139 |
(MenuItem |
140 |
enabled: hasMultipleBuffersHolder |
|
141 |
label: 'Save all As...' |
|
142 |
itemValue: menuSaveAllAs |
|
5296 | 143 |
) |
13214 | 144 |
(MenuItem |
145 |
label: '-' |
|
146 |
) |
|
147 |
(MenuItem |
|
148 |
label: 'Exit' |
|
149 |
itemValue: closeRequest |
|
5296 | 150 |
) |
13214 | 151 |
) |
152 |
nil |
|
153 |
nil |
|
154 |
) |
|
155 |
) |
|
156 |
(MenuItem |
|
157 |
label: 'View' |
|
158 |
submenu: |
|
159 |
(Menu |
|
160 |
( |
|
161 |
(MenuItem |
|
162 |
label: 'Normal' |
|
163 |
itemValue: setNormalDisplayMode |
|
5296 | 164 |
) |
13214 | 165 |
(MenuItem |
166 |
label: 'Reverse' |
|
167 |
itemValue: setReverseDisplayMode |
|
5296 | 168 |
) |
13214 | 169 |
(MenuItem |
170 |
label: 'Green' |
|
171 |
itemValue: setGreenDisplayMode |
|
5296 | 172 |
) |
173 |
) |
|
174 |
nil |
|
175 |
nil |
|
176 |
) |
|
177 |
) |
|
13214 | 178 |
(MenuItem |
179 |
label: 'Buffers' |
|
180 |
nameKey: Buffer |
|
181 |
submenu: |
|
182 |
(Menu |
|
183 |
( |
|
184 |
(MenuItem |
|
185 |
label: 'Add Buffer' |
|
186 |
itemValue: addWorkspace |
|
5296 | 187 |
) |
13214 | 188 |
(MenuItem |
189 |
label: 'Rename...' |
|
190 |
itemValue: renameWorkspace |
|
5296 | 191 |
) |
13214 | 192 |
(MenuItem |
193 |
label: '-' |
|
5296 | 194 |
) |
13214 | 195 |
(MenuItem |
196 |
enabled: canRemoveWorkspace |
|
197 |
label: 'Remove Buffer' |
|
198 |
itemValue: removeWorkspace |
|
5296 | 199 |
) |
200 |
) |
|
201 |
nil |
|
202 |
nil |
|
203 |
) |
|
204 |
) |
|
13214 | 205 |
(MenuItem |
206 |
label: 'Edit' |
|
207 |
submenu: |
|
208 |
(Menu |
|
209 |
( |
|
210 |
(MenuItem |
|
211 |
enabled: hasSelectionInActiveWorkspace |
|
212 |
label: 'Copy' |
|
213 |
itemValue: copySelection |
|
5296 | 214 |
) |
13214 | 215 |
(MenuItem |
216 |
label: 'Paste' |
|
217 |
itemValue: paste |
|
5296 | 218 |
) |
13214 | 219 |
(MenuItem |
220 |
label: '-' |
|
5296 | 221 |
) |
13214 | 222 |
(MenuItem |
223 |
label: 'Select All' |
|
224 |
itemValue: selectAll |
|
5296 | 225 |
) |
226 |
) |
|
227 |
nil |
|
228 |
nil |
|
229 |
) |
|
230 |
) |
|
13214 | 231 |
(MenuItem |
232 |
label: 'Shell' |
|
233 |
submenu: |
|
234 |
(Menu |
|
235 |
( |
|
236 |
(MenuItem |
|
237 |
label: 'Interrupt' |
|
238 |
itemValue: doSendInterrupt |
|
5296 | 239 |
) |
13214 | 240 |
(MenuItem |
241 |
label: 'Kill' |
|
242 |
itemValue: doSendKillSignal |
|
5296 | 243 |
) |
13214 | 244 |
(MenuItem |
245 |
label: '-' |
|
5296 | 246 |
) |
13214 | 247 |
(MenuItem |
248 |
label: 'Reset Terminal' |
|
249 |
itemValue: doReset |
|
5296 | 250 |
) |
251 |
) |
|
252 |
nil |
|
253 |
nil |
|
254 |
) |
|
255 |
) |
|
13214 | 256 |
(MenuItem |
257 |
label: 'Help' |
|
258 |
startGroup: right |
|
259 |
submenu: |
|
260 |
(Menu |
|
261 |
( |
|
262 |
(MenuItem |
|
263 |
label: 'Documentation' |
|
264 |
itemValue: openDocumentation |
|
5296 | 265 |
) |
13214 | 266 |
(MenuItem |
267 |
label: '-' |
|
5296 | 268 |
) |
13214 | 269 |
(MenuItem |
270 |
label: 'About this Application...' |
|
271 |
itemValue: openAboutThisApplication |
|
5296 | 272 |
) |
273 |
) |
|
274 |
nil |
|
275 |
nil |
|
276 |
) |
|
277 |
) |
|
278 |
) |
|
279 |
nil |
|
280 |
nil |
|
281 |
) |
|
282 |
! |
|
283 |
||
284 |
tabMenu |
|
285 |
"This resource specification was automatically generated |
|
286 |
by the MenuEditor of ST/X." |
|
287 |
||
288 |
"Do not manually edit this!! If it is corrupted, |
|
289 |
the MenuEditor may not be able to read the specification." |
|
290 |
||
291 |
" |
|
292 |
MenuEditor new openOnClass:WorkspaceApplication andSelector:#tabMenu |
|
293 |
(Menu new fromLiteralArrayEncoding:(WorkspaceApplication tabMenu)) startUp |
|
294 |
" |
|
295 |
||
296 |
<resource: #menu> |
|
297 |
||
298 |
^ |
|
299 |
#(#Menu |
|
300 |
#( |
|
301 |
#(#MenuItem |
|
302 |
#label: 'Add Buffer' |
|
303 |
#translateLabel: true |
|
304 |
"/ #triggerOnDown: true |
|
305 |
#value: #addWorkspace |
|
306 |
) |
|
307 |
#(#MenuItem |
|
308 |
#label: 'Rename...' |
|
309 |
#translateLabel: true |
|
310 |
"/ #triggerOnDown: true |
|
311 |
#value: #renameWorkspace: |
|
312 |
) |
|
313 |
#(#MenuItem |
|
314 |
#label: '-' |
|
315 |
) |
|
316 |
#(#MenuItem |
|
317 |
#label: 'Remove Buffer' |
|
318 |
#translateLabel: true |
|
319 |
"/ #triggerOnDown: true |
|
320 |
#value: #removeWorkspace: |
|
321 |
#enabled: #canRemoveWorkspace: |
|
322 |
) |
|
323 |
) |
|
324 |
nil |
|
325 |
nil |
|
326 |
) |
|
327 |
! ! |
|
328 |
||
329 |
!TerminalApplication class methodsFor:'special startup'! |
|
330 |
||
5300 | 331 |
openIn:aDirectory |
332 |
"launch a new terminal in some directory" |
|
333 |
||
334 |
|terminal| |
|
5296 | 335 |
|
5300 | 336 |
terminal := self new. |
337 |
terminal initialDirectory:aDirectory. |
|
338 |
terminal open. |
|
339 |
^ terminal |
|
5296 | 340 |
|
341 |
" |
|
5300 | 342 |
TerminalApplication open |
343 |
TerminalApplication openIn:'/etc' |
|
5296 | 344 |
" |
345 |
! ! |
|
346 |
||
347 |
!TerminalApplication methodsFor:'menu-actions'! |
|
348 |
||
349 |
addWorkspace |
|
350 |
self addWindow:(self createWorkspace) named:'Terminal%1' |
|
351 |
! |
|
352 |
||
353 |
createWorkspace |
|
354 |
|scr| |
|
355 |
||
10937 | 356 |
"/ JV@2011-11-30: XTermView disabled as recent changes in |
357 |
"/ #startShellInSelectedWindow leads to infinite loop. |
|
358 |
"/ further investigation needed. |
|
9812 | 359 |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
360 |
(OperatingSystem isUNIXlike and:[XTermView notNil]) ifTrue:[ |
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
361 |
scr := XTermView new. |
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
362 |
scr workingDirectory: initialDirectory. |
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
363 |
] ifFalse:[ |
10937 | 364 |
VT100TerminalView isNil ifTrue:[ |
365 |
self error:'missing: VT100TerminalView' |
|
366 |
]. |
|
10253 | 367 |
scr := (HVScrollableView for:VT100TerminalView). |
368 |
scr autoHideScrollBars:false. |
|
369 |
scr horizontalMini:true. |
|
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
370 |
]. |
10253 | 371 |
|
5296 | 372 |
self window realized ifTrue:[ |
373 |
self window sensor pushUserEvent:#startShellInSelectedWindow for:self. |
|
374 |
]. |
|
375 |
^ scr |
|
9812 | 376 |
|
377 |
"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
|
378 |
"Modified: / 03-04-2012 / 10:19:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5296 | 379 |
! |
380 |
||
381 |
doKill |
|
382 |
self selectedWorkspacesTextView doKill. |
|
383 |
! |
|
384 |
||
385 |
doReset |
|
386 |
self selectedWorkspacesTextView doReset. |
|
387 |
! |
|
388 |
||
389 |
doSendInterrupt |
|
390 |
self selectedWorkspacesTextView doSendInterrupt. |
|
391 |
! |
|
392 |
||
393 |
doSendKillSignal |
|
394 |
self selectedWorkspacesTextView doSendKillSignal. |
|
395 |
! |
|
396 |
||
397 |
menuPlayback |
|
398 |
|file suff| |
|
399 |
||
400 |
suff := 'sh'. |
|
401 |
||
402 |
OperatingSystem isMSDOSlike ifTrue:[ suff := 'bat' ]. |
|
403 |
file := Dialog requestFileName:'Playback file' default:('file.',suff) pattern:('*.',suff). |
|
404 |
file size > 0 ifTrue:[ |
|
405 |
self playbackFile:file |
|
406 |
] |
|
407 |
! |
|
408 |
||
409 |
openDocumentation |
|
410 |
"opens the documentation file" |
|
411 |
||
5351 | 412 |
self openHTMLDocument: 'tools/misc/TOP.html#TERMINAL' |
5296 | 413 |
! |
414 |
||
415 |
playbackFile:aFileName |
|
416 |
|file ws| |
|
417 |
||
418 |
file := aFileName asFilename. |
|
419 |
file exists ifFalse:[ |
|
420 |
Dialog warn:(resources string:'File %1 does not exist.' with:file asString). |
|
421 |
^ self |
|
422 |
]. |
|
423 |
||
424 |
ws := self selectedWorkspacesTextView. |
|
425 |
file readingLinesDo:[:eachLine | ws sendLine:eachLine] |
|
426 |
. |
|
13214 | 427 |
! |
428 |
||
429 |
setGreenDisplayMode |
|
430 |
self selectedWorkspacesTextView setGreenDisplayMode. |
|
431 |
! |
|
432 |
||
433 |
setNormalDisplayMode |
|
434 |
self selectedWorkspacesTextView setNormalDisplayMode. |
|
435 |
! |
|
436 |
||
437 |
setReverseDisplayMode |
|
438 |
self selectedWorkspacesTextView setReverseDisplayMode. |
|
5296 | 439 |
! ! |
440 |
||
441 |
!TerminalApplication methodsFor:'private'! |
|
442 |
||
443 |
isModifiedWorkspace:aView |
|
444 |
^ false |
|
445 |
! ! |
|
446 |
||
447 |
!TerminalApplication methodsFor:'startup'! |
|
448 |
||
5300 | 449 |
initialDirectory:aDirectory |
450 |
initialDirectory := aDirectory |
|
451 |
! |
|
452 |
||
5299 | 453 |
postBuildWith:aBuilder |
454 |
|w h| |
|
455 |
||
456 |
super postBuildWith:aBuilder. |
|
457 |
||
458 |
w := self window width max:(workspaces first preferredExtent x). |
|
459 |
h := builder menuBar height + (workspaces first preferredExtent y). |
|
460 |
self window extent:(w@h). |
|
461 |
! |
|
462 |
||
5296 | 463 |
postOpenWith:aBuilder |
464 |
self startShellInSelectedWindow. |
|
465 |
super postOpenWith:aBuilder |
|
466 |
! |
|
467 |
||
5305 | 468 |
shellFinishedInWorkspace:aView |
469 |
"/ vt backgroundColor:(Color red). |
|
470 |
aView |
|
471 |
cr; |
|
472 |
nextPutLine:('>> shell terminated.' asText allBold colorizeAllWith:Color red). |
|
473 |
! |
|
474 |
||
5296 | 475 |
startShellInSelectedWindow |
476 |
|vt| |
|
477 |
||
478 |
vt := self selectedWorkspacesTextView. |
|
9812 | 479 |
(vt notNil and:[vt superView realized]) ifFalse:[ |
5296 | 480 |
self window sensor pushUserEvent:#startShellInSelectedWindow for:self. |
481 |
^ self. |
|
482 |
]. |
|
483 |
||
5300 | 484 |
vt startShellIn:initialDirectory. |
5305 | 485 |
vt shellTerminateAction:[self shellFinishedInWorkspace:vt]. |
13135 | 486 |
vt masterWindow:(self window). "/ to change window title |
9812 | 487 |
|
488 |
"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
|
489 |
"Modified: / 03-04-2012 / 10:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5296 | 490 |
! ! |
491 |
||
492 |
!TerminalApplication class methodsFor:'documentation'! |
|
493 |
||
9812 | 494 |
version_CVS |
13214 | 495 |
^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.13 2013-07-23 21:08:55 cg Exp $' |
12144 | 496 |
! |
497 |
||
12650
e0f607754b9a
Merged 18d06283743d and ff31bac2fd1b (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12216
diff
changeset
|
498 |
version_HG |
e0f607754b9a
Merged 18d06283743d and ff31bac2fd1b (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12216
diff
changeset
|
499 |
|
e0f607754b9a
Merged 18d06283743d and ff31bac2fd1b (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12216
diff
changeset
|
500 |
^ '$Changeset: <not expanded> $' |
e0f607754b9a
Merged 18d06283743d and ff31bac2fd1b (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12216
diff
changeset
|
501 |
! |
e0f607754b9a
Merged 18d06283743d and ff31bac2fd1b (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12216
diff
changeset
|
502 |
|
12144 | 503 |
version_SVN |
12216
5698c277f043
- Improvements in FileBrowserV2/V3
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12201
diff
changeset
|
504 |
^ '$Id: TerminalApplication.st 7963 2012-04-03 12:32:03Z vranyj1 $' |
5296 | 505 |
! ! |
13135 | 506 |