gsh/input/editor
The editor module is a custom, raw-mode multiline text editor built from scratch.
Standard input methods (like erlang:get_line) block the thread and do not
allow for custom keybindings, autocomplete menus, or multiline cursor traversal.
This module solves that by capturing individual keystrokes and manually
calculating 2D terminal cursor positions using ANSI escape sequences.
Types
Tracks the complete state of a single REPL prompt session.
pub type Editor {
Editor(
buffer: String,
cursor: Int,
history: List(String),
history_index: Int,
saved_buffer: option.Option(String),
menu: option.Option(String),
)
}
Constructors
-
Editor( buffer: String, cursor: Int, history: List(String), history_index: Int, saved_buffer: option.Option(String), menu: option.Option(String), )Arguments
- buffer
-
The current raw text being typed by the user
- cursor
-
The 1D index of where the cursor is inside the buffer
- history
-
Previously executed REPL commands
- history_index
-
Current position when navigating history with ArrowUp/ArrowDown
- saved_buffer
-
Temporarily saves the current typing buffer if the user arrows up into history
- menu
-
A pre-rendered string grid of autocomplete suggestions, floating below the prompt