mirror of
https://github.com/tmux/tmux.git
synced 2024-12-25 02:48:47 +00:00
Allow formats in status options.
This commit is contained in:
parent
6ad2c5c40f
commit
6c53a1ed68
3
format.c
3
format.c
@ -251,10 +251,11 @@ format_expand(struct format_tree *ft, const char *fmt)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (len - off < 2) {
|
while (len - off < 3) {
|
||||||
buf = xrealloc(buf, 2, len);
|
buf = xrealloc(buf, 2, len);
|
||||||
len *= 2;
|
len *= 2;
|
||||||
}
|
}
|
||||||
|
buf[off++] = '#';
|
||||||
buf[off++] = ch;
|
buf[off++] = ch;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
30
status.c
30
status.c
@ -393,13 +393,6 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl,
|
|||||||
long limit;
|
long limit;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
s = c->session;
|
|
||||||
if (wl == NULL)
|
|
||||||
wl = s->curw;
|
|
||||||
if (wp == NULL)
|
|
||||||
wp = wl->window->active;
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
limit = strtol(*iptr, &endptr, 10);
|
limit = strtol(*iptr, &endptr, 10);
|
||||||
if ((limit == 0 && errno != EINVAL) ||
|
if ((limit == 0 && errno != EINVAL) ||
|
||||||
@ -468,6 +461,9 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl,
|
|||||||
*/
|
*/
|
||||||
ch = ']';
|
ch = ']';
|
||||||
goto skip_to;
|
goto skip_to;
|
||||||
|
case '{':
|
||||||
|
ptr = (char *) "#{";
|
||||||
|
goto do_replace;
|
||||||
case '#':
|
case '#':
|
||||||
*(*optr)++ = '#';
|
*(*optr)++ = '#';
|
||||||
break;
|
break;
|
||||||
@ -507,13 +503,21 @@ char *
|
|||||||
status_replace(struct client *c, struct session *s, struct winlink *wl,
|
status_replace(struct client *c, struct session *s, struct winlink *wl,
|
||||||
struct window_pane *wp, const char *fmt, time_t t, int jobsflag)
|
struct window_pane *wp, const char *fmt, time_t t, int jobsflag)
|
||||||
{
|
{
|
||||||
static char out[BUFSIZ];
|
static char out[BUFSIZ];
|
||||||
char in[BUFSIZ], ch, *iptr, *optr;
|
char in[BUFSIZ], ch, *iptr, *optr;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
struct format_tree *ft;
|
||||||
|
|
||||||
if (fmt == NULL)
|
if (fmt == NULL)
|
||||||
return (xstrdup(""));
|
return (xstrdup(""));
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
s = c->session;
|
||||||
|
if (wl == NULL)
|
||||||
|
wl = s->curw;
|
||||||
|
if (wp == NULL)
|
||||||
|
wp = wl->window->active;
|
||||||
|
|
||||||
len = strftime(in, sizeof in, fmt, localtime(&t));
|
len = strftime(in, sizeof in, fmt, localtime(&t));
|
||||||
in[len] = '\0';
|
in[len] = '\0';
|
||||||
|
|
||||||
@ -534,7 +538,11 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
|
|||||||
}
|
}
|
||||||
*optr = '\0';
|
*optr = '\0';
|
||||||
|
|
||||||
return (xstrdup(out));
|
ft = format_create();
|
||||||
|
format_session(ft, s);
|
||||||
|
format_winlink(ft, s, wl);
|
||||||
|
format_window_pane(ft, wp);
|
||||||
|
return (format_expand(ft, out));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Figure out job name and get its result, starting it off if necessary. */
|
/* Figure out job name and get its result, starting it off if necessary. */
|
||||||
|
Loading…
Reference in New Issue
Block a user