From b5c33ca2b769e87e86e1ed6d2c19dfce14c242c0 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 25 Dec 2025 18:05:15 +0000 Subject: [PATCH] Add selection_mode format variable for copy mode, from Mike Jonkmans in GitHub issue 4773. --- tmux.1 | 1 + window-copy.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/tmux.1 b/tmux.1 index fe228dd2..a93a002e 100644 --- a/tmux.1 +++ b/tmux.1 @@ -6238,6 +6238,7 @@ The following variables are available, where appropriate: .It Li "selection_active" Ta "" Ta "1 if selection started and changes with the cursor in copy mode" .It Li "selection_end_x" Ta "" Ta "X position of the end of the selection" .It Li "selection_end_y" Ta "" Ta "Y position of the end of the selection" +.It Li "selection_mode" Ta "" Ta "Selection mode" .It Li "selection_present" Ta "" Ta "1 if selection started in copy mode" .It Li "selection_start_x" Ta "" Ta "X position of the start of the selection" .It Li "selection_start_y" Ta "" Ta "Y position of the start of the selection" diff --git a/window-copy.c b/window-copy.c index f8700555..87d0dea8 100644 --- a/window-copy.c +++ b/window-copy.c @@ -956,6 +956,18 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft) format_add(ft, "selection_present", "0"); } + switch (data->selflag) { + case SEL_CHAR: + format_add(ft, "selection_mode", "char"); + break; + case SEL_WORD: + format_add(ft, "selection_mode", "word"); + break; + case SEL_LINE: + format_add(ft, "selection_mode", "line"); + break; + } + format_add(ft, "search_present", "%d", data->searchmark != NULL); format_add(ft, "search_timed_out", "%d", data->timeout); if (data->searchcount != -1) {