Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7f776a

Browse files
committed
Suite to talk to the OSX Terminal application.
1 parent ad5dcaf commit e7f776a

2 files changed

Lines changed: 345 additions & 0 deletions

File tree

Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
"""Suite Terminal Suite: Terms and Events for controlling the Terminal application
2+
Level 1, version 1
3+
4+
Generated from /Applications/Utilities/Terminal.app/Contents/Resources/Terminal.rsrc
5+
AETE/AEUT resource version 1/0, language 0, script 0
6+
"""
7+
8+
import aetools
9+
import MacOS
10+
11+
_code = 'trmx'
12+
13+
class Terminal_Suite_Events:
14+
15+
def run(self, _no_object=None, _attributes={}, **_arguments):
16+
"""run: Run the Terminal application
17+
Keyword argument _attributes: AppleEvent attribute dictionary
18+
"""
19+
_code = 'core'
20+
_subcode = 'oapp'
21+
22+
if _arguments: raise TypeError, 'No optional args expected'
23+
if _no_object != None: raise TypeError, 'No direct arg expected'
24+
25+
26+
_reply, _arguments, _attributes = self.send(_code, _subcode,
27+
_arguments, _attributes)
28+
if _arguments.has_key('errn'):
29+
raise aetools.Error, aetools.decodeerror(_arguments)
30+
# XXXX Optionally decode result
31+
if _arguments.has_key('----'):
32+
return _arguments['----']
33+
34+
def quit(self, _no_object=None, _attributes={}, **_arguments):
35+
"""quit: Quit the Terminal application
36+
Keyword argument _attributes: AppleEvent attribute dictionary
37+
"""
38+
_code = 'core'
39+
_subcode = 'quit'
40+
41+
if _arguments: raise TypeError, 'No optional args expected'
42+
if _no_object != None: raise TypeError, 'No direct arg expected'
43+
44+
45+
_reply, _arguments, _attributes = self.send(_code, _subcode,
46+
_arguments, _attributes)
47+
if _arguments.has_key('errn'):
48+
raise aetools.Error, aetools.decodeerror(_arguments)
49+
# XXXX Optionally decode result
50+
if _arguments.has_key('----'):
51+
return _arguments['----']
52+
53+
def count(self, _object=None, _attributes={}, **_arguments):
54+
"""count: Return the number of elements of a particular class within an object
55+
Required argument: a reference to the objects to be counted
56+
Keyword argument _attributes: AppleEvent attribute dictionary
57+
Returns: the number of objects counted
58+
"""
59+
_code = 'core'
60+
_subcode = 'cnte'
61+
62+
if _arguments: raise TypeError, 'No optional args expected'
63+
_arguments['----'] = _object
64+
65+
66+
_reply, _arguments, _attributes = self.send(_code, _subcode,
67+
_arguments, _attributes)
68+
if _arguments.has_key('errn'):
69+
raise aetools.Error, aetools.decodeerror(_arguments)
70+
# XXXX Optionally decode result
71+
if _arguments.has_key('----'):
72+
return _arguments['----']
73+
74+
_argmap_do_script = {
75+
'with_command' : 'cmnd',
76+
}
77+
78+
def do_script(self, _no_object=None, _attributes={}, **_arguments):
79+
"""do script: Run a UNIX shell script or command
80+
Keyword argument with_command: data to be passed to the Terminal application as the command line
81+
Keyword argument _attributes: AppleEvent attribute dictionary
82+
"""
83+
_code = 'core'
84+
_subcode = 'dosc'
85+
86+
aetools.keysubst(_arguments, self._argmap_do_script)
87+
if _no_object != None: raise TypeError, 'No direct arg expected'
88+
89+
90+
_reply, _arguments, _attributes = self.send(_code, _subcode,
91+
_arguments, _attributes)
92+
if _arguments.has_key('errn'):
93+
raise aetools.Error, aetools.decodeerror(_arguments)
94+
# XXXX Optionally decode result
95+
if _arguments.has_key('----'):
96+
return _arguments['----']
97+
98+
99+
class application(aetools.ComponentItem):
100+
"""application - The Terminal program """
101+
want = 'capp'
102+
class name(aetools.NProperty):
103+
"""name - the name of the application """
104+
which = 'pnam'
105+
want = 'TEXT'
106+
class version(aetools.NProperty):
107+
"""version - the version of the application """
108+
which = 'vers'
109+
want = 'vers'
110+
class frontmost(aetools.NProperty):
111+
"""frontmost - Is this the active application? """
112+
which = 'pisf'
113+
want = 'bool'
114+
# element 'cwin' as ['name', 'indx']
115+
116+
applications = application
117+
118+
class window(aetools.ComponentItem):
119+
"""window - A Terminal window """
120+
want = 'cwin'
121+
class index(aetools.NProperty):
122+
"""index - the number of the window """
123+
which = 'pidx'
124+
want = 'long'
125+
class visible(aetools.NProperty):
126+
"""visible - Is the window visible? """
127+
which = 'pvis'
128+
want = 'bool'
129+
class has_close_box(aetools.NProperty):
130+
"""has close box - Does the window have a close box? """
131+
which = 'hclb'
132+
want = 'bool'
133+
class has_title_bar(aetools.NProperty):
134+
"""has title bar - Does the window have a title bar? """
135+
which = 'ptit'
136+
want = 'bool'
137+
class floating(aetools.NProperty):
138+
"""floating - Does the window float? """
139+
which = 'isfl'
140+
want = 'bool'
141+
class modal(aetools.NProperty):
142+
"""modal - Is the window modal? """
143+
which = 'pmod'
144+
want = 'bool'
145+
class resizable(aetools.NProperty):
146+
"""resizable - Is the window resizable? """
147+
which = 'prsz'
148+
want = 'bool'
149+
class zoomable(aetools.NProperty):
150+
"""zoomable - Is the window zoomable? """
151+
which = 'iszm'
152+
want = 'bool'
153+
class zoomed(aetools.NProperty):
154+
"""zoomed - Is the window zoomed? """
155+
which = 'pzum'
156+
want = 'bool'
157+
class miniaturizable(aetools.NProperty):
158+
"""miniaturizable - Is the window miniaturizable? """
159+
which = 'mini'
160+
want = 'bool'
161+
class miniaturized(aetools.NProperty):
162+
"""miniaturized - Is the window miniaturized? """
163+
which = 'mina'
164+
want = 'bool'
165+
class position(aetools.NProperty):
166+
"""position - the upper left coordinates of window """
167+
which = 'ppos'
168+
want = 'QDpt'
169+
class bounds(aetools.NProperty):
170+
"""bounds - the boundary rectangle for the window """
171+
which = 'pbnd'
172+
want = 'qdrt'
173+
class title_displays_device_name(aetools.NProperty):
174+
"""title displays device name - Does the title for the window contain the device name? """
175+
which = 'tddn'
176+
want = 'bool'
177+
class title_displays_shell_path(aetools.NProperty):
178+
"""title displays shell path - Does the title for the window contain the shell path? """
179+
which = 'tdsp'
180+
want = 'bool'
181+
class title_displays_window_size(aetools.NProperty):
182+
"""title displays window size - Does the title for the window contain the window size? """
183+
which = 'tdws'
184+
want = 'bool'
185+
class title_displays_file_name(aetools.NProperty):
186+
"""title displays file name - Does the title for the window contain the file name? """
187+
which = 'tdfn'
188+
want = 'bool'
189+
class title_displays_custom_title(aetools.NProperty):
190+
"""title displays custom title - Does the title for the window contain a custom title? """
191+
which = 'tdct'
192+
want = 'bool'
193+
class custom_title(aetools.NProperty):
194+
"""custom title - the custom title for the window """
195+
which = 'titl'
196+
want = 'TEXT'
197+
class contents(aetools.NProperty):
198+
"""contents - the currently visible contents of the window """
199+
which = 'pcnt'
200+
want = 'TEXT'
201+
class history(aetools.NProperty):
202+
"""history - the contents of the entire scrolling buffer of the window """
203+
which = 'hist'
204+
want = 'TEXT'
205+
class number_of_rows(aetools.NProperty):
206+
"""number of rows - the number of rows in the window """
207+
which = 'crow'
208+
want = 'long'
209+
class number_of_columns(aetools.NProperty):
210+
"""number of columns - the number of columns in the window """
211+
which = 'ccol'
212+
want = 'long'
213+
class cursor_color(aetools.NProperty):
214+
"""cursor color - the cursor color for the window """
215+
which = 'pcuc'
216+
want = 'TEXT'
217+
class background_color(aetools.NProperty):
218+
"""background color - the background color for the window """
219+
which = 'pbcl'
220+
want = 'TEXT'
221+
class normal_text_color(aetools.NProperty):
222+
"""normal text color - the normal text color for the window """
223+
which = 'ptxc'
224+
want = 'TEXT'
225+
class bold_text_color(aetools.NProperty):
226+
"""bold text color - the bold text color for the window """
227+
which = 'pbtc'
228+
want = 'TEXT'
229+
230+
windows = window
231+
application._propdict = {
232+
'name' : name,
233+
'version' : version,
234+
'frontmost' : frontmost,
235+
}
236+
application._elemdict = {
237+
'window' : window,
238+
}
239+
window._propdict = {
240+
'name' : name,
241+
'index' : index,
242+
'visible' : visible,
243+
'has_close_box' : has_close_box,
244+
'has_title_bar' : has_title_bar,
245+
'floating' : floating,
246+
'modal' : modal,
247+
'resizable' : resizable,
248+
'zoomable' : zoomable,
249+
'zoomed' : zoomed,
250+
'miniaturizable' : miniaturizable,
251+
'miniaturized' : miniaturized,
252+
'position' : position,
253+
'bounds' : bounds,
254+
'title_displays_device_name' : title_displays_device_name,
255+
'title_displays_shell_path' : title_displays_shell_path,
256+
'title_displays_window_size' : title_displays_window_size,
257+
'title_displays_file_name' : title_displays_file_name,
258+
'title_displays_custom_title' : title_displays_custom_title,
259+
'custom_title' : custom_title,
260+
'contents' : contents,
261+
'history' : history,
262+
'number_of_rows' : number_of_rows,
263+
'number_of_columns' : number_of_columns,
264+
'cursor_color' : cursor_color,
265+
'background_color' : background_color,
266+
'normal_text_color' : normal_text_color,
267+
'bold_text_color' : bold_text_color,
268+
}
269+
window._elemdict = {
270+
}
271+
272+
#
273+
# Indices of types declared in this module
274+
#
275+
_classdeclarations = {
276+
'cwin' : window,
277+
'capp' : application,
278+
}
279+
280+
_propdeclarations = {
281+
'tdfn' : title_displays_file_name,
282+
'mini' : miniaturizable,
283+
'vers' : version,
284+
'pidx' : index,
285+
'prsz' : resizable,
286+
'pbnd' : bounds,
287+
'mina' : miniaturized,
288+
'pbcl' : background_color,
289+
'tddn' : title_displays_device_name,
290+
'iszm' : zoomable,
291+
'hclb' : has_close_box,
292+
'isfl' : floating,
293+
'pcnt' : contents,
294+
'ppos' : position,
295+
'ptxc' : normal_text_color,
296+
'pcuc' : cursor_color,
297+
'tdsp' : title_displays_shell_path,
298+
'pvis' : visible,
299+
'tdct' : title_displays_custom_title,
300+
'pmod' : modal,
301+
'titl' : custom_title,
302+
'pisf' : frontmost,
303+
'hist' : history,
304+
'pzum' : zoomed,
305+
'crow' : number_of_rows,
306+
'pnam' : name,
307+
'ccol' : number_of_columns,
308+
'tdws' : title_displays_window_size,
309+
'pbtc' : bold_text_color,
310+
'ptit' : has_title_bar,
311+
}
312+
313+
_compdeclarations = {
314+
}
315+
316+
_enumdeclarations = {
317+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Package generated from /Applications/Utilities/Terminal.app/Contents/Resources/Terminal.rsrc
3+
Resource aete resid 0 Terminal Terminology
4+
"""
5+
# Note: hand-edited _signature to 'trmx'.
6+
7+
import aetools
8+
Error = aetools.Error
9+
import Terminal_Suite
10+
11+
12+
_code_to_module = {
13+
'trmx' : Terminal_Suite,
14+
}
15+
16+
17+
18+
_code_to_fullname = {
19+
'trmx' : ('Terminal.Terminal_Suite', 'Terminal_Suite'),
20+
}
21+
22+
from Terminal_Suite import *
23+
24+
25+
class Terminal(Terminal_Suite_Events,
26+
aetools.TalkTo):
27+
_signature = 'trmx'
28+

0 commit comments

Comments
 (0)