version 1.119, 2015/01/20 10:57:10 |
version 1.120, 2015/02/01 23:43:23 |
|
|
|
|
/* Retrieve options for left string. */ |
/* Retrieve options for left string. */ |
char * |
char * |
status_redraw_get_left(struct client *c, |
status_redraw_get_left(struct client *c, time_t t, int utf8flag, |
time_t t, int utf8flag, struct grid_cell *gc, size_t *size) |
struct grid_cell *gc, size_t *size) |
{ |
{ |
struct session *s = c->session; |
struct session *s = c->session; |
|
const char *template; |
char *left; |
char *left; |
size_t leftlen; |
size_t leftlen; |
|
|
style_apply_update(gc, &s->options, "status-left-style"); |
style_apply_update(gc, &s->options, "status-left-style"); |
|
|
left = status_replace(c, NULL, |
template = options_get_string(&s->options, "status-left"); |
NULL, NULL, options_get_string(&s->options, "status-left"), t, 1); |
left = status_replace(c, NULL, template , t, 1); |
|
|
*size = options_get_number(&s->options, "status-left-length"); |
*size = options_get_number(&s->options, "status-left-length"); |
leftlen = screen_write_cstrlen(utf8flag, "%s", left); |
leftlen = screen_write_cstrlen(utf8flag, "%s", left); |
|
|
|
|
/* Retrieve options for right string. */ |
/* Retrieve options for right string. */ |
char * |
char * |
status_redraw_get_right(struct client *c, |
status_redraw_get_right(struct client *c, time_t t, int utf8flag, |
time_t t, int utf8flag, struct grid_cell *gc, size_t *size) |
struct grid_cell *gc, size_t *size) |
{ |
{ |
struct session *s = c->session; |
struct session *s = c->session; |
|
const char *template; |
char *right; |
char *right; |
size_t rightlen; |
size_t rightlen; |
|
|
style_apply_update(gc, &s->options, "status-right-style"); |
style_apply_update(gc, &s->options, "status-right-style"); |
|
|
right = status_replace(c, NULL, |
template = options_get_string(&s->options, "status-right"); |
NULL, NULL, options_get_string(&s->options, "status-right"), t, 1); |
right = status_replace(c, NULL, template, t, 1); |
|
|
*size = options_get_number(&s->options, "status-right-length"); |
*size = options_get_number(&s->options, "status-right-length"); |
rightlen = screen_write_cstrlen(utf8flag, "%s", right); |
rightlen = screen_write_cstrlen(utf8flag, "%s", right); |
|
|
|
|
/* Replace special sequences in fmt. */ |
/* Replace special sequences in fmt. */ |
char * |
char * |
status_replace(struct client *c, struct session *s, struct winlink *wl, |
status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t, |
struct window_pane *wp, const char *fmt, time_t t, int jobsflag) |
int jobsflag) |
{ |
{ |
|
struct session *s = NULL; |
|
struct window_pane *wp = NULL; |
static char out[BUFSIZ]; |
static char out[BUFSIZ]; |
char in[BUFSIZ], ch, *iptr, *optr, *expanded; |
char in[BUFSIZ], ch, *iptr, *optr, *expanded; |
size_t len; |
size_t len; |
|
|
if (fmt == NULL) |
if (fmt == NULL) |
return (xstrdup("")); |
return (xstrdup("")); |
|
|
if (s == NULL && c != NULL) |
if (c != NULL) |
s = c->session; |
s = c->session; |
if (wl == NULL && s != NULL) |
if (wl == NULL && s != NULL) |
wl = s->curw; |
wl = s->curw; |
if (wp == NULL && wl != NULL) |
if (wl != NULL) |
wp = wl->window->active; |
wp = wl->window->active; |
|
|
len = strftime(in, sizeof in, fmt, localtime(&t)); |
len = strftime(in, sizeof in, fmt, localtime(&t)); |
|
|
|
|
/* Return winlink status line entry and adjust gc as necessary. */ |
/* Return winlink status line entry and adjust gc as necessary. */ |
char * |
char * |
status_print( |
status_print(struct client *c, struct winlink *wl, time_t t, |
struct client *c, struct winlink *wl, time_t t, struct grid_cell *gc) |
struct grid_cell *gc) |
{ |
{ |
struct options *oo = &wl->window->options; |
struct options *oo = &wl->window->options; |
struct session *s = c->session; |
struct session *s = c->session; |
|
|
else if (wl->flags & (WINLINK_ACTIVITY|WINLINK_SILENCE)) |
else if (wl->flags & (WINLINK_ACTIVITY|WINLINK_SILENCE)) |
style_apply_update(gc, oo, "window-status-activity-style"); |
style_apply_update(gc, oo, "window-status-activity-style"); |
|
|
text = status_replace(c, NULL, wl, NULL, fmt, t, 1); |
text = status_replace(c, wl, fmt, t, 1); |
return (text); |
return (text); |
} |
} |
|
|
|
|
status_message_clear(c); |
status_message_clear(c); |
status_prompt_clear(c); |
status_prompt_clear(c); |
|
|
c->prompt_string = status_replace(c, NULL, NULL, NULL, msg, |
c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0); |
time(NULL), 0); |
|
|
|
c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input, |
c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0); |
time(NULL), 0); |
|
c->prompt_index = strlen(c->prompt_buffer); |
c->prompt_index = strlen(c->prompt_buffer); |
|
|
c->prompt_callbackfn = callbackfn; |
c->prompt_callbackfn = callbackfn; |
|
|
status_prompt_update(struct client *c, const char *msg, const char *input) |
status_prompt_update(struct client *c, const char *msg, const char *input) |
{ |
{ |
free(c->prompt_string); |
free(c->prompt_string); |
c->prompt_string = status_replace(c, NULL, NULL, NULL, msg, |
c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0); |
time(NULL), 0); |
|
|
|
free(c->prompt_buffer); |
free(c->prompt_buffer); |
c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input, |
c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0); |
time(NULL), 0); |
|
c->prompt_index = strlen(c->prompt_buffer); |
c->prompt_index = strlen(c->prompt_buffer); |
|
|
c->prompt_hindex = 0; |
c->prompt_hindex = 0; |