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