Class: MiniReadline::History
- Inherits:
-
Object
- Object
- MiniReadline::History
- Defined in:
- lib/mini_readline/read_line/history.rb
Overview
Support for the edit history.
Instance Method Summary collapse
-
#append_history(str) ⇒ Object
Append a string to the history buffer if enabled.
-
#get_next_history ⇒ Object
Get the next history string.
-
#get_previous_history ⇒ Object
Get the previous history string.
-
#goto_end_of_history ⇒ Object
Go to the end of the history array.
-
#history ⇒ Object
Get the history buffer associated with this instance.
-
#initialize(buffer) ⇒ History
constructor
Setup the history array of the mini line editor.
-
#initialize_parms(options) ⇒ Object
Get the history object ready for the next read line operation.
Constructor Details
#initialize(buffer) ⇒ History
Setup the history array of the mini line editor.
10 11 12 13 |
# File 'lib/mini_readline/read_line/history.rb', line 10 def initialize(buffer) @_buffer = buffer goto_end_of_history end |
Instance Method Details
#append_history(str) ⇒ Object
Append a string to the history buffer if enabled.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mini_readline/read_line/history.rb', line 47 def append_history(str) return if [:no_blanks] && str.strip.empty? if history.include?(str) if [:no_dups] return if [:no_move] history.delete(str) end end history << str end |
#get_next_history ⇒ Object
Get the next history string
37 38 39 40 41 42 43 44 |
# File 'lib/mini_readline/read_line/history.rb', line 37 def get_next_history if @history_cursor < history.length @history_cursor += 1 history[@history_cursor] || "" else false end end |
#get_previous_history ⇒ Object
Get the previous history string.
27 28 29 30 31 32 33 34 |
# File 'lib/mini_readline/read_line/history.rb', line 27 def get_previous_history if @history_cursor > 0 @history_cursor -= 1 self.history[@history_cursor] else false end end |
#goto_end_of_history ⇒ Object
Go to the end of the history array.
22 23 24 |
# File 'lib/mini_readline/read_line/history.rb', line 22 def goto_end_of_history @history_cursor = history.length end |
#history ⇒ Object
Get the history buffer associated with this instance.
62 63 64 |
# File 'lib/mini_readline/read_line/history.rb', line 62 def history @_buffer end |
#initialize_parms(options) ⇒ Object
Get the history object ready for the next read line operation.
16 17 18 19 |
# File 'lib/mini_readline/read_line/history.rb', line 16 def initialize_parms() = goto_end_of_history end |