Documentation
¶
Overview ¶
Package findbar is find and replace: a bar on the context line rather than a dialog, in the spirit of less and vim. Matches highlight in the grid as you type and the active cell follows the current one. Options are toggles shown as chips and switched with Alt keys, as in VS Code's find widget. The scope chip says where to search, as Sheets' "Search" choice: this sheet, all sheets, or the range selected when the bar opened; Alt+S goes through them. It knows the UI only through Host.
Index ¶
- type Bar
- func (f *Bar) Again(d int)
- func (f *Bar) Changed()
- func (f *Bar) ContextLine() (left, right string)
- func (f *Bar) Cursor() (x, y int)
- func (f *Bar) Field() int
- func (f *Bar) Found(s *sheet.Sheet, a sheet.Addr) bool
- func (f *Bar) Indicator() string
- func (f *Bar) Key(k tea.KeyPressMsg) tea.Cmd
- func (f *Bar) Layout() []overlay.Box
- func (f *Bar) Matches() []Match
- func (f *Bar) Mouse(e overlay.MouseEvent) tea.Cmd
- func (f *Bar) Open(replace bool)
- func (f *Bar) Options() sheet.FindOptions
- func (f *Bar) Replacing() bool
- func (f *Bar) Reset(sel *sheet.Rect)
- func (f *Bar) Searched() bool
- func (f *Bar) Status() (string, string)
- type Host
- type Match
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// Vim makes Enter close the bar on the match, as / does in vim.
Vim bool
// contains filtered or unexported fields
}
Bar is the find bar: the search, its options and its matches. It outlives being open, so the last search can be reopened or repeated.
func (*Bar) Again ¶
Again goes to the next (d = 1) or previous (d = -1) match of the last search from the active cell, without opening the bar, as n and N do in vim and less, and says where it went. It does nothing without a search to repeat (see Searched).
func (*Bar) ContextLine ¶
ContextLine renders the bar for the context line, with the match count on the right.
func (*Bar) Cursor ¶
Cursor puts the terminal cursor in the focused field, whose text ends its part.
func (*Bar) Mouse ¶
func (f *Bar) Mouse(e overlay.MouseEvent) tea.Cmd
Mouse focuses a field or flips a chip on the bar; a click anywhere else closes the bar and lands where it was clicked.
func (*Bar) Open ¶
Open focuses the query, or with replace the replacement once there's a query, and searches.
func (*Bar) Replacing ¶
Replacing reports whether the replacement field shows, and Field which field is focused: 0 the query, 1 the replacement.
func (*Bar) Reset ¶
Reset gets the bar ready to open over the sheet shown, keeping the last search. A multi-cell selection sel becomes the search scope, as Sheets' "specific range". The kept query is loaded into the edit line.
type Host ¶
type Host interface {
Theme() *theme.Theme
Size() (width, height int)
// Line is the shared edit line the focused field is typed in.
Line() *lineedit.Line
Book() *sheet.Workbook
// Trace is where searches are timed, nested in what is open.
Trace() *telemetry.Trace
// At is the sheet shown and its active cell.
At() (*sheet.Sheet, sheet.Addr)
// Show shows sheet s with a as the active cell.
Show(s *sheet.Sheet, a sheet.Addr)
// Note says how the last action went, on the context line.
Note(msg string)
// Edited marks the file modified.
Edited()
// Leave closes the bar, keeping its search for Ctrl+F and find next.
Leave()
// Press handles a mouse press outside the bar, as on the grid.
Press(x, y int, button tea.MouseButton) tea.Cmd
}
Host is what the find bar needs of the UI.