Documentation
¶
Overview ¶
Package input provides the user input subsystem for the TUI.
It integrates reeflective/readline as the line-editing backend and exposes a clean Reader API for the TUI main loop. Completion, multiline editing, and persistent history are all configured here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandInfo ¶
CommandInfo describes a slash command for completion purposes.
type Completer ¶
type Completer struct {
// contains filtered or unexported fields
}
Completer provides tab-completion for the readline shell. It supports slash command completion and can be extended with additional completion sources.
func NewCompleter ¶
func NewCompleter(commands []CommandInfo) *Completer
NewCompleter creates a new completer with the given command list.
func (*Completer) Complete ¶
func (c *Completer) Complete(line []rune, cursor int) readline.Completions
Complete is the readline Completer function. It examines the current line and cursor position to produce relevant completions.
func (*Completer) SetCommands ¶
func (c *Completer) SetCommands(commands []CommandInfo)
SetCommands updates the command list used for completion. This allows the command registry to be updated after the completer is created.
type Config ¶
type Config struct {
// Prompt is the primary prompt string (default: "> ").
Prompt string
// MultilinePrompt is shown on continuation lines (default: "· ").
MultilinePrompt string
// History configures persistent command history.
History HistoryConfig
}
Config holds all configuration for the input Reader.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type HistoryConfig ¶
type HistoryConfig struct {
// FilePath overrides the default history file location.
// If empty, defaults to $HOME/.echoctl_history.
FilePath string
// MaxEntries is the maximum number of history entries to keep.
// Zero means unlimited.
MaxEntries int
}
HistoryConfig holds options for the persistent command history.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps a reeflective/readline Shell to provide a high-level line-reading API for the TUI main loop.
It handles prompt rendering, multiline editing (Shift+Enter or trailing backslash), tab completion, and persistent history — all through a single [ReadLine] call.
func NewReader ¶
func NewReader(cfg Config, commands []CommandInfo) (*Reader, error)
NewReader creates a new input Reader with the given configuration. The caller should call Reader.Close when done.
func (*Reader) ReadLine ¶
ReadLine displays the prompt and reads one (possibly multi-line) user input. It returns the trimmed input string.
Errors:
- io.EOF when the user presses Ctrl-D on an empty line.
- readline.ErrInterrupt on Ctrl-C.
func (*Reader) SetCommands ¶
func (r *Reader) SetCommands(commands []CommandInfo)
SetCommands updates the slash-command list used by the completer.