Rather than hardcode where the printable window flags need to be used (such as on the status-line and choose-window list), introduce a printable_window_flags() function to return a list of flags.
As a change of behaviour, now returns *all* window flags on a given winlink rather than a single flag. --- cmd-choose-window.c | 24 +++++++----------------- status.c | 17 ++--------------- tmux.h | 2 ++ window.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/cmd-choose-window.c b/cmd-choose-window.c index ecdb959..c39c0ed 100644 --- a/cmd-choose-window.c +++ b/cmd-choose-window.c @@ -57,7 +57,7 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) struct winlink *wl, *wm; struct window *w; u_int idx, cur; - char flag, *title; + char *flags, *title; const char *left, *right; if (ctx->curclient == NULL) { @@ -80,20 +80,7 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) cur = idx; idx++; - flag = ' '; - if (wm->flags & WINLINK_ACTIVITY) - flag = '#'; - else if (wm->flags & WINLINK_BELL) - flag = '!'; - else if (wm->flags & WINLINK_CONTENT) - flag = '+'; - else if (wm->flags & WINLINK_SILENCE) - flag = '~'; - else if (wm == s->curw) - flag = '*'; - else if (wm == TAILQ_FIRST(&s->lastw)) - flag = '-'; - + flags = window_printable_flags(s, wm); title = w->active->screen->title; if (wm == wl) title = w->active->base.title; @@ -103,12 +90,15 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) left = right = ""; window_choose_add(wl->window->active, - wm->idx, "%3d: %s%c [%ux%u] (%u panes%s)%s%s%s", - wm->idx, w->name, flag, w->sx, w->sy, window_count_panes(w), + wm->idx, "%3d: %s%s [%ux%u] (%u panes%s)%s%s%s", + wm->idx, w->name, flags, w->sx, w->sy, window_count_panes(w), w->active->fd == -1 ? ", dead" : "", left, title, right); } + if (flags != NULL) + xfree(flags); + cdata = xmalloc(sizeof *cdata); if (data->arg != NULL) cdata->template = xstrdup(data->arg); diff --git a/status.c b/status.c index 8395fbd..a8e73be 100644 --- a/status.c +++ b/status.c @@ -393,21 +393,8 @@ status_replace1(struct client *c,struct winlink *wl, ptr = wl->window->name; goto do_replace; case 'F': - tmp[0] = ' '; - if (wl->flags & WINLINK_CONTENT) - tmp[0] = '+'; - else if (wl->flags & WINLINK_BELL) - tmp[0] = '!'; - else if (wl->flags & WINLINK_ACTIVITY) - tmp[0] = '#'; - else if (wl->flags & WINLINK_SILENCE) - tmp[0] = '~'; - else if (wl == s->curw) - tmp[0] = '*'; - else if (wl == TAILQ_FIRST(&s->lastw)) - tmp[0] = '-'; - tmp[1] = '\0'; - ptr = tmp; + ptr = window_printable_flags(s, wl); + freeptr = ptr; goto do_replace; case '[': /* diff --git a/tmux.h b/tmux.h index 5e49979..4162bff 100644 --- a/tmux.h +++ b/tmux.h @@ -1887,6 +1887,8 @@ void window_pane_mouse(struct window_pane *, int window_pane_visible(struct window_pane *); char *window_pane_search( struct window_pane *, const char *, u_int *); +char *window_printable_flags(struct session *, struct winlink *); + 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 *); diff --git a/window.c b/window.c index a19f28b..a0b94b7 100644 --- a/window.c +++ b/window.c @@ -460,6 +460,37 @@ window_destroy_panes(struct window *w) } } +char * +window_printable_flags(struct session *s, struct winlink *wl) +{ + int window_flags; + char flags[BUFSIZ]; + int pos; + + pos = 0; + window_flags = wl->flags; + + if (window_flags & WINLINK_ACTIVITY) + flags[pos++] = '#'; + if (window_flags & WINLINK_BELL) + flags[pos++] = '!'; + if (window_flags & WINLINK_CONTENT) + flags[pos++] = '+'; + if (window_flags & WINLINK_SILENCE) + flags[pos++] = '~'; + if (wl == s->curw) + flags[pos++] = '*'; + if (wl == TAILQ_FIRST(&s->lastw)) + flags[pos++] = '-'; + + /* Set flags to be a space if there's no other flags. */ + if (pos == 0) + flags[pos++] = ' '; + + flags[pos] = '\0'; + return (xstrdup(flags)); +} + struct window_pane * window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) { -- 1.7.2.3 ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users