Documentation
¶
Overview ¶
Package findbar renders an in-buffer search bar — the narrow query input that overlays an editor when the user hits Ctrl-F. It owns nothing but the query, the active match index, and the navigation buttons; the actual buffer-side search is performed by the consumer (FindMatches walks any "lines" string for plain or case-insensitive matches; if the consumer wants fuzzy or regex they wire their own).
Composition shape:
bar := findbar.New(theme.Default) bar = bar.WithQuery(q).WithMatches(matches, current) // In Update: pass tea.KeyMsg to bar.Update; act on its messages.
The bar emits four messages: QueryMsg{Value} when the input changes, NextMsg / PrevMsg when the user hits Enter/F3/Shift-F3, CloseMsg when the user hits Esc. The consumer is the one that scrolls the editor to the next match — the bar is purely an input.
Index ¶
- type Bar
- func (b Bar) Blur() Bar
- func (b Bar) CaseSensitive() bool
- func (b Bar) Current() int
- func (b Bar) CurrentMatch() (Match, bool)
- func (b Bar) Focus() Bar
- func (b Bar) Focused() bool
- func (b Bar) Init() tea.Cmd
- func (b Bar) MatchCount() int
- func (b Bar) Query() string
- func (b Bar) Update(msg tea.Msg) (Bar, tea.Cmd)
- func (b Bar) View() string
- func (b Bar) WithCaseSensitive(on bool) Bar
- func (b Bar) WithMatches(matches []Match, current int) Bar
- func (b Bar) WithQuery(s string) Bar
- func (b Bar) WithWidth(w int) Bar
- type CloseMsg
- type Match
- type NextMsg
- type PrevMsg
- type QueryMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar is a Bubble Tea model for the find bar.
func (Bar) CaseSensitive ¶
CaseSensitive reports the bar's current match mode.
func (Bar) CurrentMatch ¶
CurrentMatch returns the active match and true when one exists.
func (Bar) MatchCount ¶
MatchCount returns the size of the bar's match set.
func (Bar) Update ¶
Update implements tea.Model. It returns its own messages via Cmd rather than mutating any parent state; the consumer is expected to re-issue queries and navigate the editor on each message.
func (Bar) View ¶
View renders the bar: query input on the left, match counter on the right ("3 / 12" or "no matches"), wrapped in a single-line bordered frame the same height as a status-bar row.
func (Bar) WithCaseSensitive ¶
WithCaseSensitive toggles case-sensitive matching for FindMatches.
func (Bar) WithMatches ¶
WithMatches replaces the match set; current is clamped to a valid index or -1 when empty.
type Match ¶
Match is a single hit inside the buffer. Row is 0-based; ColStart and ColEnd are rune indices (start-inclusive, end-exclusive).
func FindMatches ¶
FindMatches is a stateless helper: walk lines for every occurrence of query and return the match set in document order. Empty queries return nil. The bar passes b.CaseSensitive() through; consumers can call FindMatches directly with any boolean.
type NextMsg ¶
type NextMsg struct{}
NextMsg / PrevMsg are emitted when the user requests cursor motion.
