1717import mactwit_browser
1818import mactwit_edit
1919import macfs
20+ import string
2021
2122# Resource-id (for checking existence)
2223ID_MODULES = 512
@@ -37,6 +38,7 @@ def __init__(self, sessiontype, arg=None):
3738 AE .AESetInteractionAllowed (AppleEvents .kAEInteractWithAll )
3839 self .installaehandler ('aevt' , 'odoc' , self .ae_open_doc )
3940 self .installaehandler ('aevt' , 'quit' , self .do_quit )
41+ self .installaehandler ('pyth' , 'EXEC' , self .do_bbpyexec ) # BBpy execute event
4042
4143 self .dbg_menu_bar = Menu .GetMenuBar ()
4244 self .setstate (sessiontype )
@@ -175,6 +177,19 @@ def ae_open_doc(self, object=None, **args):
175177 fss , changed = object .Resolve ()
176178 self .runfile (fss .as_pathname ())
177179
180+ def do_bbpyexec (self , object = None , NAME = None , ** args ):
181+ if type (object ) <> type ('' ):
182+ if AE .AEInteractWithUser (AppleEvents .kAEDefaultTimeout ) == 0 :
183+ EasyDialogs .Message ('EXEC AppleEvent arg should be a string' )
184+ return
185+ if self .state <> 'none' :
186+ if AE .AEInteractWithUser (AppleEvents .kAEDefaultTimeout ) == 0 :
187+ if not self .asknewsession ():
188+ return
189+ stuff = string .splitfields (object , '\r ' )
190+ stuff = string .joinfields (stuff , '\n ' )
191+ self .runstring (stuff )
192+
178193 def do_run (self , * args ):
179194 if not self .asknewsession ():
180195 return
0 commit comments