Files
ghostty/include
Mitchell Hashimoto 4b51f521d4 libghostty: add terminal search API (#14097)
This exposes the terminal search API through libghostty C and Zig APIs.

This was previously available through the Zig APIs but forced our
threading model. I've now extracted the full terminal search state to a
new `terminal.search.TerminalSearch` structure so threading isn't
forced. The C API is completely new.

## Example (C)

```c
GhosttySearch search;
ghostty_search_new(NULL, &search, terminal);

GhosttyString needle = { (const uint8_t *)"error", 5 };
ghostty_search_set(search, GHOSTTY_SEARCH_OPT_NEEDLE, &needle);
ghostty_search_run(search);

// Find bar chrome: "k of n"
size_t total, idx;
ghostty_search_get(search, GHOSTTY_SEARCH_DATA_TOTAL_MATCHES, &total);

// Enter: select the next match (wraps, scrolls the viewport if needed)
ghostty_search_set(search, GHOSTTY_SEARCH_OPT_SELECT_NEXT, NULL);
ghostty_search_get(search, GHOSTTY_SEARCH_DATA_SELECTED_INDEX, &idx);

ghostty_search_free(search);
```
2026-08-31 14:23:38 -07:00
..