class TerminalRender::Input

Defined in:

render/terminal/key_event.cr
render/terminal/keys.cr
render/terminal/terminal-input.cr

Constant Summary

BACKSPACE = 8
CARRIAGE_RETURN = 13

Key codes

CTRL_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"
WIN_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

Instance methods inherited from class Object

to_sban(io : IO)
to_sban(encoder : SBAN::Encoder)
to_sban : Bytes
to_sban

Class methods inherited from class Object

from_sban(string_or_io) from_sban

Constructor Detail

def self.new(input : IO::FileDescriptor = STDIN, output : IO::FileDescriptor = STDOUT, env : Hash(String, String) = ENV.to_h) #

[View source]

Instance Method Detail

def console : Console #

[View source]
def env : Hash(String, String) #

[View source]
def get_codes(codes = [] of Int32, nonblock = false) #

Get input code points.


[View source]
def input : IO::FileDescriptor #

[View source]
def output : IO::FileDescriptor #

[View source]
def read_keypress(nonblock = false) #

Reads a keypress, including invisible multibyte codes and return a character as a String.

Nothing is echoed to the console.


[View source]
def unbuffered(&) #

Get input in unbuffered mode.


[View source]