[Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.60, 1.61 PyShell.py, 1.96, 1.97

kbk@users.sourceforge.net kbk at users.sourceforge.net
Sun Jun 19 20:56:18 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/idlelib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32688

Modified Files:
	NEWS.txt PyShell.py 
Log Message:
<Enter> when cursor is on a previous command retrieves that command.  Instead
of replacing the input line, the previous command is now appended to the
input line. Indentation is preserved, and undo is enabled.
Patch 1196917  Jeff Shute

Modified Files:
	NEWS.txt PyShell.py 


Index: NEWS.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- NEWS.txt	12 Jun 2005 05:19:23 -0000	1.60
+++ NEWS.txt	19 Jun 2005 18:56:15 -0000	1.61
@@ -3,6 +3,11 @@
 
 *Release date: XX-XXX-2005*
 
+- <Enter> when cursor is on a previous command retrieves that command.  Instead
+  of replacing the input line, the previous command is now appended to the
+  input line. Indentation is preserved, and undo is enabled.
+  Patch 1196917  Jeff Shute
+
 - Clarify "tab/space" Error Dialog and "Tab Width" Dialog associated with
   the Untabify command.
 

Index: PyShell.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- PyShell.py	10 May 2005 03:44:24 -0000	1.96
+++ PyShell.py	19 Jun 2005 18:56:15 -0000	1.97
@@ -1074,7 +1074,7 @@
             sel = self.text.get("sel.first", "sel.last")
             if sel:
                 if self.text.compare("sel.last", "<=", "iomark"):
-                    self.recall(sel)
+                    self.recall(sel, event)
                     return "break"
         except:
             pass
@@ -1085,18 +1085,18 @@
             # Check if there's a relevant stdin range -- if so, use it
             prev = self.text.tag_prevrange("stdin", "insert")
             if prev and self.text.compare("insert", "<", prev[1]):
-                self.recall(self.text.get(prev[0], prev[1]))
+                self.recall(self.text.get(prev[0], prev[1]), event)
                 return "break"
             next = self.text.tag_nextrange("stdin", "insert")
             if next and self.text.compare("insert lineend", ">=", next[0]):
-                self.recall(self.text.get(next[0], next[1]))
+                self.recall(self.text.get(next[0], next[1]), event)
                 return "break"
             # 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)
+            self.recall(line, event)
             return "break"
         # If we're between the beginning of the line and the iomark, i.e.
         # in the prompt area, move to the end of the prompt
@@ -1127,9 +1127,29 @@
             self.runit()
         return "break"
 
-    def recall(self, s):
-        if self.history:
-            self.history.recall(s)
+    def recall(self, s, event):
+        self.text.undo_block_start()
+        try:
+            self.text.tag_remove("sel", "1.0", "end")
+            self.text.mark_set("insert", "end-1c")
+            s = s.strip()
+            lines = s.split('\n')
+            if lines:
+                prefix = self.text.get("insert linestart","insert").rstrip()
+                if prefix and prefix[-1]==':':
+                    self.newline_and_indent_event(event)
+
+                self.text.insert("insert",lines[0].strip())
+                if len(lines) > 1:
+                    self.newline_and_indent_event(event)
+                    for line in lines[1:]:
+                        self.text.insert("insert", line.strip())
+                        self.newline_and_indent_event(event)
+            else:
+                self.text.insert("insert", s)
+        finally:
+            self.text.see("insert")
+            self.text.undo_block_stop()
 
     def runit(self):
         line = self.text.get("iomark", "end-1c")



More information about the Python-checkins mailing list