have = len(chars.expandtabs(tabwidth))
assert have > 0
want = ((have - 1) // self.indentwidth) * self.indentwidth
+ # Debug prompt is multilined....
+ last_line_of_prompt = sys.ps1.split('\n')[-1]
ncharsdeleted = 0
while 1:
- if chars == sys.ps1:
+ if chars == last_line_of_prompt:
break
chars = chars[:-1]
ncharsdeleted = ncharsdeleted + 1
text.mark_set("insert", first)
line = text.get("insert linestart", "insert")
i, n = 0, len(line)
- if line == sys.ps1:
- return "break"
while i < n and line[i] in " \t":
i = i+1
if i == n:
- # the cursor is in or at leading indentation; just inject
- # an empty line at the start
+ # the cursor is in or at leading indentation in a continuation
+ # line; just inject an empty line at the start
text.insert("insert linestart", '\n')
return "break"
indent = line[:i]
- # strip whitespace before insert point
+ # strip whitespace before insert point unless it's in the prompt
i = 0
- while line and line[-1] in " \t":
+ last_line_of_prompt = sys.ps1.split('\n')[-1]
+ while line and line[-1] in " \t" and line != last_line_of_prompt:
line = line[:-1]
i = i+1
if i:
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
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")
cmd = None
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: