Help us shape the future of Go! Take the 2026 Go Developer Survey

searchmodal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package searchmodal shows the incremental search prompt and its match counter. It holds no search logic: the parent model matches against the diff and pushes the query and the result counts in for display.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model is the search prompt. It mirrors state the parent model owns, so the query and counts it displays are only as current as the last SetQuery and UpdateResults call.

func New

func New() Model

New returns a hidden prompt with an empty query.

func (*Model) Hide

func (m *Model) Hide()

Hide closes the prompt, leaving the query in place for the parent to read.

func (Model) IsVisible

func (m Model) IsVisible() bool

IsVisible reports whether the prompt is open, which is how the parent decides to route keys here.

func (*Model) SetQuery

func (m *Model) SetQuery(query string)

SetQuery replaces the displayed query. It runs no search, so the counts stay as UpdateResults left them until the parent calls it again.

func (*Model) Show

func (m *Model) Show()

Show opens the prompt with the query and counts cleared, so a reopen never displays the previous search.

func (*Model) UpdateResults

func (m *Model) UpdateResults(matchCount, currentIdx int)

UpdateResults sets the match counter. The current index is 0-based and is displayed one higher, so pass -1 when no match is current.

func (Model) View

func (m Model) View(width, _ int) string

View renders the prompt centered in the given terminal size, returning the empty string while hidden.

Jump to

Keyboard shortcuts

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