Fix missing function clear_history, thanks to a patch by Aldarion <erendisaldarion@gmail.com>

This commit is contained in:
jdh2358
2007-04-11 17:17:06 +00:00
parent fa1abaad08
commit 2c3b1bc497
4 changed files with 12 additions and 1 deletions
+1
View File
@@ -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',
+5
View File
@@ -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:
+1 -1
View File
@@ -22,7 +22,7 @@ name = 'pyreadline'
branch = 'refactor'
version = '1.4'
version = '1.4.1'
revision = '$Revision$'
+5
View File
@@ -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