From 2c3b1bc4975ea6bc4ad229c1c4be85eddeec4854 Mon Sep 17 00:00:00 2001 From: jdh2358 <> Date: Wed, 11 Apr 2007 17:17:06 +0000 Subject: [PATCH] Fix missing function clear_history, thanks to a patch by Aldarion --- pyreadline/__init__.py | 1 + pyreadline/lineeditor/history.py | 5 +++++ pyreadline/release.py | 2 +- pyreadline/rlmain.py | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pyreadline/__init__.py b/pyreadline/__init__.py index 34393a6..dd31888 100644 --- a/pyreadline/__init__.py +++ b/pyreadline/__init__.py @@ -11,6 +11,7 @@ from rlmain import * __all__ = [ 'parse_and_bind', 'get_line_buffer', 'insert_text', + 'clear_history', 'read_init_file', 'read_history_file', 'write_history_file', diff --git a/pyreadline/lineeditor/history.py b/pyreadline/lineeditor/history.py index 8007b76..57d70f0 100644 --- a/pyreadline/lineeditor/history.py +++ b/pyreadline/lineeditor/history.py @@ -53,6 +53,11 @@ class LineHistory(object): history_length=property(get_history_length,set_history_length) history_cursor=property(get_history_cursor,set_history_cursor) + def clear_history(self): + '''Clear readline history.''' + self.history[:] = [] + self.history_cursor = 0 + def read_history_file(self, filename=None): '''Load a readline history file.''' if filename is None: diff --git a/pyreadline/release.py b/pyreadline/release.py index c099c1c..153c58d 100644 --- a/pyreadline/release.py +++ b/pyreadline/release.py @@ -22,7 +22,7 @@ name = 'pyreadline' branch = 'refactor' -version = '1.4' +version = '1.4.1' revision = '$Revision$' diff --git a/pyreadline/rlmain.py b/pyreadline/rlmain.py index 897c757..6c62f75 100644 --- a/pyreadline/rlmain.py +++ b/pyreadline/rlmain.py @@ -170,6 +170,10 @@ class Readline(object): ''' self._history.set_history_length(length) + def clear_history(self): + '''Clear readline history''' + self._history.clear_history() + def read_history_file(self, filename=None): '''Load a readline history file. The default filename is ~/.history.''' self._history.read_history_file(filename) @@ -433,6 +437,7 @@ read_init_file = rl.read_init_file add_history = rl.add_history get_history_length = rl.get_history_length set_history_length = rl.set_history_length +clear_history = rl.clear_history read_history_file = rl.read_history_file write_history_file = rl.write_history_file set_completer = rl.set_completer