summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2003-05-09 11:47:23 (GMT)
committerJust van Rossum <just@letterror.com>2003-05-09 11:47:23 (GMT)
commitba5db205585867d55fc94ca11b43b4fc23c0afeb (patch)
treeba5ed82d0300140f8c937ad32fc5a5b52c93e3eb /Mac
parent505c4c2858aae64e0e3579d710df935d2dfc10f7 (diff)
downloadcpython-ba5db205585867d55fc94ca11b43b4fc23c0afeb.zip
cpython-ba5db205585867d55fc94ca11b43b4fc23c0afeb.tar.gz
cpython-ba5db205585867d55fc94ca11b43b4fc23c0afeb.tar.bz2
also support cmd-. in the interactive window
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Tools/IDE/PyConsole.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/Mac/Tools/IDE/PyConsole.py b/Mac/Tools/IDE/PyConsole.py
index 8d44469..e60b138 100644
--- a/Mac/Tools/IDE/PyConsole.py
+++ b/Mac/Tools/IDE/PyConsole.py
@@ -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')