Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv6519

Modified Files:
        cmd-choose-window.c status.c tmux.h window.c 
Log Message:
Sync OpenBSD patchset 813:

Add a function to create window flags rather than doing the same thing
in two places. From Thomas Adam.


Index: cmd-choose-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-choose-window.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cmd-choose-window.c 7 Jan 2011 14:45:33 -0000       1.25
+++ cmd-choose-window.c 7 Jan 2011 16:55:40 -0000       1.26
@@ -56,7 +56,7 @@
        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) {
@@ -79,20 +79,7 @@
                        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;
@@ -102,10 +89,12 @@
                        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);
+
+               xfree(flags);
        }
 
        cdata = xmalloc(sizeof *cdata);

Index: window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/window.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- window.c    6 Dec 2010 22:52:21 -0000       1.142
+++ window.c    7 Jan 2011 16:55:40 -0000       1.143
@@ -460,6 +460,32 @@
        }
 }
 
+/* Return list of printable window flag symbols. No flags is just a space. */
+char *
+window_printable_flags(struct session *s, struct winlink *wl)
+{
+       char    flags[BUFSIZ];
+       int     pos;
+
+       pos = 0;
+       if (wl->flags & WINLINK_ACTIVITY)
+               flags[pos++] = '#';
+       if (wl->flags & WINLINK_BELL)
+               flags[pos++] = '!';
+       if (wl->flags & WINLINK_CONTENT)
+               flags[pos++] = '+';
+       if (wl->flags & WINLINK_SILENCE)
+               flags[pos++] = '~';
+       if (wl == s->curw)
+               flags[pos++] = '*';
+       if (wl == TAILQ_FIRST(&s->lastw))
+               flags[pos++] = '-';
+       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)
 {

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.602
retrieving revision 1.603
diff -u -d -r1.602 -r1.603
--- tmux.h      7 Jan 2011 14:45:34 -0000       1.602
+++ tmux.h      7 Jan 2011 16:55:40 -0000       1.603
@@ -1873,6 +1873,8 @@
 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 *);

Index: status.c
===================================================================
RCS file: /cvsroot/tmux/tmux/status.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -d -r1.154 -r1.155
--- status.c    7 Jan 2011 14:32:26 -0000       1.154
+++ status.c    7 Jan 2011 16:55:40 -0000       1.155
@@ -393,21 +393,8 @@
                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 '[':
                /*


------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to