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, terminal: 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).



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rawline/editor.rb', line 98

def initialize(env: nil, terminal: nil)
  @env = env
  @keys = KeyBindings.new(terminal: terminal)
  @keyboard_input_processors = []

  @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.



91
92
93
# File 'lib/rawline/editor.rb', line 91

def completion_class
  @completion_class
end

#historyObject

Returns the value of attribute history.



91
92
93
# File 'lib/rawline/editor.rb', line 91

def history
  @history
end

#keyboard_input_processorsObject

Returns the value of attribute keyboard_input_processors.



92
93
94
# File 'lib/rawline/editor.rb', line 92

def keyboard_input_processors
  @keyboard_input_processors
end

#keysObject

Returns the value of attribute keys.



91
92
93
# File 'lib/rawline/editor.rb', line 91

def keys
  @keys
end

#terminalObject

Returns the value of attribute terminal.



93
94
95
# File 'lib/rawline/editor.rb', line 93

def terminal
  @terminal
end

#word_separatorObject

Returns the value of attribute word_separator.



91
92
93
# File 'lib/rawline/editor.rb', line 91

def word_separator
  @word_separator
end

Instance Method Details

#initialize_line(&blk) ⇒ Object



114
115
116
117
118
# File 'lib/rawline/editor.rb', line 114

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