version 1.46, 2009/11/19 11:38:54 |
version 1.47, 2009/11/19 16:22:10 |
|
|
|
|
char *status_job(struct client *, char **); |
char *status_job(struct client *, char **); |
void status_job_callback(struct job *); |
void status_job_callback(struct job *); |
size_t status_width(struct winlink *); |
size_t status_width(struct client *, struct winlink *, time_t); |
char *status_print(struct session *, struct winlink *, struct grid_cell *); |
char *status_print( |
void status_replace1( |
struct client *, struct winlink *, time_t, struct grid_cell *); |
struct client *, char **, char **, char *, size_t, int); |
void status_replace1(struct client *, |
|
struct winlink *, char **, char **, char *, size_t, int); |
void status_message_callback(int, short, void *); |
void status_message_callback(int, short, void *); |
|
|
void status_prompt_add_history(struct client *); |
void status_prompt_add_history(struct client *); |
|
|
utf8flag = options_get_number(&s->options, "status-utf8"); |
utf8flag = options_get_number(&s->options, "status-utf8"); |
|
|
/* Work out the left and right strings. */ |
/* Work out the left and right strings. */ |
left = status_replace(c, options_get_string( |
left = status_replace(c, NULL, options_get_string( |
&s->options, "status-left"), c->status_timer.tv_sec, 1); |
&s->options, "status-left"), c->status_timer.tv_sec, 1); |
llen = options_get_number(&s->options, "status-left-length"); |
llen = options_get_number(&s->options, "status-left-length"); |
llen2 = screen_write_cstrlen(utf8flag, "%s", left); |
llen2 = screen_write_cstrlen(utf8flag, "%s", left); |
if (llen2 < llen) |
if (llen2 < llen) |
llen = llen2; |
llen = llen2; |
|
|
right = status_replace(c, options_get_string( |
right = status_replace(c, NULL, options_get_string( |
&s->options, "status-right"), c->status_timer.tv_sec, 1); |
&s->options, "status-right"), c->status_timer.tv_sec, 1); |
rlen = options_get_number(&s->options, "status-right-length"); |
rlen = options_get_number(&s->options, "status-right-length"); |
rlen2 = screen_write_cstrlen(utf8flag, "%s", right); |
rlen2 = screen_write_cstrlen(utf8flag, "%s", right); |
|
|
*/ |
*/ |
width = offset = 0; |
width = offset = 0; |
RB_FOREACH(wl, winlinks, &s->windows) { |
RB_FOREACH(wl, winlinks, &s->windows) { |
size = status_width(wl) + 1; |
size = status_width(c, wl, c->status_timer.tv_sec) + 1; |
if (wl == s->curw) |
if (wl == s->curw) |
offset = width; |
offset = width; |
width += size; |
width += size; |
|
|
goto draw; |
goto draw; |
|
|
/* Find size of current window text. */ |
/* Find size of current window text. */ |
size = status_width(s->curw); |
size = status_width(c, s->curw, c->status_timer.tv_sec); |
|
|
/* |
/* |
* If the offset is already on screen, we're good to draw from the |
* If the offset is already on screen, we're good to draw from the |
|
|
offset = 0; |
offset = 0; |
RB_FOREACH(wl, winlinks, &s->windows) { |
RB_FOREACH(wl, winlinks, &s->windows) { |
memcpy(&gc, &stdgc, sizeof gc); |
memcpy(&gc, &stdgc, sizeof gc); |
text = status_print(s, wl, &gc); |
text = status_print(c, wl, c->status_timer.tv_sec, &gc); |
|
|
if (larrow == 1 && offset < start) { |
if (larrow == 1 && offset < start) { |
if (session_alert_has(s, wl, WINDOW_ACTIVITY)) |
if (session_alert_has(s, wl, WINDOW_ACTIVITY)) |
|
|
larrow = -1; |
larrow = -1; |
} |
} |
|
|
for (ptr = text; *ptr != '\0'; ptr++) { |
ptr = text; |
if (offset >= start && offset < start + width) |
for (; offset < start; offset++) |
screen_write_putc(&ctx, &gc, *ptr); |
ptr++; /* XXX should skip UTF-8 characters */ |
offset++; |
if (offset < start + width) { |
|
screen_write_cnputs(&ctx, |
|
start + width - offset, &gc, utf8flag, "%s", text); |
|
offset += screen_write_cstrlen(utf8flag, "%s", text); |
} |
} |
|
|
if (rarrow == 1 && offset > start + width) { |
if (rarrow == 1 && offset > start + width) { |
|
|
|
|
/* Replace a single special sequence (prefixed by #). */ |
/* Replace a single special sequence (prefixed by #). */ |
void |
void |
status_replace1(struct client *c, |
status_replace1(struct client *c,struct winlink *wl, |
char **iptr, char **optr, char *out, size_t outsize, int jobsflag) |
char **iptr, char **optr, char *out, size_t outsize, int jobsflag) |
{ |
{ |
struct session *s = c->session; |
struct session *s = c->session; |
struct winlink *wl = s->curw; |
|
char ch, tmp[256], *ptr, *endptr, *freeptr; |
char ch, tmp[256], *ptr, *endptr, *freeptr; |
size_t ptrlen; |
size_t ptrlen; |
long limit; |
long limit; |
|
|
|
if (wl == NULL) |
|
wl = s->curw; |
|
|
errno = 0; |
errno = 0; |
limit = strtol(*iptr, &endptr, 10); |
limit = strtol(*iptr, &endptr, 10); |
if ((limit == 0 && errno != EINVAL) || |
if ((limit == 0 && errno != EINVAL) || |
|
|
case 'W': |
case 'W': |
ptr = wl->window->name; |
ptr = wl->window->name; |
goto do_replace; |
goto do_replace; |
|
case 'F': |
|
tmp[0] = ' '; |
|
if (session_alert_has(s, wl, WINDOW_CONTENT)) |
|
tmp[0] = '+'; |
|
else if (session_alert_has(s, wl, WINDOW_BELL)) |
|
tmp[0] = '!'; |
|
else if (session_alert_has(s, wl, WINDOW_ACTIVITY)) |
|
tmp[0] = '#'; |
|
else if (wl == s->curw) |
|
tmp[0] = '*'; |
|
else if (wl == TAILQ_FIRST(&s->lastw)) |
|
tmp[0] = '-'; |
|
tmp[1] = '\0'; |
|
ptr = tmp; |
|
goto do_replace; |
case '[': |
case '[': |
/* |
/* |
* Embedded style, handled at display time. Leave present and |
* Embedded style, handled at display time. Leave present and |
|
|
|
|
/* Replace special sequences in fmt. */ |
/* Replace special sequences in fmt. */ |
char * |
char * |
status_replace(struct client *c, const char *fmt, time_t t, int jobsflag) |
status_replace(struct client *c, |
|
struct winlink *wl, 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; |
|
|
strftime(in, sizeof in, fmt, localtime(&t)); |
strftime(in, sizeof in, fmt, localtime(&t)); |
in[(sizeof in) - 1] = '\0'; |
in[(sizeof in) - 1] = '\0'; |
|
|
|
|
*optr++ = ch; |
*optr++ = ch; |
continue; |
continue; |
} |
} |
status_replace1(c, &iptr, &optr, out, sizeof out, jobsflag); |
status_replace1(c, wl, &iptr, &optr, out, sizeof out, jobsflag); |
} |
} |
*optr = '\0'; |
*optr = '\0'; |
|
|
|
|
|
|
/* Calculate winlink status line entry width. */ |
/* Calculate winlink status line entry width. */ |
size_t |
size_t |
status_width(struct winlink *wl) |
status_width(struct client *c, struct winlink *wl, time_t t) |
{ |
{ |
return (xsnprintf(NULL, 0, "%d:%s ", wl->idx, wl->window->name)); |
struct options *oo = &wl->window->options; |
|
struct session *s = c->session; |
|
const char *fmt; |
|
char *text; |
|
size_t size; |
|
int utf8flag; |
|
|
|
utf8flag = options_get_number(&s->options, "status-utf8"); |
|
|
|
fmt = options_get_string(&wl->window->options, "window-status-format"); |
|
if (wl == s->curw) |
|
fmt = options_get_string(oo, "window-status-current-format"); |
|
|
|
text = status_replace(c, wl, fmt, t, 1); |
|
size = screen_write_cstrlen(utf8flag, "%s", text); |
|
xfree(text); |
|
|
|
return (size); |
} |
} |
|
|
/* Return winlink status line entry and adjust gc as necessary. */ |
/* Return winlink status line entry and adjust gc as necessary. */ |
char * |
char * |
status_print(struct session *s, struct winlink *wl, struct grid_cell *gc) |
status_print( |
|
struct client *c, struct winlink *wl, time_t t, struct grid_cell *gc) |
{ |
{ |
struct options *oo = &wl->window->options; |
struct options *oo = &wl->window->options; |
char *text, flag; |
struct session *s = c->session; |
|
const char *fmt; |
|
char *text; |
u_char fg, bg, attr; |
u_char fg, bg, attr; |
|
|
fg = options_get_number(oo, "window-status-fg"); |
fg = options_get_number(oo, "window-status-fg"); |
|
|
attr = options_get_number(oo, "window-status-attr"); |
attr = options_get_number(oo, "window-status-attr"); |
if (attr != 0) |
if (attr != 0) |
gc->attr = attr; |
gc->attr = attr; |
|
fmt = options_get_string(oo, "window-status-format"); |
flag = ' '; |
|
if (wl == TAILQ_FIRST(&s->lastw)) |
|
flag = '-'; |
|
if (wl == s->curw) { |
if (wl == s->curw) { |
fg = options_get_number(oo, "window-status-current-fg"); |
fg = options_get_number(oo, "window-status-current-fg"); |
if (fg != 8) |
if (fg != 8) |
|
|
attr = options_get_number(oo, "window-status-current-attr"); |
attr = options_get_number(oo, "window-status-current-attr"); |
if (attr != 0) |
if (attr != 0) |
gc->attr = attr; |
gc->attr = attr; |
flag = '*'; |
fmt = options_get_string(oo, "window-status-current-format"); |
} |
} |
|
|
if (session_alert_has(s, wl, WINDOW_ACTIVITY)) { |
if (session_alert_has(s, wl, WINDOW_ACTIVITY) || |
flag = '#'; |
session_alert_has(s, wl, WINDOW_BELL) || |
|
session_alert_has(s, wl, WINDOW_CONTENT)) |
gc->attr ^= GRID_ATTR_REVERSE; |
gc->attr ^= GRID_ATTR_REVERSE; |
} else if (session_alert_has(s, wl, WINDOW_BELL)) { |
|
flag = '!'; |
|
gc->attr ^= GRID_ATTR_REVERSE; |
|
} else if (session_alert_has(s, wl, WINDOW_CONTENT)) { |
|
flag = '+'; |
|
gc->attr ^= GRID_ATTR_REVERSE; |
|
} |
|
|
|
xasprintf(&text, "%d:%s%c", wl->idx, wl->window->name, flag); |
text = status_replace(c, wl, fmt, t, 1); |
return (text); |
return (text); |
} |
} |
|
|