class

Term::Reader::Line

Inherits Reference < Object

Constants

ANSI_MATCHER = /(\[)?\033(\[)?[;?\d]*[\dA-Za-z](\])?/

Constructors

new(text : String = "", prompt : String = "")

Create a Line instance

Source
new

ditto

Source

Class methods

sanitize(text : String) : String

Strip ANSI characters from the text

Source

Instance methods

<<(char)

Add char and move cursor

Source
[](i)

Read character

Source
[]=(i : Int, chars : String)

Insert characters inside a line. When the lines exceeds maximum length, an extra space is added to accomodate index.

text = "aaa"
line[5] = "b"
=> "aaa  b"
Source
[]=(range : Range, chars : String)

Insert characters inside a line. When the lines exceeds maximum length, an extra space is added to accomodate index.

Source
cursor

The current cursor position witin the text

Source
delete(n : Int32 = 1) : Nil

Remove char from the line at current position

Source
edit_mode

Enable edit mode

Source
editing?

Check if line is in edit mode

Source
end?

Check if cursor reached end of the line

Source
insert(chars)

Insert char(s) at cursor position

Source
inspect

Returns an unambiguous and information-rich string representation of this object, typically intended for developers.

This method should usually not be overridden. It delegates to #inspect(IO) which can be overridden for custom implementations.

Also see #to_s.

Source
left(n = 1) : Nil

Move line position to the left by n chars

Source
mode

The line mode

Source
move_to_end

Move cursor to end position

Source
move_to_start

Move cursor to beginning position

Source
prompt

The prompt displayed before input

Source
prompt_size

Prompt size

Source
remove(n : Int32 = 1) : Nil

Remove char from the line in front of the cursor

Source
replace(text : String)

Replace current line with new text

Source
replace_mode

Enable replace mode

Source
replacing?

Check if line is in replace mode

Source
right(n = 1) : Nil

Move line position to the right by n chars

Source
size

Full line size with prompt

Source
start?

Check if cursor reached beginning of the line

Source
text

The editable text

Source
text_size

Text size

Source
to_s

Full line with prompt as string

Source

Nested types