Add in-file search (find bar)

- pool: SearchTask + FindSubstring (case-insensitive substring scan with
  query generation for stale-result dropping)
- editor: FindState on EditorState; find bar handlers (ToggleFind/FindNext/
  FindPrev/FindClose); worker-pool scan of the in-memory content; edit-aware
  offset remapping (shift after, drop overlapping); next/prev with
  wrap-around, selection + scroll to match; main-owned find_bar input
  forwarded via FindQueryChan (browser search_bar precedent)
- ui: find-bar layout below the margin-free top bar; search icon on the top
  bar right; new search/close/chevron_up/chevron_down icons
- logic: findQueryChan, TypeSearch result handling, findReset on open
- frame: FindQuery field (main syncs the widget text like Query)
- tests: pool scan tests, find-state unit tests (remap, nav, gen gate,
  focus), e2e find bar + navigation + edit-survival on real files
- docs: spec/architecture/development_plan updated (search implemented,
  channel/task tables)
This commit is contained in:
gmp
2026-08-20 00:02:54 -04:00
parent 49b60a79e8
commit 78d240eedb
22 changed files with 1081 additions and 10 deletions
+10
View File
@@ -101,6 +101,11 @@ func run(w *app.Window) error {
var searchEditor widget.Editor
renderer.RegisterGioEditor("search_bar", &searchEditor)
// The find bar's (in-file search) widget.Editor is main-owned the same
// way; its text is forwarded via FindQueryChan (editor.findSetQuery).
var findEditor widget.Editor
renderer.RegisterGioEditor("find_bar", &findEditor)
// Clipboard plumbing (architecture.md §6.3): the logic goroutine only
// REQUESTS clipboard operations through channels (copy/cut write, paste
// read); the main goroutine executes the Gio ops during a frame and
@@ -209,6 +214,8 @@ func run(w *app.Window) error {
// The logic goroutine handles filtering and triggers a new frame.
newQuery := searchEditor.Text()
sendQuery := newQuery != frame.Query
newFind := findEditor.Text()
sendFind := newFind != frame.FindQuery
events := renderer.CheckGestures(e.Source, gtx.Metric)
// Keep frames flowing while a long press is pending: a stationary
// finger generates no pointer events, so without this the window
@@ -305,6 +312,9 @@ func run(w *app.Window) error {
if sendQuery {
logic.SearchQueryChan() <- newQuery
}
if sendFind {
logic.FindQueryChan() <- newFind
}
logic.LayoutChan() <- ui.LayoutFeedback{
GlyphLayout: glyphLayout,
WindowText: frame.WindowText,