summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/PyShell.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2002-12-29 22:03:38 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2002-12-29 22:03:38 (GMT)
commit4ada7ad3bc9ab269189ed20e57943d9721664deb (patch)
tree327c3d149a6902106b4d476284c854d439693d69 /Lib/idlelib/PyShell.py
parentaf72d5221f6c826c05594cb1877e8b6d6e20d12b (diff)
downloadcpython-4ada7ad3bc9ab269189ed20e57943d9721664deb.zip
cpython-4ada7ad3bc9ab269189ed20e57943d9721664deb.tar.gz
cpython-4ada7ad3bc9ab269189ed20e57943d9721664deb.tar.bz2
M EditorWindow.py
M PyShell.py 1. PyShell Rev 1.39, EditorWindow Rev 1.37 fix was not handling a multiline prompt. 2. The same fix introduced a bug where hitting <enter> at a previous prompt-only line would copy the prompt to the iomark. 3. Move the setting of sys.ps1 earlier, into PyShell.main(), to allow this code to work before a shell is started up. 4. If cursor is on the input line in the prompt, and you hit <enter>, process the line instead of complaining. 5. If line has no stdin range (this includes the last line before shell restart) strip any prompt before recalling.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rw-r--r--Lib/idlelib/PyShell.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index f4485bd..eb5c6af 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -825,10 +825,6 @@ class PyShell(OutputWindow):
self.write("Python %s on %s\n%s\nIDLEfork %s\n" %
(sys.version, sys.platform, self.COPYRIGHT,
idlever.IDLE_VERSION))
- try:
- sys.ps1
- except AttributeError:
- sys.ps1 = ">>> "
self.showprompt()
import Tkinter
Tkinter._default_root = None
@@ -943,14 +939,17 @@ class PyShell(OutputWindow):
if next and self.text.compare("insert lineend", ">=", next[0]):
self.recall(self.text.get(next[0], next[1]))
return "break"
- # No stdin mark -- just get the current line
- self.recall(self.text.get("insert linestart", "insert lineend"))
+ # No stdin mark -- just get the current line, less any prompt
+ line = self.text.get("insert linestart", "insert lineend")
+ last_line_of_prompt = sys.ps1.split('\n')[-1]
+ if line.startswith(last_line_of_prompt):
+ line = line[len(last_line_of_prompt):]
+ self.recall(line)
return "break"
# If we're between the beginning of the line and the iomark, i.e.
- # in the prompt area, complain.
+ # in the prompt area, move to the end of the prompt
if self.text.compare("insert", "<", "iomark"):
- self.text.bell()
- return "break"
+ self.text.mark_set("insert", "iomark")
# If we're in the current input and there's only whitespace
# beyond the cursor, erase that whitespace first
s = self.text.get("insert", "end-1c")
@@ -1136,6 +1135,10 @@ def main():
script = None
startup = False
try:
+ sys.ps1
+ except AttributeError:
+ sys.ps1 = '>>> '
+ try:
opts, args = getopt.getopt(sys.argv[1:], "c:deihr:st:")
except getopt.error, msg:
sys.stderr.write("Error: %s\n" % str(msg))