Summary
With the alternate buffer owning the screen, tmux's built-in search (C-a [ then /) is no longer available for searching history. The CLI needs its own search to replace this lost functionality.
Expected behaviour
Entering search
/ enters forward search mode (search downward from current position)
? enters backward search mode (search upward from current position)
- Both open a search input at the bottom of the screen, replacing the editor/status zone
Search display
The zone collapses to a single-line search bar at the bottom:
/ query here_ [3/17 matches]
or for backward search:
? query here_ [3/17 matches]
- Left side: direction indicator (
/ or ?) + query input with cursor
- Right side: match count
[current/total matches]
- The rest of the screen (above the search bar) shows history with matches highlighted
- Current match is highlighted differently from other matches (e.g. bright/bold vs dim highlight)
- Search is live/incremental -- results update as you type
Navigation
Following vim/less/tmux convention:
n -- next match in the search direction (forward for /, backward for ?)
N -- next match in the reverse direction
Enter -- accept search, stay at current match position in history mode
Esc -- cancel search, return to live mode
Backspace -- delete character from query
- Arrow keys up/down -- also navigate between matches (alternative to n/N)
History viewport during search
- History viewport scrolls to center the current match in view
- All matches highlighted across the visible portion
- Current match visually distinct (bold/inverse vs just colored background)
- If no matches, the counter shows
[0/0 matches] and history stays at current position
Returning from search
Enter leaves search mode but stays in history mode at the current match position (can continue browsing with PgUp/PgDown)
Esc exits search entirely and returns to live mode (same as pressing Esc in history mode)
Guidance
This is another zone mode alongside editor, history_scroll, and tool_approval (#158). The search bar replaces the zone content, similar to how history mode collapses the editor (#154).
The search state lives alongside HistoryViewport -- it needs: query string, match positions (line indices), current match index, search direction. Match positions are recomputed on query change against displayBuffer (already available, same source as history viewport).
Highlighting requires marking match regions within lines. The renderer needs to apply highlight styling (ANSI codes) to matched substrings. Two styles: current match (e.g. \x1b[30;43m black on yellow) and other matches (e.g. \x1b[33m yellow text or \x1b[7m inverse).
Key routing: search mode intercepts all keys for the query input. Only n, N, Enter, Esc, arrows, and Backspace have special handling. All other printable characters append to the query.
Depends on alternate buffer (#151), history viewport (#152), and bottom-anchor (#153).
Summary
With the alternate buffer owning the screen, tmux's built-in search (
C-a [then/) is no longer available for searching history. The CLI needs its own search to replace this lost functionality.Expected behaviour
Entering search
/enters forward search mode (search downward from current position)?enters backward search mode (search upward from current position)Search display
The zone collapses to a single-line search bar at the bottom:
or for backward search:
/or?) + query input with cursor[current/total matches]Navigation
Following vim/less/tmux convention:
n-- next match in the search direction (forward for/, backward for?)N-- next match in the reverse directionEnter-- accept search, stay at current match position in history modeEsc-- cancel search, return to live modeBackspace-- delete character from queryHistory viewport during search
[0/0 matches]and history stays at current positionReturning from search
Enterleaves search mode but stays in history mode at the current match position (can continue browsing with PgUp/PgDown)Escexits search entirely and returns to live mode (same as pressing Esc in history mode)Guidance
This is another zone mode alongside
editor,history_scroll, andtool_approval(#158). The search bar replaces the zone content, similar to how history mode collapses the editor (#154).The search state lives alongside
HistoryViewport-- it needs: query string, match positions (line indices), current match index, search direction. Match positions are recomputed on query change againstdisplayBuffer(already available, same source as history viewport).Highlighting requires marking match regions within lines. The renderer needs to apply highlight styling (ANSI codes) to matched substrings. Two styles: current match (e.g.
\x1b[30;43mblack on yellow) and other matches (e.g.\x1b[33myellow text or\x1b[7minverse).Key routing: search mode intercepts all keys for the query input. Only
n,N,Enter,Esc, arrows, andBackspacehave special handling. All other printable characters append to the query.Depends on alternate buffer (#151), history viewport (#152), and bottom-anchor (#153).