version 1.136, 2015/10/20 21:12:09 |
version 1.137, 2015/10/27 15:58:42 |
|
|
const char *home, *history_file; |
const char *home, *history_file; |
char *path; |
char *path; |
|
|
history_file = options_get_string(&global_options, "history-file"); |
history_file = options_get_string(global_options, "history-file"); |
if (*history_file == '\0') |
if (*history_file == '\0') |
return (NULL); |
return (NULL); |
if (*history_file == '/') |
if (*history_file == '/') |
|
|
c->flags |= CLIENT_STATUS; |
c->flags |= CLIENT_STATUS; |
|
|
timerclear(&tv); |
timerclear(&tv); |
tv.tv_sec = options_get_number(&s->options, "status-interval"); |
tv.tv_sec = options_get_number(s->options, "status-interval"); |
|
|
if (tv.tv_sec != 0) |
if (tv.tv_sec != 0) |
evtimer_add(&c->status_timer, &tv); |
evtimer_add(&c->status_timer, &tv); |
|
|
else |
else |
evtimer_set(&c->status_timer, status_timer_callback, c); |
evtimer_set(&c->status_timer, status_timer_callback, c); |
|
|
if (s != NULL && options_get_number(&s->options, "status")) |
if (s != NULL && options_get_number(s->options, "status")) |
status_timer_callback(-1, 0, c); |
status_timer_callback(-1, 0, c); |
} |
} |
|
|
|
|
{ |
{ |
struct session *s = c->session; |
struct session *s = c->session; |
|
|
if (!options_get_number(&s->options, "status")) |
if (!options_get_number(s->options, "status")) |
return (-1); |
return (-1); |
|
|
if (options_get_number(&s->options, "status-position") == 0) |
if (options_get_number(s->options, "status-position") == 0) |
return (0); |
return (0); |
return (c->tty.sy - 1); |
return (c->tty.sy - 1); |
} |
} |
|
|
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"); |
|
|
template = options_get_string(&s->options, "status-left"); |
template = options_get_string(s->options, "status-left"); |
left = status_replace(c, NULL, template, t); |
left = status_replace(c, NULL, template, t); |
|
|
*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); |
if (leftlen < *size) |
if (leftlen < *size) |
*size = leftlen; |
*size = leftlen; |
|
|
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"); |
|
|
template = options_get_string(&s->options, "status-right"); |
template = options_get_string(s->options, "status-right"); |
right = status_replace(c, NULL, template, t); |
right = status_replace(c, NULL, template, t); |
|
|
*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); |
if (rightlen < *size) |
if (rightlen < *size) |
*size = rightlen; |
*size = rightlen; |
|
|
|
|
x += c->wlmouse; |
x += c->wlmouse; |
RB_FOREACH(wl, winlinks, &s->windows) { |
RB_FOREACH(wl, winlinks, &s->windows) { |
oo = &wl->window->options; |
oo = wl->window->options; |
len = strlen(options_get_string(oo, "window-status-separator")); |
len = strlen(options_get_string(oo, "window-status-separator")); |
|
|
if (x < wl->status_width) |
if (x < wl->status_width) |
|
|
int larrow, rarrow, utf8flag; |
int larrow, rarrow, utf8flag; |
|
|
/* No status line? */ |
/* No status line? */ |
if (c->tty.sy == 0 || !options_get_number(&s->options, "status")) |
if (c->tty.sy == 0 || !options_get_number(s->options, "status")) |
return (1); |
return (1); |
left = right = NULL; |
left = right = NULL; |
larrow = rarrow = 0; |
larrow = rarrow = 0; |
|
|
t = time(NULL); |
t = time(NULL); |
|
|
/* Set up default colour. */ |
/* Set up default colour. */ |
style_apply(&stdgc, &s->options, "status-style"); |
style_apply(&stdgc, s->options, "status-style"); |
|
|
/* Create the target screen. */ |
/* Create the target screen. */ |
memcpy(&old_status, &c->status, sizeof old_status); |
memcpy(&old_status, &c->status, sizeof old_status); |
|
|
goto out; |
goto out; |
|
|
/* Get UTF-8 flag. */ |
/* Get UTF-8 flag. */ |
utf8flag = options_get_number(&s->options, "status-utf8"); |
utf8flag = options_get_number(s->options, "status-utf8"); |
|
|
/* Work out left and right strings. */ |
/* Work out left and right strings. */ |
memcpy(&lgc, &stdgc, sizeof lgc); |
memcpy(&lgc, &stdgc, sizeof lgc); |
|
|
if (wl == s->curw) |
if (wl == s->curw) |
wloffset = wlwidth; |
wloffset = wlwidth; |
|
|
oo = &wl->window->options; |
oo = wl->window->options; |
sep = options_get_string(oo, "window-status-separator"); |
sep = options_get_string(oo, "window-status-separator"); |
seplen = screen_write_strlen(utf8flag, "%s", sep); |
seplen = screen_write_strlen(utf8flag, "%s", sep); |
wlwidth += wl->status_width + seplen; |
wlwidth += wl->status_width + seplen; |
|
|
screen_write_cnputs(&ctx, |
screen_write_cnputs(&ctx, |
-1, &wl->status_cell, utf8flag, "%s", wl->status_text); |
-1, &wl->status_cell, utf8flag, "%s", wl->status_text); |
|
|
oo = &wl->window->options; |
oo = wl->window->options; |
sep = options_get_string(oo, "window-status-separator"); |
sep = options_get_string(oo, "window-status-separator"); |
screen_write_nputs(&ctx, -1, &stdgc, utf8flag, "%s", sep); |
screen_write_nputs(&ctx, -1, &stdgc, utf8flag, "%s", sep); |
} |
} |
|
|
else |
else |
wloffset = 0; |
wloffset = 0; |
if (wlwidth < wlavailable) { |
if (wlwidth < wlavailable) { |
switch (options_get_number(&s->options, "status-justify")) { |
switch (options_get_number(s->options, "status-justify")) { |
case 1: /* centred */ |
case 1: /* centred */ |
wloffset += (wlavailable - wlwidth) / 2; |
wloffset += (wlavailable - wlwidth) / 2; |
break; |
break; |
|
|
status_print(struct client *c, struct winlink *wl, time_t t, |
status_print(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; |
const char *fmt; |
const char *fmt; |
char *text; |
char *text; |
|
|
int delay; |
int delay; |
u_int first, limit; |
u_int first, limit; |
|
|
limit = options_get_number(&global_options, "message-limit"); |
limit = options_get_number(global_options, "message-limit"); |
|
|
status_prompt_clear(c); |
status_prompt_clear(c); |
status_message_clear(c); |
status_message_clear(c); |
|
|
free(msg); |
free(msg); |
} |
} |
|
|
delay = options_get_number(&c->session->options, "display-time"); |
delay = options_get_number(c->session->options, "display-time"); |
tv.tv_sec = delay / 1000; |
tv.tv_sec = delay / 1000; |
tv.tv_usec = (delay % 1000) * 1000L; |
tv.tv_usec = (delay % 1000) * 1000L; |
|
|
|
|
memcpy(&old_status, &c->status, sizeof old_status); |
memcpy(&old_status, &c->status, sizeof old_status); |
screen_init(&c->status, c->tty.sx, 1, 0); |
screen_init(&c->status, c->tty.sx, 1, 0); |
|
|
utf8flag = options_get_number(&s->options, "status-utf8"); |
utf8flag = options_get_number(s->options, "status-utf8"); |
|
|
len = screen_write_strlen(utf8flag, "%s", c->message_string); |
len = screen_write_strlen(utf8flag, "%s", c->message_string); |
if (len > c->tty.sx) |
if (len > c->tty.sx) |
len = c->tty.sx; |
len = c->tty.sx; |
|
|
style_apply(&gc, &s->options, "message-style"); |
style_apply(&gc, s->options, "message-style"); |
|
|
screen_write_start(&ctx, NULL, &c->status); |
screen_write_start(&ctx, NULL, &c->status); |
|
|
|
|
|
|
c->prompt_flags = flags; |
c->prompt_flags = flags; |
|
|
keys = options_get_number(&c->session->options, "status-keys"); |
keys = options_get_number(c->session->options, "status-keys"); |
if (keys == MODEKEY_EMACS) |
if (keys == MODEKEY_EMACS) |
mode_key_init(&c->prompt_mdata, &mode_key_tree_emacs_edit); |
mode_key_init(&c->prompt_mdata, &mode_key_tree_emacs_edit); |
else |
else |
|
|
memcpy(&old_status, &c->status, sizeof old_status); |
memcpy(&old_status, &c->status, sizeof old_status); |
screen_init(&c->status, c->tty.sx, 1, 0); |
screen_init(&c->status, c->tty.sx, 1, 0); |
|
|
utf8flag = options_get_number(&s->options, "status-utf8"); |
utf8flag = options_get_number(s->options, "status-utf8"); |
|
|
len = screen_write_strlen(utf8flag, "%s", c->prompt_string); |
len = screen_write_strlen(utf8flag, "%s", c->prompt_string); |
if (len > c->tty.sx) |
if (len > c->tty.sx) |
|
|
|
|
/* Change colours for command mode. */ |
/* Change colours for command mode. */ |
if (c->prompt_mdata.mode == 1) |
if (c->prompt_mdata.mode == 1) |
style_apply(&gc, &s->options, "message-command-style"); |
style_apply(&gc, s->options, "message-command-style"); |
else |
else |
style_apply(&gc, &s->options, "message-style"); |
style_apply(&gc, s->options, "message-style"); |
|
|
screen_write_start(&ctx, NULL, &c->status); |
screen_write_start(&ctx, NULL, &c->status); |
|
|
|
|
status_prompt_key(struct client *c, int key) |
status_prompt_key(struct client *c, int key) |
{ |
{ |
struct session *sess = c->session; |
struct session *sess = c->session; |
struct options *oo = &sess->options; |
struct options *oo = sess->options; |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
char *s, *first, *last, word[64], swapc; |
char *s, *first, *last, word[64], swapc; |
const char *histstr, *bufdata, *wsep = NULL; |
const char *histstr, *bufdata, *wsep = NULL; |