summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/IdleHistory.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2005-02-03 01:37:14 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2005-02-03 01:37:14 (GMT)
commit0676dfdce06f6b01f35d76a4fb77c77c03468366 (patch)
treec795d6dc319256e4b652e82b18bf9a222e238d51 /Lib/idlelib/IdleHistory.py
parent69b8caa23a598f3192981898eb213f9578fbf0be (diff)
downloadcpython-0676dfdce06f6b01f35d76a4fb77c77c03468366.zip
cpython-0676dfdce06f6b01f35d76a4fb77c77c03468366.tar.gz
cpython-0676dfdce06f6b01f35d76a4fb77c77c03468366.tar.bz2
Add config-main.def option to make the 'history' feature non-cyclic.
Default remains cyclic. Python Patch 914546 Noam Raphael. M IdleHistory.py M NEWS.txt M config-main.def
Diffstat (limited to 'Lib/idlelib/IdleHistory.py')
-rw-r--r--Lib/idlelib/IdleHistory.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/idlelib/IdleHistory.py b/Lib/idlelib/IdleHistory.py
index 46e70e1..f672db7 100644
--- a/Lib/idlelib/IdleHistory.py
+++ b/Lib/idlelib/IdleHistory.py
@@ -1,3 +1,5 @@
+from configHandler import idleConf
+
class History:
def __init__(self, text, output_sep = "\n"):
@@ -6,6 +8,7 @@ class History:
self.history_prefix = None
self.history_pointer = None
self.output_sep = output_sep
+ self.cyclic = idleConf.GetOption("main", "History", "cyclic", 1, "bool")
text.bind("<<history-previous>>", self.history_prev)
text.bind("<<history-next>>", self.history_next)
@@ -40,7 +43,11 @@ class History:
if reverse:
pointer = nhist
else:
- pointer = -1
+ if self.cyclic:
+ pointer = -1
+ else:
+ self.text.bell()
+ return
nprefix = len(prefix)
while 1:
if reverse:
@@ -49,10 +56,13 @@ class History:
pointer = pointer + 1
if pointer < 0 or pointer >= nhist:
self.text.bell()
- if self._get_source("iomark", "end-1c") != prefix:
- self.text.delete("iomark", "end-1c")
- self._put_source("iomark", prefix)
- pointer = prefix = None
+ if not self.cyclic and pointer < 0:
+ return
+ else:
+ if self._get_source("iomark", "end-1c") != prefix:
+ self.text.delete("iomark", "end-1c")
+ self._put_source("iomark", prefix)
+ pointer = prefix = None
break
item = self.history[pointer]
if item[:nprefix] == prefix and len(item) > nprefix: