gsh/input/key
The key module defines the semantic domain model for terminal input.
When the terminal is in raw mode, every keystroke (including multi-byte ANSI escape sequences for arrow keys) is read directly. This module provides a clean algebraic data type to represent those inputs, abstracting away the low-level byte parsing so the editor can simply pattern match on meaningful events.
Types
Represents a parsed keystroke or terminal control event.
pub type Key {
Character(String)
Enter
Backspace
Tab
ArrowUp
ArrowDown
ArrowLeft
ArrowRight
CtrlL
Unknown
}
Constructors
-
Character(String)A standard printable character (e.g., “a”, “A”, “1”, “ “, or symbols).
-
EnterThe Enter / Return key, used to submit a command or create a new line in multiline blocks.
-
BackspaceThe Backspace key, used to delete the character to the left of the cursor.
-
TabThe Tab key, used to trigger the autocomplete engine and floating menu.
-
ArrowUpThe Up Arrow key, typically used to traverse backward through REPL history.
-
ArrowDownThe Down Arrow key, typically used to traverse forward through REPL history.
-
ArrowLeftThe Left Arrow key, used to move the cursor backward within the text buffer.
-
ArrowRightThe Right Arrow key, used to move the cursor forward within the text buffer.
-
CtrlLThe Ctrl+L chord, which is the standard Unix terminal shortcut for clearing the screen.
-
UnknownAny unrecognized or unhandled control sequence (e.g., Page Up, Home, End).