aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoruser <user@clank>2026-09-08 16:58:24 +0200
committeruser <user@clank>2026-09-08 16:58:24 +0200
commit935fb7e93726dcb8ab0529c2dbcb6b5e75656794 (patch)
tree824b46e4cff68b7d4fa0c333717684ce273c9b10 /include
parentrelease: v0.1.6 paperwork -- formula and PKGBUILD pinned (diff)
downloadslosh-935fb7e93726dcb8ab0529c2dbcb6b5e75656794.tar.gz
slosh-935fb7e93726dcb8ab0529c2dbcb6b5e75656794.tar.xz
slosh-935fb7e93726dcb8ab0529c2dbcb6b5e75656794.zip
search: a scrollback search bar on /, matches highlighted
C-a / opens an inline search bar on the focused pane's status row, on lib-vt's GhosttySearch (D4's pattern: the scrollback walk, reflow and alt-screen survival are the library's, the UI and the wiring are ours). Type to search live; the viewport follows the current match; up/down (or C-n/C-p) step through them with wraparound; Enter keeps your place, Escape snaps back. A k-of-n counter reads on the right, or "no matches". Every match on screen is tinted, and the one the bar is on is tinted apart -- warm gold by default, painted after the shader pass so the scrolled wash does not dilute a match you are hunting for. Four themeable colours (search_fg/bg, search_cur_fg/bg). Bare / took the key from help, which keeps ?; that needed the legacy decoder to read the shift out of a punctuation byte the way it already did for capitals -- without it ? and / decode identically (SLASH, no mods) and cannot be two keys on a client without the kitty protocol. tests/test_search.py drives it end to end (39 checks): the bar, the counter, stepping and wrap, all-match vs current highlighting, Enter/ Escape, new output updating the count, case-insensitivity, the keyboard belonging to the bar, click-away, and that / and ? no longer collide.
Diffstat (limited to 'include')
-rw-r--r--include/app_internal.h18
-rw-r--r--include/config.h6
-rw-r--r--include/slosh.h24
3 files changed, 48 insertions, 0 deletions
diff --git a/include/app_internal.h b/include/app_internal.h
index af59b6f..be3f979 100644
--- a/include/app_internal.h
+++ b/include/app_internal.h
@@ -268,6 +268,17 @@ struct app {
char query[64];
size_t sel;
+ /* The search bar: an inline editor like the rename, not a modal like the
+ * picker, because the whole point is watching the pane while you drive it.
+ * It lives on the searched pane's status row, owns the keyboard while open,
+ * and the query is pushed to the pane's GhosttySearch per keystroke -- the
+ * results live in the pane (they are terminal state), only the typing lives
+ * here. `search_id` rather than "the focused pane" so a click that moves
+ * focus commits the search instead of quietly re-aiming it. */
+ bool searching;
+ uint32_t search_id;
+ char search_buf[128];
+
/* Renaming in place: the title cell becomes the editor, so the name is typed
* where it will live rather than in a dialog somewhere else. A pane's title
* and a tab's label are the same gesture on two different things, so this is
@@ -387,6 +398,10 @@ extern config_t CFG;
#define FINDER_BG (CFG.finder_bg)
#define FINDER_SEL_FG (CFG.finder_sel_fg)
#define FINDER_SEL_BG (CFG.finder_sel_bg)
+#define SEARCH_FG (CFG.search_fg)
+#define SEARCH_BG (CFG.search_bg)
+#define SEARCH_CUR_FG (CFG.search_cur_fg)
+#define SEARCH_CUR_BG (CFG.search_cur_bg)
#define TOAST_FG (CFG.toast_fg)
#define TOAST_BG (CFG.toast_bg)
#define RENAME_FG (CFG.rename_fg)
@@ -456,6 +471,9 @@ void picker_accept(app_t *a, const char *action);
void purpose_begin(app_t *a, uint32_t id);
void rename_begin(app_t *a, uint32_t id);
void rename_tab_begin(app_t *a, uint32_t id);
+void search_begin(app_t *a);
+void search_end(app_t *a, bool keep_view);
+bool search_key(app_t *a, const input_event_t *ev);
void draw_splash(app_t *a, screen_t *s);
/* Say that a rect was painted over the panes this frame; see `overlays`. */
diff --git a/include/config.h b/include/config.h
index 69a017b..0d8a396 100644
--- a/include/config.h
+++ b/include/config.h
@@ -82,6 +82,7 @@ typedef enum {
ACT_SCROLL_PAGE_DOWN,
ACT_SCROLL_TOP,
ACT_SCROLL_BOTTOM,
+ ACT_SEARCH,
ACT_RESIZE_LEFT,
ACT_RESIZE_RIGHT,
ACT_RESIZE_UP,
@@ -413,6 +414,11 @@ typedef struct {
/* the pane finder */
color_t finder_fg, finder_bg, finder_sel_fg, finder_sel_bg;
+ /* scrollback search: every match on screen is tinted `search_*`, and the one
+ * the bar is on is tinted `search_cur_*` instead, so "all of them" and "this
+ * one" read as two things rather than one. */
+ color_t search_fg, search_bg, search_cur_fg, search_cur_bg;
+
/* the in-place editor a double-click opens on a pane's title */
color_t rename_fg, rename_bg;
diff --git a/include/slosh.h b/include/slosh.h
index 6c95426..8f96543 100644
--- a/include/slosh.h
+++ b/include/slosh.h
@@ -270,6 +270,30 @@ void pane_scroll(pane_t *p, int delta);
void pane_scroll_edge(pane_t *p, bool top);
bool pane_scrolled(const pane_t *p);
void pane_scroll_pos(const pane_t *p, uint32_t *above, uint32_t *total);
+/* Scrollback search, on lib-vt's machinery. Set a needle to search for it
+ * (empty or NULL clears); the viewport follows the current match as it moves.
+ * `step` moves through the matches -- `older` is up into history -- wrapping
+ * at either end. `refresh` catches up with a terminal that has kept printing,
+ * once per composed frame while a search is open. `pos` is the "k of n": true
+ * with `idx` (0-based, newest first) when a match is selected, `total` filled
+ * either way. */
+void pane_search_set(pane_t *p, const char *needle);
+bool pane_search_step(pane_t *p, bool older);
+void pane_search_refresh(pane_t *p);
+bool pane_search_pos(const pane_t *p, size_t *idx, size_t *total);
+void pane_search_close(pane_t *p);
+
+/* One on-screen match, in the pane's viewport coordinates: a run of columns
+ * `x0`..`x1` on `row`. A match that wraps a row comes back as one mark per
+ * row it covers. `current` is the one the bar is on -- the one the counter
+ * counts to and the keys step from -- so a caller can tint it apart from the
+ * rest. Fill `out` up to `max`; returns how many. Read after a refresh, drawn
+ * before the terminal changes again. */
+typedef struct {
+ uint16_t row, x0, x1;
+ bool current;
+} pane_mark_t;
+size_t pane_search_marks(const pane_t *p, pane_mark_t *out, size_t max);
bool pane_alt_screen(const pane_t *p);
/* Whether the line being typed looks empty, counted from the keys forwarded
* since the last Enter. An estimate: the shell's line editor is on the far