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