mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Changes by Donovan Preston (and a few minor ones by me) to make IDE run under
MachoPython. Mainly making sure we don't call routines that don't exist and representing pathnames in a os.separator-neutral format. These shouldn't interfere too much with Just's work on the next generation IDE, I hope.
This commit is contained in:
parent
c71efe0116
commit
815d2bf067
8 changed files with 71 additions and 38 deletions
|
@ -75,8 +75,10 @@ class ConsoleTextWidget(W.EditText):
|
||||||
if char == Wkeys.returnkey:
|
if char == Wkeys.returnkey:
|
||||||
text = self.get()[self._inputstart:selstart]
|
text = self.get()[self._inputstart:selstart]
|
||||||
text = string.join(string.split(text, "\r"), "\n")
|
text = string.join(string.split(text, "\r"), "\n")
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
saveyield = MacOS.EnableAppswitch(0)
|
saveyield = MacOS.EnableAppswitch(0)
|
||||||
self.pyinteractive.executeline(text, self, self._namespace)
|
self.pyinteractive.executeline(text, self, self._namespace)
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(saveyield)
|
MacOS.EnableAppswitch(saveyield)
|
||||||
selstart, selend = self.getselection()
|
selstart, selend = self.getselection()
|
||||||
self._inputstart = selstart
|
self._inputstart = selstart
|
||||||
|
@ -275,12 +277,14 @@ class PyOutput:
|
||||||
self.w.bind("<activate>", self.activate)
|
self.w.bind("<activate>", self.activate)
|
||||||
|
|
||||||
def write(self, text):
|
def write(self, text):
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
oldyield = MacOS.EnableAppswitch(-1)
|
oldyield = MacOS.EnableAppswitch(-1)
|
||||||
try:
|
try:
|
||||||
self._buf = self._buf + text
|
self._buf = self._buf + text
|
||||||
if '\n' in self._buf:
|
if '\n' in self._buf:
|
||||||
self.flush()
|
self.flush()
|
||||||
finally:
|
finally:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(oldyield)
|
MacOS.EnableAppswitch(oldyield)
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
|
|
|
@ -496,6 +496,7 @@ class Debugger(bdb.Bdb):
|
||||||
self.w.panes.bottom.tracingmonitor.toggle()
|
self.w.panes.bottom.tracingmonitor.toggle()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(0)
|
MacOS.EnableAppswitch(0)
|
||||||
if self.quitting:
|
if self.quitting:
|
||||||
# returning None is not enough, a former BdbQuit exception
|
# returning None is not enough, a former BdbQuit exception
|
||||||
|
@ -512,6 +513,7 @@ class Debugger(bdb.Bdb):
|
||||||
print 'bdb.Bdb.dispatch: unknown debugging event:', `event`
|
print 'bdb.Bdb.dispatch: unknown debugging event:', `event`
|
||||||
return self.trace_dispatch
|
return self.trace_dispatch
|
||||||
finally:
|
finally:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.set_step()
|
self.set_step()
|
||||||
|
|
|
@ -122,6 +122,7 @@ def dosearch(docpath, searchstring, settings):
|
||||||
_open = open
|
_open = open
|
||||||
hits = {}
|
hits = {}
|
||||||
try:
|
try:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(0)
|
MacOS.EnableAppswitch(0)
|
||||||
try:
|
try:
|
||||||
for do, name in books:
|
for do, name in books:
|
||||||
|
@ -145,6 +146,7 @@ def dosearch(docpath, searchstring, settings):
|
||||||
if filehits:
|
if filehits:
|
||||||
hits[fullpath] = filehits
|
hits[fullpath] = filehits
|
||||||
finally:
|
finally:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
status.close()
|
status.close()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
@ -1128,6 +1128,7 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
|
||||||
else:
|
else:
|
||||||
PyDebugger.startfromhere()
|
PyDebugger.startfromhere()
|
||||||
elif not haveThreading:
|
elif not haveThreading:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(0)
|
MacOS.EnableAppswitch(0)
|
||||||
try:
|
try:
|
||||||
if profiling:
|
if profiling:
|
||||||
|
@ -1145,6 +1146,7 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
|
||||||
exec code in globals, locals
|
exec code in globals, locals
|
||||||
finally:
|
finally:
|
||||||
if not haveThreading:
|
if not haveThreading:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
except W.AlertError, detail:
|
except W.AlertError, detail:
|
||||||
raise W.AlertError, detail
|
raise W.AlertError, detail
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
# it like the "normal" interpreter.
|
# it like the "normal" interpreter.
|
||||||
|
|
||||||
__version__ = '1.0.1'
|
__version__ = '1.0.1'
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
import MacOS
|
import MacOS
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
|
|
||||||
from Carbon import Qd, QuickDraw
|
from Carbon import Qd, QuickDraw
|
||||||
|
@ -16,11 +18,13 @@ def init():
|
||||||
import macresource
|
import macresource
|
||||||
import sys, os
|
import sys, os
|
||||||
macresource.need('DITL', 468, "PythonIDE.rsrc")
|
macresource.need('DITL', 468, "PythonIDE.rsrc")
|
||||||
widgetresfile = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE:Widgets.rsrc")
|
widgetrespathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE", "Widgets.rsrc"]
|
||||||
|
widgetresfile = os.path.join(*widgetrespathsegs)
|
||||||
refno = macresource.need('CURS', 468, widgetresfile)
|
refno = macresource.need('CURS', 468, widgetresfile)
|
||||||
if refno:
|
if refno:
|
||||||
# We're not a fullblown application
|
# We're not a fullblown application
|
||||||
ide_path = os.path.join(sys.exec_prefix, ":Mac:Tools:IDE")
|
idepathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE"]
|
||||||
|
ide_path = os.path.join(*idepathsegs)
|
||||||
else:
|
else:
|
||||||
# We are a fully frozen application
|
# We are a fully frozen application
|
||||||
ide_path = sys.argv[0]
|
ide_path = sys.argv[0]
|
||||||
|
|
|
@ -7,7 +7,12 @@ import Wapplication
|
||||||
import W
|
import W
|
||||||
import os
|
import os
|
||||||
import macfs
|
import macfs
|
||||||
|
import MacOS
|
||||||
|
|
||||||
|
if MacOS.runtimemodel == 'macho':
|
||||||
|
ELIPSES = '...'
|
||||||
|
else:
|
||||||
|
ELIPSES = '\xc9'
|
||||||
|
|
||||||
class PythonIDE(Wapplication.Application):
|
class PythonIDE(Wapplication.Application):
|
||||||
|
|
||||||
|
@ -50,13 +55,13 @@ class PythonIDE(Wapplication.Application):
|
||||||
def makeusermenus(self):
|
def makeusermenus(self):
|
||||||
m = Wapplication.Menu(self.menubar, "File")
|
m = Wapplication.Menu(self.menubar, "File")
|
||||||
newitem = FrameWork.MenuItem(m, "New", "N", 'new')
|
newitem = FrameWork.MenuItem(m, "New", "N", 'new')
|
||||||
openitem = FrameWork.MenuItem(m, "Open\xc9", "O", 'open')
|
openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open')
|
||||||
FrameWork.Separator(m)
|
FrameWork.Separator(m)
|
||||||
closeitem = FrameWork.MenuItem(m, "Close", "W", 'close')
|
closeitem = FrameWork.MenuItem(m, "Close", "W", 'close')
|
||||||
saveitem = FrameWork.MenuItem(m, "Save", "S", 'save')
|
saveitem = FrameWork.MenuItem(m, "Save", "S", 'save')
|
||||||
saveasitem = FrameWork.MenuItem(m, "Save as\xc9", None, 'save_as')
|
saveasitem = FrameWork.MenuItem(m, "Save as"+ELIPSES, None, 'save_as')
|
||||||
FrameWork.Separator(m)
|
FrameWork.Separator(m)
|
||||||
saveasappletitem = FrameWork.MenuItem(m, "Save as Applet\xc9", None, 'save_as_applet')
|
saveasappletitem = FrameWork.MenuItem(m, "Save as Applet"+ELIPSES, None, 'save_as_applet')
|
||||||
FrameWork.Separator(m)
|
FrameWork.Separator(m)
|
||||||
quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit')
|
quititem = FrameWork.MenuItem(m, "Quit", "Q", 'quit')
|
||||||
|
|
||||||
|
@ -71,7 +76,7 @@ class PythonIDE(Wapplication.Application):
|
||||||
selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall")
|
selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall")
|
||||||
sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline")
|
sellineitem = FrameWork.MenuItem(m, "Select line", "L", "selectline")
|
||||||
FrameWork.Separator(m)
|
FrameWork.Separator(m)
|
||||||
finditem = FrameWork.MenuItem(m, "Find\xc9", "F", "find")
|
finditem = FrameWork.MenuItem(m, "Find"+ELIPSES, "F", "find")
|
||||||
findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext")
|
findagainitem = FrameWork.MenuItem(m, "Find again", 'G', "findnext")
|
||||||
enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring")
|
enterselitem = FrameWork.MenuItem(m, "Enter search string", "E", "entersearchstring")
|
||||||
replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace")
|
replaceitem = FrameWork.MenuItem(m, "Replace", None, "replace")
|
||||||
|
@ -84,12 +89,12 @@ class PythonIDE(Wapplication.Application):
|
||||||
runitem = FrameWork.MenuItem(m, "Run window", "R", 'run')
|
runitem = FrameWork.MenuItem(m, "Run window", "R", 'run')
|
||||||
runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection')
|
runselitem = FrameWork.MenuItem(m, "Run selection", None, 'runselection')
|
||||||
FrameWork.Separator(m)
|
FrameWork.Separator(m)
|
||||||
moditem = FrameWork.MenuItem(m, "Module browser\xc9", "M", self.domenu_modulebrowser)
|
moditem = FrameWork.MenuItem(m, "Module browser"+ELIPSES, "M", self.domenu_modulebrowser)
|
||||||
FrameWork.Separator(m)
|
FrameWork.Separator(m)
|
||||||
mm = FrameWork.SubMenu(m, "Preferences")
|
mm = FrameWork.SubMenu(m, "Preferences")
|
||||||
FrameWork.MenuItem(mm, "Set Scripts folder\xc9", None, self.do_setscriptsfolder)
|
FrameWork.MenuItem(mm, "Set Scripts folder"+ELIPSES, None, self.do_setscriptsfolder)
|
||||||
FrameWork.MenuItem(mm, "Editor default settings\xc9", None, self.do_editorprefs)
|
FrameWork.MenuItem(mm, "Editor default settings"+ELIPSES, None, self.do_editorprefs)
|
||||||
FrameWork.MenuItem(mm, "Set default window font\xc9", None, self.do_setwindowfont)
|
FrameWork.MenuItem(mm, "Set default window font"+ELIPSES, None, self.do_setwindowfont)
|
||||||
|
|
||||||
self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows')
|
self.openwindowsmenu = Wapplication.Menu(self.menubar, 'Windows')
|
||||||
self.makeopenwindowsmenu()
|
self.makeopenwindowsmenu()
|
||||||
|
@ -110,7 +115,7 @@ class PythonIDE(Wapplication.Application):
|
||||||
path = os.path.join(os.getcwd(), "Scripts")
|
path = os.path.join(os.getcwd(), "Scripts")
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
f = open(os.path.join(path, "Place your scripts here\xc9"), "w")
|
f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w")
|
||||||
f.close()
|
f.close()
|
||||||
fss = macfs.FSSpec(path)
|
fss = macfs.FSSpec(path)
|
||||||
self.scriptsfolder = fss.NewAlias()
|
self.scriptsfolder = fss.NewAlias()
|
||||||
|
@ -159,7 +164,7 @@ class PythonIDE(Wapplication.Application):
|
||||||
W.Message("Can't open file of type '%s'." % ftype)
|
W.Message("Can't open file of type '%s'." % ftype)
|
||||||
|
|
||||||
def getabouttext(self):
|
def getabouttext(self):
|
||||||
return "About Python IDE\xc9"
|
return "About Python IDE"+ELIPSES
|
||||||
|
|
||||||
def do_about(self, id, item, window, event):
|
def do_about(self, id, item, window, event):
|
||||||
Splash.about()
|
Splash.about()
|
||||||
|
|
|
@ -28,26 +28,32 @@ class Application(FrameWork.Application):
|
||||||
def mainloop(self, mask=FrameWork.everyEvent, wait=None):
|
def mainloop(self, mask=FrameWork.everyEvent, wait=None):
|
||||||
import W
|
import W
|
||||||
self.quitting = 0
|
self.quitting = 0
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
saveyield = MacOS.EnableAppswitch(-1)
|
saveyield = MacOS.EnableAppswitch(-1)
|
||||||
try:
|
try:
|
||||||
while not self.quitting:
|
while not self.quitting:
|
||||||
try:
|
try:
|
||||||
self.do1event(mask, wait)
|
self.do1event(mask, wait)
|
||||||
except W.AlertError, detail:
|
except W.AlertError, detail:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
W.Message(detail)
|
W.Message(detail)
|
||||||
except self.DebuggerQuit:
|
except self.DebuggerQuit:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
except:
|
except:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
import PyEdit
|
import PyEdit
|
||||||
PyEdit.tracebackwindow.traceback()
|
PyEdit.tracebackwindow.traceback()
|
||||||
finally:
|
finally:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(1)
|
MacOS.EnableAppswitch(1)
|
||||||
|
|
||||||
def debugger_mainloop(self, mask=FrameWork.everyEvent, wait=None):
|
def debugger_mainloop(self, mask=FrameWork.everyEvent, wait=None):
|
||||||
import W
|
import W
|
||||||
self.debugger_quitting = 0
|
self.debugger_quitting = 0
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
saveyield = MacOS.EnableAppswitch(-1)
|
saveyield = MacOS.EnableAppswitch(-1)
|
||||||
try:
|
try:
|
||||||
while not self.quitting and not self.debugger_quitting:
|
while not self.quitting and not self.debugger_quitting:
|
||||||
|
@ -59,6 +65,7 @@ class Application(FrameWork.Application):
|
||||||
import PyEdit
|
import PyEdit
|
||||||
PyEdit.tracebackwindow.traceback()
|
PyEdit.tracebackwindow.traceback()
|
||||||
finally:
|
finally:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(saveyield)
|
MacOS.EnableAppswitch(saveyield)
|
||||||
|
|
||||||
def breathe(self, wait=1):
|
def breathe(self, wait=1):
|
||||||
|
@ -309,18 +316,23 @@ class Application(FrameWork.Application):
|
||||||
# exec in that window's namespace.
|
# exec in that window's namespace.
|
||||||
# xxx what to do when it's not saved???
|
# xxx what to do when it's not saved???
|
||||||
# promt to save?
|
# promt to save?
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(0)
|
MacOS.EnableAppswitch(0)
|
||||||
execfile(path, {'__name__': '__main__', '__file__': path})
|
execfile(path, {'__name__': '__main__', '__file__': path})
|
||||||
except W.AlertError, detail:
|
except W.AlertError, detail:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
raise W.AlertError, detail
|
raise W.AlertError, detail
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
except:
|
except:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
import PyEdit
|
import PyEdit
|
||||||
PyEdit.tracebackwindow.traceback(1)
|
PyEdit.tracebackwindow.traceback(1)
|
||||||
else:
|
else:
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(-1)
|
MacOS.EnableAppswitch(-1)
|
||||||
#os.chdir(cwd)
|
#os.chdir(cwd)
|
||||||
|
|
||||||
|
|
|
@ -455,6 +455,7 @@ class ModalDialog(Dialog):
|
||||||
Dialog.close(self)
|
Dialog.close(self)
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
saveyield = MacOS.EnableAppswitch(-1)
|
saveyield = MacOS.EnableAppswitch(-1)
|
||||||
while not self.done:
|
while not self.done:
|
||||||
#self.do1event()
|
#self.do1event()
|
||||||
|
@ -465,6 +466,7 @@ class ModalDialog(Dialog):
|
||||||
Events.mDownMask +
|
Events.mDownMask +
|
||||||
Events.mUpMask,
|
Events.mUpMask,
|
||||||
10)
|
10)
|
||||||
|
if hasattr(MacOS, 'EnableAppswitch'):
|
||||||
MacOS.EnableAppswitch(saveyield)
|
MacOS.EnableAppswitch(saveyield)
|
||||||
|
|
||||||
def do1event(self, mask = Events.everyEvent, wait = 0):
|
def do1event(self, mask = Events.everyEvent, wait = 0):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue