Documentation
¶
Overview ¶
Package slash renders the autocomplete suggestion panel that pops up when the user types "/" at the start of the input. It is NOT part of the focus stack — the input keeps focus while the panel is visible; the panel is a passive renderer plus a tiny state machine for the highlighted row and the "Esc dismissed this typing session" flag.
The App owns one *Panel for the lifetime of the program and drives it through Match (on every keystroke), MoveSel (on Up/Down when the panel is visible), Complete (on Tab), and Dismiss / Reset (on Esc and after-submit).
Index ¶
- type Command
- type Panel
- func (p *Panel) Complete(input string, catalog []Command) string
- func (p *Panel) Dismiss()
- func (p *Panel) MoveSel(input string, catalog []Command, delta int) bool
- func (p *Panel) Reset()
- func (p *Panel) Selected() int
- func (p *Panel) View(input string, ctrl ui.Controller, width int, th *theme.Theme) string
- func (p *Panel) Visible(input string, overlayOpen bool, catalog []Command) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
Command is one entry in the suggestion catalog. Name includes the leading "/". Builtin commands ship with the binary; skill entries are added at runtime from Controller.Skills().
func Catalog ¶
func Catalog(ctrl ui.Controller) []Command
Catalog returns the merged builtin + skills catalog. ctrl may be nil — pre-Attach state — in which case only builtins are returned.
func Match ¶
Match returns ALL catalog entries whose name has the trimmed, lowercased input as a prefix, in catalog order. Empty / non-"/" input returns nil so the caller can collapse the panel.
The full list is returned so navigation (MoveSel/Complete) can reach every match; View renders only a maxSuggestions-sized window over it.
type Panel ¶
type Panel struct {
// contains filtered or unexported fields
}
Panel holds the suggestion-overlay's state:
- selected: the highlighted row, clamped to the current match list each render (a shrinking list could otherwise leave selected dangling past the end).
- dismissed: true after Esc, until the input drops back to "" (so re-typing "/" reopens the panel naturally).
func New ¶
func New() *Panel
New returns an empty panel. Cheap; safe to create at App construction time.
func (*Panel) Complete ¶
Complete returns the full name of the currently highlighted suggestion (or "" when no matches). The App uses this to replace the input's value on Tab.
func (*Panel) Dismiss ¶
func (p *Panel) Dismiss()
Dismiss hides the panel until the user clears the input back below "/". Bound to Esc in the App when no overlay is open.
func (*Panel) MoveSel ¶
MoveSel shifts the highlighted row by delta (+1 / -1). Clamps to the bounds of the current match list. Returns true when a move happened so the App can swallow the key event.
func (*Panel) Reset ¶
func (p *Panel) Reset()
Reset clears the dismissed flag — called when the user submits (so the next /-prefixed input shows suggestions again) and when the user blanks the input box.
func (*Panel) Selected ¶
Selected returns the highlighted index (clamped if the match list shrank since the user last navigated).
func (*Panel) View ¶
View renders the panel as a bordered box, or "" when not visible. width is the column count to render within; the panel uses a 4-col inner margin so the bordered box sits inside the App's layout slot.