autocomplete

package
v0.0.54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package autocomplete provides a small searchable single-line selection control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyMap

type KeyMap struct {
	Up, Down, Choose, Close key.Binding
}

KeyMap supplies the active surface's bindings. Tab is deliberately not an autocomplete action: callers retain it for focus navigation.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model combines a Bubbles text input with a bounded match list. It owns query, selection, acceptance, and geometry; callers own options and presentation.

func New

func New(options []Option, keys KeyMap) Model

New constructs a control with the supplied stable options and active bindings.

func (*Model) Blur

func (m *Model) Blur()

Blur hides suggestions without changing the query or accepted value.

func (*Model) Focus

func (m *Model) Focus() tea.Cmd

Focus focuses the input and opens its matches when geometry permits.

func (Model) InputView

func (m Model) InputView() string

InputView returns the Bubbles input presentation.

func (Model) Open

func (m Model) Open() bool

Open reports whether suggestions are currently visible and actionable.

func (Model) Query

func (m Model) Query() string

Query returns the current draft query.

func (*Model) Search

func (m *Model) Search()

Search starts a fresh query without discarding an accepted selection. Typing replaces that selection; an untouched empty search still retains its value.

func (*Model) SetGeometry

func (m *Model) SetGeometry(width, height int)

SetGeometry configures the visible match-list area. Invalid geometry suppresses input and actions until a later usable offer, preserving the draft unchanged.

func (*Model) SetStyles

func (m *Model) SetStyles(styles textinput.Styles)

SetStyles configures the caller-owned input presentation.

func (*Model) SetValue

func (m *Model) SetValue(value string) bool

SetValue selects an option by stable value. It returns false for an unknown value.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (cmd tea.Cmd, handled bool)

Update routes input, cursor, paste, and active action messages. handled is false for unclaimed keys such as Tab so the enclosing form can route them normally.

func (Model) Value

func (m Model) Value() string

Value returns the accepted value, or the exact stable value matching a fully typed identifier. A highlighted row alone never produces a value.

func (*Model) View

func (m *Model) View() bounded.ListView

View returns the current bounded suggestion projection for caller rendering.

type Option

type Option struct {
	Value, Label, Search string
}

Option is one caller-owned choice. Value identifies the choice, Label is its presentation, and Search is additional text that should find it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL