aboutsummaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
authornicm <nicm>2021-02-26 07:53:26 +0000
committernicm <nicm>2021-02-26 07:53:26 +0000
commitdd7006c850e1f973c214f70eee87a054b00f19e7 (patch)
tree86f8629d95e7224f8a60c6fb59f06292fad72158 /format.c
parent6aaef3e705507566631905560b1c903f8ae22ab3 (diff)
downloadrtmux-dd7006c850e1f973c214f70eee87a054b00f19e7.tar.gz
rtmux-dd7006c850e1f973c214f70eee87a054b00f19e7.tar.bz2
rtmux-dd7006c850e1f973c214f70eee87a054b00f19e7.zip
Add a couple of format variables for active and last window index.
Diffstat (limited to 'format.c')
-rw-r--r--format.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/format.c b/format.c
index a9694bab..00413bae 100644
--- a/format.c
+++ b/format.c
@@ -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
},