From 66ce85fbb591ded1d8d17e02ce555f9e5f768cad Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 27 Aug 2024 07:31:26 +0000 Subject: [PATCH] Add search_count and search_count_partial formats in copy mode, GitHub issue 4091. --- usr.bin/tmux/tmux.1 | 6 ++++-- usr.bin/tmux/window-copy.c | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 2a905aae602..eea5747ae70 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.952 2024/08/26 07:09:34 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.953 2024/08/27 07:31:26 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 26 2024 $ +.Dd $Mdocdate: August 27 2024 $ .Dt TMUX 1 .Os .Sh NAME @@ -5584,6 +5584,8 @@ The following variables are available, where appropriate: .It Li "scroll_position" Ta "" Ta "Scroll position in copy mode" .It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane" .It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane" +.It Li "search_count" Ta "" Ta "Count of search results" +.It Li "search_count_partial" Ta "" Ta "1 if search count is partial count" .It Li "search_match" Ta "" Ta "Search match if any" .It Li "search_present" Ta "" Ta "1 if search started in copy mode" .It Li "selection_active" Ta "" Ta "1 if selection started and changes with the cursor in copy mode" diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 8d0ab752408..697b7b56aea 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.351 2024/08/26 07:09:34 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.352 2024/08/27 07:31:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -825,6 +825,10 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft) } format_add(ft, "search_present", "%d", data->searchmark != NULL); + if (data->searchcount != -1) { + format_add(ft, "search_count", "%d", data->searchcount); + format_add(ft, "search_count_partial", "%d", data->searchmore); + } format_add_cb(ft, "search_match", window_copy_search_match_cb); format_add_cb(ft, "copy_cursor_word", window_copy_cursor_word_cb); -- 2.20.1