class Term::Reader::Line

Defined in:

reader/line.cr

Constant Summary

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

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(text : String = "", prompt : String = "") #

Create a Line instance


[View source]
def self.new(**options, & : self -> ) #

ditto


[View source]

Class Method Detail

def self.sanitize(text : String) : String #

Strip ANSI characters from the text


[View source]

Instance Method Detail

def <<(char) #

Add char and move cursor


[View source]
def [](i) #

Read character


[View source]
def []=(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"

[View source]
def []=(range : Range, chars : String) #

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


[View source]
def cursor : Int32 #

The current cursor position witin the text


[View source]
def delete(n : Int32 = 1) : Nil #

Remove char from the line at current position


[View source]
def edit_mode : Nil #

Enable edit mode


[View source]
def editing? : Bool #

Check if line is in edit mode


[View source]
def end? : Bool #

Check if cursor reached end of the line


[View source]
def insert(chars) #

Insert char(s) at cursor position


[View source]
def inspect : String #
Description copied from class Object

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.


[View source]
def left(n = 1) : Nil #

Move line position to the left by n chars


[View source]
def mode : Mode #

The line mode


[View source]
def move_to_end : Nil #

Move cursor to end position


[View source]
def move_to_start : Nil #

Move cursor to beginning position


[View source]
def prompt : String #

The prompt displayed before input


[View source]
def prompt_size : Int32 #

Prompt size


[View source]
def remove(n : Int32 = 1) : Nil #

Remove char from the line in front of the cursor


[View source]
def replace(text : String) #

Replace current line with new text


[View source]
def replace_mode : Nil #

Enable replace mode


[View source]
def replacing? : Bool #

Check if line is in replace mode


[View source]
def right(n = 1) : Nil #

Move line position to the right by n chars


[View source]
def size : Int32 #

Full line size with prompt


[View source]
def start? : Bool #

Check if cursor reached beginning of the line


[View source]
def text : String #

The editable text


[View source]
def text_size : Int32 #

Text size


[View source]
def to_s : String #

Full line with prompt as string


[View source]