]> granicus.if.org Git - python/commitdiff
also support cmd-. in the interactive window
authorJust van Rossum <just@letterror.com>
Fri, 9 May 2003 11:47:23 +0000 (11:47 +0000)
committerJust van Rossum <just@letterror.com>
Fri, 9 May 2003 11:47:23 +0000 (11:47 +0000)
Mac/Tools/IDE/PyConsole.py

index 8d4446910baaa9e42a47bd15e7618b66f741abd5..e60b138c32b88b7dff64c2bccdfd584d10a804ca 100644 (file)
@@ -78,12 +78,36 @@ class ConsoleTextWidget(W.EditText):
                                text = string.join(string.split(text, "\r"), "\n")
                                if hasattr(MacOS, 'EnableAppswitch'):
                                        saveyield = MacOS.EnableAppswitch(0)
-                               self.pyinteractive.executeline(text, self, self._namespace)
+                               self._scriptDone = False
+                               if sys.platform == "darwin":
+                                       # see identical construct in PyEdit.py
+                                       from threading import Thread
+                                       t = Thread(target=self._userCancelledMonitor,
+                                                       name="UserCancelledMonitor")
+                                       t.start()
+                               try:
+                                       self.pyinteractive.executeline(text, self, self._namespace)
+                               finally:
+                                       self._scriptDone = True
                                if hasattr(MacOS, 'EnableAppswitch'):
                                        MacOS.EnableAppswitch(saveyield)
                                selstart, selend = self.getselection()
                                self._inputstart = selstart
        
+       def _userCancelledMonitor(self):
+               # XXX duplicate code from PyEdit.py
+               import time, os
+               from signal import SIGINT
+               from Carbon import Evt
+               while not self._scriptDone:
+                       if Evt.CheckEventQueueForUserCancel():
+                               # Send a SIGINT signal to ourselves.
+                               # This gets delivered to the main thread,
+                               # cancelling the running script.
+                               os.kill(os.getpid(), SIGINT)
+                               break
+                       time.sleep(0.25)
+       
        def domenu_save_as(self, *args):
                filename = EasyDialogs.AskFileForSave(message='Save console text as:', 
                        savedFileName='console.txt')