From: nicm Date: Fri, 26 Feb 2021 07:53:26 +0000 (+0000) Subject: Add a couple of format variables for active and last window index. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ad5116fe1f87c36a53d9a0cd305dba97da67ebc2;p=openbsd Add a couple of format variables for active and last window index. --- diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index abeb9537212..a5b485335bf 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.277 2021/02/24 09:22:15 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.278 2021/02/26 07:53:26 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -2099,6 +2099,28 @@ format_cb_version(__unused struct format_tree *ft) return (xstrdup(getversion())); } +/* Callback for active_window_index. */ +static void * +format_cb_active_window_index(struct format_tree *ft) +{ + if (ft->s != NULL) + return (format_printf("%u", ft->s->curw->idx)); + return (NULL); +} + +/* Callback for last_window_index. */ +static void * +format_cb_last_window_index(struct format_tree *ft) +{ + struct winlink *wl; + + if (ft->s != NULL) { + wl = RB_MAX(winlinks, &ft->s->windows); + return (format_printf("%u", wl->idx)); + } + return (NULL); +} + /* Callback for window_active. */ static void * format_cb_window_active(struct format_tree *ft) @@ -2496,6 +2518,9 @@ struct format_table_entry { * Only variables which are added by the caller go into the tree. */ static const struct format_table_entry format_table[] = { + { "active_window_index", FORMAT_TABLE_STRING, + format_cb_active_window_index + }, { "alternate_on", FORMAT_TABLE_STRING, format_cb_alternate_on }, @@ -2631,6 +2656,9 @@ static const struct format_table_entry format_table[] = { { "keypad_flag", FORMAT_TABLE_STRING, format_cb_keypad_flag }, + { "last_window_index", FORMAT_TABLE_STRING, + format_cb_last_window_index + }, { "mouse_all_flag", FORMAT_TABLE_STRING, format_cb_mouse_all_flag }, diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index cf5a39006b7..5aed569ddf1 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.823 2021/02/22 08:18:13 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.824 2021/02/26 07:53: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: February 22 2021 $ +.Dd $Mdocdate: February 26 2021 $ .Dt TMUX 1 .Os .Sh NAME @@ -4756,6 +4756,7 @@ will be replaced by The following variables are available, where appropriate: .Bl -column "XXXXXXXXXXXXXXXXXXX" "XXXXX" .It Sy "Variable name" Ta Sy "Alias" Ta Sy "Replaced with" +.It Li "active_window_index" Ta "" Ta "Index of active window in session" .It Li "alternate_on" Ta "" Ta "1 if pane is in alternate screen" .It Li "alternate_saved_x" Ta "" Ta "Saved cursor X in alternate screen" .It Li "alternate_saved_y" Ta "" Ta "Saved cursor Y in alternate screen" @@ -4763,7 +4764,6 @@ The following variables are available, where appropriate: .It Li "buffer_name" Ta "" Ta "Name of buffer" .It Li "buffer_sample" Ta "" Ta "Sample of start of buffer" .It Li "buffer_size" Ta "" Ta "Size of the specified buffer in bytes" -.It Li "config_files" Ta "" Ta "List of configuration files loaded" .It Li "client_activity" Ta "" Ta "Time client last had activity" .It Li "client_cell_height" Ta "" Ta "Height of each client cell in pixels" .It Li "client_cell_width" Ta "" Ta "Width of each client cell in pixels" @@ -4790,6 +4790,7 @@ The following variables are available, where appropriate: .It Li "command_list_alias" Ta "" Ta "Command alias if listing commands" .It Li "command_list_name" Ta "" Ta "Command name if listing commands" .It Li "command_list_usage" Ta "" Ta "Command usage if listing commands" +.It Li "config_files" Ta "" Ta "List of configuration files loaded" .It Li "copy_cursor_line" Ta "" Ta "Line the cursor is on in copy mode" .It Li "copy_cursor_word" Ta "" Ta "Word under cursor in copy mode" .It Li "copy_cursor_x" Ta "" Ta "Cursor X position in copy mode" @@ -4812,6 +4813,7 @@ The following variables are available, where appropriate: .It Li "insert_flag" Ta "" Ta "Pane insert flag" .It Li "keypad_cursor_flag" Ta "" Ta "Pane keypad cursor flag" .It Li "keypad_flag" Ta "" Ta "Pane keypad flag" +.It Li "last_window_index" Ta "" Ta "Index of last window in session" .It Li "line" Ta "" Ta "Line number in the list" .It Li "mouse_all_flag" Ta "" Ta "Pane mouse all flag" .It Li "mouse_any_flag" Ta "" Ta "Pane mouse any flag" @@ -4867,8 +4869,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_present" Ta "" Ta "1 if search started in copy mode" .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" .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"