=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.277 retrieving revision 1.278 diff -u -r1.277 -r1.278 --- src/usr.bin/tmux/format.c 2021/02/24 09:22:15 1.277 +++ src/usr.bin/tmux/format.c 2021/02/26 07:53:26 1.278 @@ -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 @@ 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 @@ * 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 }, @@ -2630,6 +2655,9 @@ }, { "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