From: Jack Jansen Date: Sun, 24 Feb 2002 23:12:47 +0000 (+0000) Subject: Backport of 1.9-1.11: X-Git-Tag: v2.2.1c1~170 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c9e7d800919ed8772c791cf6559fb27b6901e14;p=thirdparty%2FPython%2Fcpython.git Backport of 1.9-1.11: - Flush screen buffer upon console.flush() and output.flush(). This fixes bug #511992. - 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. - Modified version of patch #496882: echo SimpleStdin readline() input to stdout. --- diff --git a/Mac/Tools/IDE/PyConsole.py b/Mac/Tools/IDE/PyConsole.py index 2bb109d03a6a..23f301b4ef35 100644 --- a/Mac/Tools/IDE/PyConsole.py +++ b/Mac/Tools/IDE/PyConsole.py @@ -75,9 +75,11 @@ class ConsoleTextWidget(W.EditText): if char == Wkeys.returnkey: text = self.get()[self._inputstart:selstart] text = string.join(string.split(text, "\r"), "\n") - saveyield = MacOS.EnableAppswitch(0) + if hasattr(MacOS, 'EnableAppswitch'): + saveyield = MacOS.EnableAppswitch(0) self.pyinteractive.executeline(text, self, self._namespace) - MacOS.EnableAppswitch(saveyield) + if hasattr(MacOS, 'EnableAppswitch'): + MacOS.EnableAppswitch(saveyield) selstart, selend = self.getselection() self._inputstart = selstart @@ -106,6 +108,8 @@ class ConsoleTextWidget(W.EditText): self._buf = "" self.ted.WEClearUndo() self.updatescrollbars() + if Qd.QDIsPortBuffered(self._parentwindow.wid): + Qd.QDFlushPortBuffer(self._parentwindow.wid, None) def selection_ok(self): selstart, selend = self.getselection() @@ -275,13 +279,15 @@ class PyOutput: self.w.bind("", self.activate) def write(self, text): - oldyield = MacOS.EnableAppswitch(-1) + if hasattr(MacOS, 'EnableAppswitch'): + oldyield = MacOS.EnableAppswitch(-1) try: self._buf = self._buf + text if '\n' in self._buf: self.flush() finally: - MacOS.EnableAppswitch(oldyield) + if hasattr(MacOS, 'EnableAppswitch'): + MacOS.EnableAppswitch(oldyield) def flush(self): self.show() @@ -294,6 +300,8 @@ class PyOutput: self._buf = "" self.w.outputtext.updatescrollbars() self.w.outputtext.ted.WEFeatureFlag(WASTEconst.weFReadOnly, 1) + if Qd.QDIsPortBuffered(self.w.wid): + Qd.QDFlushPortBuffer(self.w.wid, None) def show(self): if self.closed: @@ -354,7 +362,9 @@ class SimpleStdin: rv = EasyDialogs.AskString(prompt) if rv is None: return "" - return rv + '\n' + rv = rv + "\n" # readline should include line terminator + sys.stdout.write(rv) # echo user's reply + return rv def installconsole(defaultshow = 1):