Fixing readline api problems Bug #637506

This commit is contained in:
Jorgen Stenarson
2010-09-16 20:41:57 +02:00
parent 20ebe00853
commit bad7ebf0a3
3 changed files with 30 additions and 0 deletions
+2
View File
@@ -16,7 +16,9 @@ __all__ = [ 'parse_and_bind',
'read_init_file',
'read_history_file',
'write_history_file',
'get_current_history_length',
'get_history_length',
'get_history_item',
'set_history_length',
'set_startup_hook',
'set_pre_input_hook',
+16
View File
@@ -33,11 +33,27 @@ class LineHistory(object):
self.lastcommand = None
self.query = u""
def get_current_history_length(self):
u'''Return the number of lines currently in the history.
(This is different from get_history_length(), which returns
the maximum number of lines that will be written to a history file.)'''
value = len(self.history)
log(u"get_current_history_length:%d"%value)
return value
def get_history_length(self):
u'''Return the desired length of the history file. Negative values imply
unlimited history file size.'''
value = self._history_length
log(u"get_history_length:%d"%value)
return value
def get_history_item(self, index):
u'''Return the current contents of history item at index.'''
item = self.history[index]
log(u"get_history_item: index:%d item:%r"%(index, item))
return item.get_line_text()
def set_history_length(self, value):
log(u"set_history_length: old:%d new:%d"%(self._history_length, value))
self._history_length = value
+12
View File
@@ -128,6 +128,12 @@ class BaseReadline(object):
u'''Append a line to the history buffer, as if it was the last line typed.'''
self.mode._history.add_history(line)
def get_current_history_length(self ):
u'''Return the number of lines currently in the history.
(This is different from get_history_length(), which returns
the maximum number of lines that will be written to a history file.)'''
return self.mode._history.get_current_history_length()
def get_history_length(self ):
u'''Return the desired length of the history file.
@@ -142,6 +148,10 @@ class BaseReadline(object):
'''
self.mode._history.set_history_length(length)
def get_history_item(self, index):
u'''Return the current contents of history item at index.'''
return self.mode._history.get_history_item(index)
def clear_history(self):
u'''Clear readline history'''
self.mode._history.clear_history()
@@ -581,7 +591,9 @@ write_history_file = rl.write_history_file
read_history_file = rl.read_history_file
get_completer_delims = rl.get_completer_delims
get_current_history_length = rl.get_current_history_length
get_history_length = rl.get_history_length
get_history_item = rl.get_history_item
get_line_buffer = rl.get_line_buffer
set_completer = rl.set_completer
get_completer = rl.get_completer