mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 14:27:09 +00:00
Big internal reorganisation to move tty control into parent.
This commit is contained in:
89
status.c
89
status.c
@ -1,4 +1,4 @@
|
||||
/* $Id: status.c,v 1.13 2007-11-22 18:09:43 nicm Exp $ */
|
||||
/* $Id: status.c,v 1.14 2007-11-27 19:23:34 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -25,19 +25,19 @@
|
||||
void printflike3 status_print(struct buffer *, size_t *, const char *, ...);
|
||||
|
||||
void
|
||||
status_write(struct client *c)
|
||||
status_write_client(struct client *c)
|
||||
{
|
||||
struct screen *s = &c->session->curw->window->screen;
|
||||
struct buffer *b = c->out;
|
||||
struct winlink *wl;
|
||||
size_t size;
|
||||
char flag;
|
||||
struct screen_draw_ctx ctx;
|
||||
struct winlink *wl;
|
||||
char flag;
|
||||
|
||||
input_store_zero(b, CODE_CURSOROFF);
|
||||
input_store_two(b, CODE_CURSORMOVE, c->sy - status_lines + 1, 1);
|
||||
input_store_two(b, CODE_ATTRIBUTES, 0, status_colour);
|
||||
if (status_lines == 0 || c->sy <= status_lines)
|
||||
return;
|
||||
|
||||
screen_draw_start_client(&ctx, c, 0, 0);
|
||||
screen_draw_move_cursor(&ctx, 0, c->sy - status_lines);
|
||||
screen_draw_set_attributes(&ctx, 0, status_colour);
|
||||
|
||||
size = c->sx;
|
||||
RB_FOREACH(wl, winlinks, &c->session->windows) {
|
||||
flag = ' ';
|
||||
if (wl == c->session->lastw)
|
||||
@ -46,45 +46,50 @@ status_write(struct client *c)
|
||||
flag = '*';
|
||||
if (session_hasbell(c->session, wl))
|
||||
flag = '!';
|
||||
status_print(
|
||||
b, &size, "%d:%s%c ", wl->idx, wl->window->name, flag);
|
||||
screen_draw_write_string(
|
||||
&ctx, "%d:%s%c ", wl->idx, wl->window->name, flag);
|
||||
|
||||
if (size == 0)
|
||||
if (ctx.cx >= screen_last_x(ctx.s))
|
||||
break;
|
||||
}
|
||||
while (size-- > 0)
|
||||
input_store8(b, ' ');
|
||||
screen_draw_clear_line_to(&ctx, screen_last_x(ctx.s));
|
||||
|
||||
input_store_two(b, CODE_ATTRIBUTES, s->attr, s->colr);
|
||||
input_store_two(b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1);
|
||||
if (s->mode & MODE_BACKGROUND) {
|
||||
if (s->mode & MODE_BGCURSOR)
|
||||
input_store_zero(c->out, CODE_CURSORON);
|
||||
} else {
|
||||
if (s->mode & MODE_CURSOR)
|
||||
input_store_zero(c->out, CODE_CURSORON);
|
||||
}
|
||||
screen_draw_stop(&ctx);
|
||||
}
|
||||
|
||||
void printflike3
|
||||
status_print(struct buffer *b, size_t *size, const char *fmt, ...)
|
||||
void
|
||||
status_write_window(struct window *w)
|
||||
{
|
||||
va_list ap;
|
||||
char *msg, *ptr;
|
||||
int n;
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
||||
va_start(ap, fmt);
|
||||
n = xvasprintf(&msg, fmt, ap);
|
||||
va_end(ap);
|
||||
if (w->screen.mode & MODE_HIDDEN)
|
||||
return;
|
||||
|
||||
if ((size_t) n > *size) {
|
||||
msg[*size] = '\0';
|
||||
n = *size;
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (c == NULL || c->session == NULL)
|
||||
continue;
|
||||
if (c->session->curw->window != w)
|
||||
continue;
|
||||
|
||||
status_write_client(c);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
status_write_session(struct session *s)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
||||
if (s->flags & SESSION_UNATTACHED)
|
||||
return;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (c == NULL || c->session != s)
|
||||
continue;
|
||||
status_write_client(c);
|
||||
}
|
||||
|
||||
for (ptr = msg; *ptr != '\0'; ptr++)
|
||||
input_store8(b, *ptr);
|
||||
(*size) -= n;
|
||||
|
||||
xfree(msg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user