summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-11-27 19:23:34 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-11-27 19:23:34 +0000
commit76c8a590db14131928f79123adcab934a3825501 (patch)
tree359cbfac219a68d5137bd3ec02b31ecb33cbd288 /status.c
parent97eca99d0bae6c4fdfc38a6f42d42f05c8faac4b (diff)
Big internal reorganisation to move tty control into parent.
Diffstat (limited to 'status.c')
-rw-r--r--status.c87
1 files changed, 46 insertions, 41 deletions
diff --git a/status.c b/status.c
index 15821313..f6b0a057 100644
--- a/status.c
+++ b/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, ' ');
-
- 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_clear_line_to(&ctx, screen_last_x(ctx.s));
+
+ 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;
+
+ if (w->screen.mode & MODE_HIDDEN)
+ return;
- va_start(ap, fmt);
- n = xvasprintf(&msg, fmt, ap);
- va_end(ap);
+ 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;
- if ((size_t) n > *size) {
- msg[*size] = '\0';
- n = *size;
+ status_write_client(c);
}
+}
- for (ptr = msg; *ptr != '\0'; ptr++)
- input_store8(b, *ptr);
- (*size) -= n;
+void
+status_write_session(struct session *s)
+{
+ struct client *c;
+ u_int i;
- xfree(msg);
+ 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);
+ }
}