class Term::Reader::Line
- Term::Reader::Line
- Reference
- Object
Defined in:
reader/line.crConstant Summary
-
ANSI_MATCHER =
/(\[)?\033(\[)?[;?\d]*[\dA-Za-z](\])?/
Constructors
-
.new(text : String = "", prompt : String = "")
Create a Line instance
-
.new(**options, & : self -> )
ditto
Class Method Summary
-
.sanitize(text : String) : String
Strip ANSI characters from the text
Instance Method Summary
-
#<<(char)
Add char and move cursor
-
#[](i)
Read character
-
#[]=(i : Int, chars : String)
Insert characters inside a line.
-
#[]=(range : Range, chars : String)
Insert characters inside a line.
-
#cursor : Int32
The current cursor position witin the text
-
#delete(n : Int32 = 1) : Nil
Remove char from the line at current position
-
#edit_mode : Nil
Enable edit mode
-
#editing? : Bool
Check if line is in edit mode
-
#end? : Bool
Check if cursor reached end of the line
-
#insert(chars)
Insert char(s) at cursor position
-
#inspect : String
Returns an unambiguous and information-rich string representation of this object, typically intended for developers.
-
#left(n = 1) : Nil
Move line position to the left by n chars
-
#mode : Mode
The line mode
-
#move_to_end : Nil
Move cursor to end position
-
#move_to_start : Nil
Move cursor to beginning position
-
#prompt : String
The prompt displayed before input
-
#prompt_size : Int32
Prompt size
-
#remove(n : Int32 = 1) : Nil
Remove char from the line in front of the cursor
-
#replace(text : String)
Replace current line with new text
-
#replace_mode : Nil
Enable replace mode
-
#replacing? : Bool
Check if line is in replace mode
-
#right(n = 1) : Nil
Move line position to the right by n chars
-
#size : Int32
Full line size with prompt
-
#start? : Bool
Check if cursor reached beginning of the line
-
#text : String
The editable text
-
#text_size : Int32
Text size
-
#to_s : String
Full line with prompt as string
Constructor Detail
Class Method Detail
Instance Method Detail
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"
Insert characters inside a line. When the lines exceeds maximum length, an extra space is added to accomodate index.
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
.