More PyCrust updates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-12-16 21:21:30 +00:00
parent df011ca6e2
commit c77f57b50a
3 changed files with 19 additions and 25 deletions

View File

@@ -51,6 +51,7 @@ class Interpreter(InteractiveInterpreter):
If the passed in command is part of a multi-line command we keep
appending the pieces to the last list in commandBuffer until we
have a complete command. If not, we delete that last list."""
command = str(command) # In case the command is unicode.
if not self.more:
try: del self.commandBuffer[-1]
except IndexError: pass
@@ -63,9 +64,7 @@ class Interpreter(InteractiveInterpreter):
def runsource(self, source):
"""Compile and run source code in the interpreter."""
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
sys.stdin = self.stdin
sys.stdout = self.stdout
sys.stderr = self.stderr
sys.stdin, sys.stdout, sys.stderr = self.stdin, self.stdout, self.stderr
more = InteractiveInterpreter.runsource(self, source)
# If sys.std* is still what we set it to, then restore it.
# But, if the executed source changed sys.std*, assume it
@@ -86,7 +85,10 @@ class Interpreter(InteractiveInterpreter):
"""Return list of auto-completion options for a command.
The list of options will be based on the locals namespace."""
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
sys.stdin, sys.stdout, sys.stderr = self.stdin, self.stdout, self.stderr
return introspect.getAutoCompleteList(command, self.locals, *args, **kwds)
sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr
def getCallTip(self, command='', *args, **kwds):
"""Return call tip text for a command.

View File

@@ -217,7 +217,7 @@ def getRoot(command, terminator=None):
else:
# start represents the last known good point in the line.
start = token[2][1]
elif tokenstring in ('[({])}'):
elif len(tokenstring) == 1 and tokenstring in ('[({])}'):
# Remember, we're working backwords.
# So prefix += tokenstring would be wrong.
if prefix in emptyTypes and tokenstring in ('[({'):

View File

@@ -76,8 +76,13 @@ class ShellFrame(wx.wxFrame, ShellMenu):
wx.EVT_CLOSE(self, self.OnCloseWindow)
def OnCloseWindow(self, event):
self.shell.destroy()
self.Destroy()
"""Event handler for closing."""
# This isn't working the way I want, but I'll leave it for now.
if self.shell.waiting:
event.Veto(True)
else:
self.shell.destroy()
self.Destroy()
class ShellFacade:
@@ -244,7 +249,7 @@ class Shell(stc.wxStyledTextCtrl):
except: pass
def destroy(self):
# del self.interp
del self.interp
pass
def config(self):
@@ -364,7 +369,7 @@ Platform: %s""" % (VERSION, self.revision, self.interp.revision,
def OnIdle(self, event):
"""Free the CPU to do other things."""
if self.waiting:
time.sleep(0.1)
time.sleep(0.05)
def OnUpdateUI(self, event):
"""Check for matching braces."""
@@ -821,32 +826,19 @@ Platform: %s""" % (VERSION, self.revision, self.interp.revision,
self.prompt()
try:
while not reader.input:
time.sleep(0.1) # Free up the CPU.
wx.wxYield()
wx.wxYieldIfNeeded()
input = reader.input
finally:
reader.input = ''
reader.isreading = 0
input = str(input) # In case of Unicode.
return input
def readlines(self):
"""Replacement for stdin.readlines()."""
lines = []
input = ''
reader = self.reader
reader.isreading = 1
try:
while lines[-1:] != ['\n']:
self.prompt()
while not reader.input:
time.sleep(0.1) # Free up the CPU.
wx.wxYield()
input = reader.input
lines.append(input)
reader.input = ''
finally:
reader.input = ''
reader.isreading = 0
while lines[-1:] != ['\n']:
lines.append(self.readline())
return lines
def raw_input(self, prompt=''):