Class: RawLine::Editor::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/rawline/editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env: nil) ⇒ Environment

  • @history_size - the size of the editor history buffer (30).

  • @keys - the keys (arrays of character codes) bound to specific actions.

  • @line_history_size - the size of the editor line history buffer (50).



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/rawline/editor.rb', line 94

def initialize(env: nil)
  @env = env
  @keys = {}

  @completion_class = Completer

  @line_history_size = 50
  @history_size = 30

  @history = HistoryBuffer.new(@history_size) do |h|
    h.duplicates = false;
    h.exclude = lambda { |item| item.strip == "" }
  end
end

Instance Attribute Details

#completion_classObject

Returns the value of attribute completion_class.



89
90
91
# File 'lib/rawline/editor.rb', line 89

def completion_class
  @completion_class
end

#historyObject

Returns the value of attribute history.



89
90
91
# File 'lib/rawline/editor.rb', line 89

def history
  @history
end

#keysObject

Returns the value of attribute keys.



89
90
91
# File 'lib/rawline/editor.rb', line 89

def keys
  @keys
end

#word_separatorObject

Returns the value of attribute word_separator.



89
90
91
# File 'lib/rawline/editor.rb', line 89

def word_separator
  @word_separator
end

Instance Method Details

#initialize_line(&blk) ⇒ Object



109
110
111
112
113
# File 'lib/rawline/editor.rb', line 109

def initialize_line(&blk)
  Line.new(@line_history_size) do |line|
    blk.call(line) if blk
  end
end