diff --git a/cmd-select-layout.c b/cmd-select-layout.c index 6dfe2b6a..41779747 100644 --- a/cmd-select-layout.c +++ b/cmd-select-layout.c @@ -90,7 +90,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item) previous = 1; oldlayout = w->old_layout; - w->old_layout = layout_dump(w->layout_root); + w->old_layout = layout_dump(w, w->layout_root); if (next || previous) { if (next) diff --git a/format.c b/format.c index a9310ff4..2ebfe588 100644 --- a/format.c +++ b/format.c @@ -811,8 +811,8 @@ format_cb_window_layout(struct format_tree *ft) return (NULL); if (w->saved_layout_root != NULL) - return (layout_dump(w->saved_layout_root)); - return (layout_dump(w->layout_root)); + return (layout_dump(w, w->saved_layout_root)); + return (layout_dump(w, w->layout_root)); } /* Callback for window_visible_layout. */ @@ -824,7 +824,7 @@ format_cb_window_visible_layout(struct format_tree *ft) if (w == NULL) return (NULL); - return (layout_dump(w->layout_root)); + return (layout_dump(w, w->layout_root)); } /* Callback for pane_start_command. */ @@ -990,6 +990,29 @@ format_cb_pane_fg(struct format_tree *ft) return (xstrdup(colour_tostring(gc.fg))); } +/* Callback for pane_flags. */ +static void * +format_cb_pane_flags(struct format_tree *ft) +{ + if (ft->wp != NULL) + return (xstrdup(window_pane_printable_flags(ft->wp))); + return (NULL); +} + +/* Callback for pane_floating_flag. */ +static void * +format_cb_pane_floating_flag(struct format_tree *ft) +{ + struct window_pane *wp = ft->wp; + + if (wp != NULL) { + if (wp->flags & PANE_FLOATING) + return (xstrdup("1")); + return (xstrdup("0")); + } + return (NULL); +} + /* Callback for pane_bg. */ static void * format_cb_pane_bg(struct format_tree *ft) @@ -2351,6 +2374,20 @@ format_cb_pane_width(struct format_tree *ft) return (NULL); } +/* Callback for pane_zoomed_flag. */ +static void * +format_cb_pane_zoomed_flag(struct format_tree *ft) +{ + struct window_pane *wp = ft->wp; + + if (wp != NULL) { + if (wp->flags & PANE_ZOOMED) + return (xstrdup("1")); + return (xstrdup("0")); + } + return (NULL); +} + /* Callback for scroll_region_lower. */ static void * format_cb_scroll_region_lower(struct format_tree *ft) @@ -3326,6 +3363,12 @@ static const struct format_table_entry format_table[] = { { "pane_fg", FORMAT_TABLE_STRING, format_cb_pane_fg }, + { "pane_flags", FORMAT_TABLE_STRING, + format_cb_pane_flags + }, + { "pane_floating_flag", FORMAT_TABLE_STRING, + format_cb_pane_floating_flag + }, { "pane_format", FORMAT_TABLE_STRING, format_cb_pane_format }, @@ -3413,6 +3456,9 @@ static const struct format_table_entry format_table[] = { { "pane_width", FORMAT_TABLE_STRING, format_cb_pane_width }, + { "pane_zoomed_flag", FORMAT_TABLE_STRING, + format_cb_pane_zoomed_flag + }, { "pid", FORMAT_TABLE_STRING, format_cb_pid }, diff --git a/layout-custom.c b/layout-custom.c index 2bfb6d89..22de0bdd 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -58,7 +58,7 @@ layout_checksum(const char *layout) /* Dump layout as a string. */ char * -layout_dump(struct layout_cell *root) +layout_dump(__unused struct window *w, struct layout_cell *root) { char layout[8192], *out; diff --git a/tmux.1 b/tmux.1 index dd0f7c4a..9c2932ad 100644 --- a/tmux.1 +++ b/tmux.1 @@ -6369,6 +6369,8 @@ The following variables are available, where appropriate: .It Li "pane_dead_status" Ta "" Ta "Exit status of process in dead pane" .It Li "pane_dead_time" Ta "" Ta "Exit time of process in dead pane" .It Li "pane_fg" Ta "" Ta "Pane foreground colour" +.It Li "pane_flags" Ta "" Ta "Pane flags" +.It Li "pane_floating_flag" Ta "" Ta "1 if pane is floating" .It Li "pane_format" Ta "" Ta "1 if format is for a pane" .It Li "pane_height" Ta "" Ta "Height of pane" .It Li "pane_id" Ta "#D" Ta "Unique pane ID" @@ -6398,6 +6400,7 @@ The following variables are available, where appropriate: .It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane" .It Li "pane_unseen_changes" Ta "" Ta "1 if there were changes in pane while in mode" .It Li "pane_width" Ta "" Ta "Width of pane" +.It Li "pane_floating_flag" Ta "" Ta "1 if pane is floating" .It Li "pid" Ta "" Ta "Server PID" .It Li "prev_window_active" Ta "" Ta "1 if previous window in W: loop is active" .It Li "prev_window_index" Ta "" Ta "Index of previous window in W: loop" diff --git a/tmux.h b/tmux.h index 3f55c30f..27f016de 100644 --- a/tmux.h +++ b/tmux.h @@ -1218,7 +1218,7 @@ struct window_pane { #define PANE_FOCUSED 0x4 #define PANE_VISITED 0x8 #define PANE_ZOOMED 0x10 -/* 0x20 unused */ +#define PANE_FLOATING 0x20 #define PANE_INPUTOFF 0x40 #define PANE_CHANGED 0x80 #define PANE_EXITED 0x100 @@ -3372,6 +3372,7 @@ int window_pane_exited(struct window_pane *); u_int window_pane_search(struct window_pane *, const char *, int, int); const char *window_printable_flags(struct winlink *, int); +const char *window_pane_printable_flags(struct window_pane *); struct window_pane *window_pane_find_up(struct window_pane *); struct window_pane *window_pane_find_down(struct window_pane *); struct window_pane *window_pane_find_left(struct window_pane *); @@ -3439,7 +3440,7 @@ int layout_spread_cell(struct window *, struct layout_cell *); void layout_spread_out(struct window_pane *); /* layout-custom.c */ -char *layout_dump(struct layout_cell *); +char *layout_dump(struct window *, struct layout_cell *); int layout_parse(struct window *, const char *, char **); /* layout-set.c */ diff --git a/window.c b/window.c index 7a70205e..c97a3875 100644 --- a/window.c +++ b/window.c @@ -882,9 +882,8 @@ window_printable_flags(struct winlink *wl, int escape) { struct session *s = wl->session; static char flags[32]; - int pos; + u_int pos = 0; - pos = 0; if (wl->flags & WINLINK_ACTIVITY) { flags[pos++] = '#'; if (escape) @@ -906,6 +905,25 @@ window_printable_flags(struct winlink *wl, int escape) return (flags); } +const char * +window_pane_printable_flags(struct window_pane *wp) +{ + struct window *w = wp->window; + static char flags[32]; + u_int pos = 0; + + if (wp == w->active) + flags[pos++] = '*'; + if (wp == TAILQ_FIRST(&w->last_panes)) + flags[pos++] = '-'; + if (wp->flags & PANE_ZOOMED) + flags[pos++] = 'Z'; + if (wp->flags & PANE_FLOATING) + flags[pos++] = 'F'; + flags[pos] = '\0'; + return (flags); +} + struct window_pane * window_pane_find_by_id_str(const char *s) {