class Term::Reader
- Term::Reader
- Reference
- Object
Defined in:
reader/console.crreader/history.cr
reader/key_event.cr
reader/keys.cr
reader/line.cr
reader/mode.cr
reader/version.cr
term-reader.cr
Constant Summary
-
BACKSPACE =
8
-
CARRIAGE_RETURN =
13
-
Key codes
-
CONTROL_KEYS =
{"\u0001" => "ctrl_a", "\u0002" => "ctrl_b", "\u0003" => "ctrl_c", "\u0004" => "ctrl_d", "\u0005" => "ctrl_e", "\u0006" => "ctrl_f", "\a" => "ctrl_g", "\b" => "ctrl_h", "\t" => "ctrl_i", "\n" => "ctrl_j", "\v" => "ctrl_k", "\f" => "ctrl_l", "\r" => "ctrl_m", "\u000E" => "ctrl_n", "\u000F" => "ctrl_o", "\u0010" => "ctrl_p", "\u0011" => "ctrl_q", "\u0012" => "ctrl_r", "\u0013" => "ctrl_s", "\u0014" => "ctrl_t", "\u0015" => "ctrl_u", "\u0016" => "ctrl_v", "\u0017" => "ctrl_w", "\u0018" => "ctrl_x", "\u0019" => "ctrl_y", "\u001A" => "ctrl_z", "\u0000" => "ctrl_space", "\u001C" => "ctrl_backslash", "\u001D" => "ctrl_square_close", "\e[1;5A" => "ctrl_up", "\e[1;5B" => "ctrl_down", "\e[1;5C" => "ctrl_right", "\e[1;5D" => "ctrl_left"}
-
DELETE =
27
-
KEYS =
{"\t" => "tab", "\n" => "enter", "\r" => "return", "\e" => "escape", " " => "space", "\u007F" => "backspace", "\e[1~" => "home", "\e[2~" => "insert", "\e[3~" => "delete", "\e[3;2~" => "shift_delete", "\e[3;5~" => "ctrl_delete", "\e[4~" => "end", "\e[5~" => "page_up", "\e[6~" => "page_down", "\e[7~" => "home", "\e[8~" => "end", "\e[A" => "up", "\e[B" => "down", "\e[C" => "right", "\e[D" => "left", "\e[E" => "clear", "\e[H" => "home", "\e[F" => "end", "\e[Z" => "back_tab", "\eOA" => "up", "\eOB" => "down", "\eOC" => "right", "\eOD" => "left", "\eOE" => "clear", "\eOF" => "end", "\eOH" => "home", "\eOP" => "f1", "\eOQ" => "f2", "\eOR" => "f3", "\eOS" => "f4", "\e[[A" => "f1", "\e[[B" => "f2", "\e[[C" => "f3", "\e[[D" => "f4", "\e[[E" => "f5", "\e[11~" => "f1", "\e[12~" => "f2", "\e[13~" => "f3", "\e[14~" => "f4", "\e[15~" => "f5", "\e[17~" => "f6", "\e[18~" => "f7", "\e[19~" => "f8", "\e[20~" => "f9", "\e[21~" => "f10", "\e[23~" => "f11", "\e[24~" => "f12", "\e[25~" => "f13", "\e[26~" => "f14", "\e[28~" => "f15", "\e[29~" => "f16", "\e[31~" => "f17", "\e[32~" => "f18", "\e[33~" => "f19", "\e[34~" => "f20", "\e[1;2P" => "f13", "\e[2;2Q" => "f14", "\e[1;2S" => "f16", "\e[15;2~" => "f17", "\e[17;2~" => "f18", "\e[18;2~" => "f19", "\e[19;2~" => "f20", "\e[20;2~" => "f21", "\e[21;2~" => "f22", "\e[23;2~" => "f23", "\e[24;2~" => "f24"}
-
NEWLINE =
10
-
VERSION =
"0.1.0"
-
WINDOWS_KEYS =
{"\t" => "tab", "\n" => "enter", "\r" => "return", "\e" => "escape", " " => "space", "\b" => "backspace", "àG" => "home", "àO" => "end", "àR" => "insert", "àS" => "clear", "àI" => "page_up", "àQ" => "page_down", "àH" => "up", "àP" => "down", "àM" => "right", "àK" => "left", "\u0000;" => "f1", "\u0000<" => "f2", "\u0000" => "f3", "\u0000=" => "f4", "\u0000?" => "f5", "\u0000@" => "f6", "\u0000A" => "f7", "\u0000B" => "f8", "\u0000C" => "f9", "\u0000D" => "f10", "\u0000\x85" => "f11", "\u0000\x86" => "f12"}
Constructors
Instance Method Summary
- #add_to_history(line : String)
-
#clear_display(line : Line, screen_width : Int32) : Nil
Clear display for the current line input
- #console : Console
-
#count_screen_lines(line : String, screen_width : Int32) : Int32
Count the number of screen lines the given line takes up in the terminal.
-
#count_screen_lines(size : Int, screen_width : Int32) : Int32
ditto
- #cursor : Term::Cursor.class
- #env : Hash(String, String)
-
#get_codes(echo : Bool, raw : Bool, nonblock : Bool) : Array(Int32) | Nil
Get input code points FIXME: Fails to handle escape '\e' all by itself
- #history : History
- #history_next : String | Nil
- #history_next? : Bool
- #history_previous : String | Nil
- #history_previous? : Bool
- #input : IO::FileDescriptor
-
#inspect(io : IO) : Nil
Inspect class name and public attributes
- #interrupt : Symbol
- #keyctrl_d : Nil
- #keyctrl_z : Nil
-
#on_key(keys : Enumerable(String | Symbol) = [] of Symbol, &block : HandlerFunc) : Nil
Listen for specific keys (or all keys if
keys
is empty) -
#on_key(*keys : String | Symbol, &block : HandlerFunc) : Nil
Listen for specific keys (or all keys if
keys
is empty) - #output : IO::FileDescriptor
-
#read_keypress(echo : Bool = false, raw : Bool = true, nonblock : Bool = false) : String | Nil
Reads a keypress, including ivisible multibyte codes and return a character as a String.
-
#read_line(*, prompt : String = "", value : String = "", echo : Bool = true, raw : Bool = true, nonblock : Bool = false) : String
Get a signal line from STDIN.
-
#read_multiline(prompt : String = "") : Array(String)
Read multiple lines and return them as an array.
-
#read_multiline(prompt : String = "", & : String -> ) : Array(String)
ditto
-
#track_history? : Bool
Do we want to keep a log of things as they happen
-
#unbuffered(&)
Get input in unbuffered mode.
Macro Summary
Constructor Detail
Instance Method Detail
Clear display for the current line input
Handles clearing input that is longer than the current terminal width, which allows copy + pasting long strings.
Count the number of screen lines the given line takes up in the terminal.
Get input code points
FIXME Fails to handle escape '\e' all by itself
Listen for specific keys (or all keys if keys
is empty)
Listen for specific keys (or all keys if keys
is empty)
Reads a keypress, including ivisible multibyte codes and return a character as a String.
Nothing is echoed to the console. This call will block for a single keypress, but will not wait for Enter to be pressed.
Get a signal line from STDIN. Each key pressed is echoed back to the shell. The input terminates when enter or return key is pressed.
Read multiple lines and return them as an array. Skip empty lines in the returned lines array. The input gathering is terminated by Ctrl+d or Ctrl+z.