Class InLine::Line
In: lib/inline/line.rb
Parent: Object

The Line class is used to represent the current line being processed and edited by InLine::Editor. It keeps track of the characters typed, the cursor position, the current word and maintains an internal history to allow undos and redos.

Methods

<<   []   []=   bol   bol?   eol   eol?   left   length   max_length   new   right   word  

Included Modules

HighLine::SystemExtensions

Attributes

history  [RW] 
history_size  [RW] 
offset  [R] 
position  [RW] 
prompt  [RW] 
text  [RW] 
word_separator  [RW] 

Public Class methods

Create an instance of InLine::Line. This method takes an optional block used to override the following instance attributes:

  • @text - the line text.
  • @history_size - the size of the line history buffer.
  • @position - the current cursor position within the line.
  • @prompt - a prompt to prepend to the line text.

Public Instance methods

Add a character (expressed as a character code) to the line text.

Access the line text at @index

Modify the character(s) in the line text at @index

Return the position corresponding to the beginning of the line.

Return true if the cursor is at the beginning of the line.

Return the position corresponding to the end of the line.

Return true if the cursor is at the end of the line.

Decrement the line position by offset

Return the length of the line text.

Return the maximum line length. By default, it corresponds to the terminal‘s width minus the length of the line prompt.

Increment the line position by offset

Return information about the current word, as a Hash composed by the following elements:

  • :start: The position in the line corresponding to the word start
  • :end: The position in the line corresponding to the word end
  • :text: The word text.

[Validate]