Module: AgentsControl::Keyboard

Included in:
Menu, Prompt
Defined in:
lib/agents_control/keyboard.rb

Overview

Reading keystrokes from the terminal in raw mode.

Split out on its own because two things need the keyboard: the input line with its command palette, and the settings menu. Parsing escape sequences and multi-byte characters is a place it's easy to get wrong twice.

Constant Summary collapse

UP =
"\e[A"
DOWN =
"\e[B"
RIGHT =
"\e[C"
LEFT =
"\e[D"
ENTER =
["\r", "\n"].freeze
BACKSPACE =
["\x7F", "\b"].freeze
CTRL_C =
"\x03"
CTRL_D =
"\x04"
CTRL_A =
"\x01"
CTRL_E =
"\x05"
CTRL_U =
"\x15"
TAB =
"\t"
ESC =
"\e"