diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-16 22:06:45 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-16 22:06:45 +0000 |
commit | 54d01c1a5ff8b4c832c439591a9eee745ba75507 (patch) | |
tree | feb22f72030e23c54040c920ea0c984fab461d65 /key-bindings.c | |
parent | 685930623534e1d0c6cd9dff91bb67b6593f844c (diff) | |
download | rtmux-54d01c1a5ff8b4c832c439591a9eee745ba75507.tar.gz rtmux-54d01c1a5ff8b4c832c439591a9eee745ba75507.tar.bz2 rtmux-54d01c1a5ff8b4c832c439591a9eee745ba75507.zip |
Two-column display for on-line print.
Diffstat (limited to 'key-bindings.c')
-rw-r--r-- | key-bindings.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/key-bindings.c b/key-bindings.c index e8a85618..6f165eaa 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.14 2007-11-16 21:43:43 nicm Exp $ */ +/* $Id: key-bindings.c,v 1.15 2007-11-16 22:06:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -159,7 +159,9 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...) void key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...) { + static u_int line; struct client *c = ctx->client; + struct screen *s = &c->session->curw->window->screen; struct hdr hdr; va_list ap; char *msg; @@ -170,25 +172,35 @@ key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...) buffer_add(c->out, sizeof hdr); size = BUFFER_USED(c->out); - if (!(c->flags & CLIENT_HOLD)) { + if (line == 2 * s->sy || !(c->flags & CLIENT_HOLD)) { input_store_zero(c->out, CODE_CURSOROFF); - for (i = 0; i < c->session->curw->window->screen.sy; i++) { + for (i = 0; i < s->sy; i++) { input_store_two(c->out, CODE_CURSORMOVE, i + 1, 1); input_store_zero(c->out, CODE_CLEARLINE); } input_store_two(c->out, CODE_CURSORMOVE, 1, 1); input_store_two(c->out, CODE_ATTRIBUTES, 0, 0x88); + line = 0; c->flags |= CLIENT_HOLD; } + if (line >= s->sy) { + input_store_two( + c->out, CODE_CURSORMOVE, line - s->sy + 1, s->sx / 2); + } + line++; va_start(ap, fmt); xvasprintf(&msg, fmt, ap); va_end(ap); + if (strlen(msg) > s->sx / 2) + msg[s->sx / 2] = '\0'; buffer_write(c->out, msg, strlen(msg)); - input_store8(c->out, '\r'); - input_store8(c->out, '\n'); + if (line != s->sy && line != 2 * s->sy) { + input_store8(c->out, '\r'); + input_store8(c->out, '\n'); + } xfree(msg); size = BUFFER_USED(c->out) - size; |