From 90c91d61482920881bb0c1ecf4babc001b3f598d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 9 Apr 2022 17:57:29 +0200 Subject: search/render: initial support for highlighting all visible matches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this patch, only the currently “selected” match was highlighted (by having the “selected” attribute, and by *not* dimming it, like the rest of the grid during a scrollback search). With this patch, we now highlight matches within the viewport. While searching, only the “primary” match is searched-for, and tracked. Then, when rendering a frame, we find all “secondary” matches as well. “holes” are added to the search-mode overlay by the means of an search-match iterator. The iterator’s text matching logic is *very* similar to what we do when the search criteria has been updated, and we re-search the scrollback. It should be possible to refactor this, and share code. --- search.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'search.h') diff --git a/search.h b/search.h index 18af0d62..24828512 100644 --- a/search.h +++ b/search.h @@ -14,3 +14,11 @@ void search_input( void search_add_chars(struct terminal *term, const char *text, size_t len); void search_selection_cancelled(struct terminal *term); + +struct search_match_iterator { + struct terminal *term; + struct coord start; +}; + +struct search_match_iterator search_matches_new_iter(struct terminal *term); +struct range search_matches_next(struct search_match_iterator *iter); -- cgit v1.3