[Python-checkins] python/dist/src/Mac/Tools/IDE PyConsole.py,1.16,1.17

jvr@users.sourceforge.net jvr@users.sourceforge.net
Fri, 09 May 2003 04:47:25 -0700


Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE
In directory sc8-pr-cvs1:/tmp/cvs-serv7637

Modified Files:
	PyConsole.py 
Log Message:
also support cmd-. in the interactive window

Index: PyConsole.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyConsole.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** PyConsole.py	6 May 2003 14:28:30 -0000	1.16
--- PyConsole.py	9 May 2003 11:47:23 -0000	1.17
***************
*** 79,87 ****
  				if hasattr(MacOS, 'EnableAppswitch'):
  					saveyield = MacOS.EnableAppswitch(0)
! 				self.pyinteractive.executeline(text, self, self._namespace)
  				if hasattr(MacOS, 'EnableAppswitch'):
  					MacOS.EnableAppswitch(saveyield)
  				selstart, selend = self.getselection()
  				self._inputstart = selstart
  	
  	def domenu_save_as(self, *args):
--- 79,111 ----
  				if hasattr(MacOS, 'EnableAppswitch'):
  					saveyield = MacOS.EnableAppswitch(0)
! 				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):