=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- src/usr.bin/tmux/status.c 2011/01/26 01:54:56 1.71 +++ src/usr.bin/tmux/status.c 2011/03/29 19:30:16 1.72 @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.71 2011/01/26 01:54:56 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.72 2011/03/29 19:30:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -38,8 +38,8 @@ void status_job_callback(struct job *); char *status_print( struct client *, struct winlink *, time_t, struct grid_cell *); -void status_replace1(struct client *, - struct winlink *, char **, char **, char *, size_t, int); +void status_replace1(struct client *, struct session *, struct winlink *, + struct window_pane *, char **, char **, char *, size_t, int); void status_message_callback(int, short, void *); const char *status_prompt_up_history(u_int *); @@ -80,8 +80,8 @@ if (attr != 0) gc->attr = attr; - left = status_replace( - c, NULL, options_get_string(&s->options, "status-left"), t, 1); + left = status_replace(c, NULL, + NULL, NULL, options_get_string(&s->options, "status-left"), t, 1); *size = options_get_number(&s->options, "status-left-length"); leftlen = screen_write_cstrlen(utf8flag, "%s", left); @@ -110,8 +110,8 @@ if (attr != 0) gc->attr = attr; - right = status_replace( - c, NULL, options_get_string(&s->options, "status-right"), t, 1); + right = status_replace(c, NULL, + NULL, NULL, options_get_string(&s->options, "status-right"), t, 1); *size = options_get_number(&s->options, "status-right-length"); rightlen = screen_write_cstrlen(utf8flag, "%s", right); @@ -347,16 +347,20 @@ /* Replace a single special sequence (prefixed by #). */ void -status_replace1(struct client *c,struct winlink *wl, - char **iptr, char **optr, char *out, size_t outsize, int jobsflag) +status_replace1(struct client *c, struct session *s, struct winlink *wl, + struct window_pane *wp, char **iptr, char **optr, char *out, + size_t outsize, int jobsflag) { - struct session *s = c->session; - char ch, tmp[256], *ptr, *endptr, *freeptr; - size_t ptrlen; - long limit; + char ch, tmp[256], *ptr, *endptr, *freeptr; + size_t ptrlen; + long limit; + if (s == NULL) + s = c->session; if (wl == NULL) wl = s->curw; + if (wp == NULL) + wp = wl->window->active; errno = 0; limit = strtol(*iptr, &endptr, 10); @@ -379,6 +383,10 @@ if ((ptr = status_find_job(c, iptr)) == NULL) return; goto do_replace; + case 'D': + xsnprintf(tmp, sizeof tmp, "%%%u", wp->id); + ptr = tmp; + goto do_replace; case 'H': if (gethostname(tmp, sizeof tmp) != 0) fatal("gethostname failed"); @@ -389,15 +397,15 @@ ptr = tmp; goto do_replace; case 'P': - xsnprintf(tmp, sizeof tmp, "%u", - window_pane_index(wl->window, wl->window->active)); + xsnprintf( + tmp, sizeof tmp, "%u", window_pane_index(wl->window, wp)); ptr = tmp; goto do_replace; case 'S': ptr = s->name; goto do_replace; case 'T': - ptr = wl->window->active->base.title; + ptr = wp->base.title; goto do_replace; case 'W': ptr = wl->window->name; @@ -449,8 +457,8 @@ /* Replace special sequences in fmt. */ char * -status_replace(struct client *c, - struct winlink *wl, const char *fmt, time_t t, int jobsflag) +status_replace(struct client *c, struct session *s, struct winlink *wl, + struct window_pane *wp, const char *fmt, time_t t, int jobsflag) { static char out[BUFSIZ]; char in[BUFSIZ], ch, *iptr, *optr; @@ -470,7 +478,8 @@ *optr++ = ch; continue; } - status_replace1(c, wl, &iptr, &optr, out, sizeof out, jobsflag); + status_replace1( + c, s, wl, wp, &iptr, &optr, out, sizeof out, jobsflag); } *optr = '\0'; @@ -657,7 +666,7 @@ gc->attr = attr; } - text = status_replace(c, wl, fmt, t, 1); + text = status_replace(c, NULL, wl, NULL, fmt, t, 1); return (text); }