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).

  • Enter

    The Enter / Return key, used to submit a command or create a new line in multiline blocks.

  • Backspace

    The Backspace key, used to delete the character to the left of the cursor.

  • Tab

    The Tab key, used to trigger the autocomplete engine and floating menu.

  • ArrowUp

    The Up Arrow key, typically used to traverse backward through REPL history.

  • ArrowDown

    The Down Arrow key, typically used to traverse forward through REPL history.

  • ArrowLeft

    The Left Arrow key, used to move the cursor backward within the text buffer.

  • ArrowRight

    The Right Arrow key, used to move the cursor forward within the text buffer.

  • CtrlL

    The Ctrl+L chord, which is the standard Unix terminal shortcut for clearing the screen.

  • Unknown

    Any unrecognized or unhandled control sequence (e.g., Page Up, Home, End).

Search Document