Two-column display for on-line print.

This commit is contained in:
Nicholas Marriott 2007-11-16 22:06:45 +00:00
parent 6859306235
commit 54d01c1a5f
2 changed files with 20 additions and 6 deletions

View File

@ -1,5 +1,7 @@
16 November 2007 16 November 2007
* (nicm) Split in-client display into two columns. This is a hack but not a lot
more so than that bit is already and it helps with lots of keys.
* (nicm) switch-client command to switch client between different sessions. This * (nicm) switch-client command to switch client between different sessions. This
is pretty cool: is pretty cool:
@ -221,4 +223,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.71 2007-11-16 21:43:43 nicm Exp $ $Id: CHANGES,v 1.72 2007-11-16 22:06:45 nicm Exp $

View File

@ -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> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -159,7 +159,9 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...)
void void
key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...) key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...)
{ {
static u_int line;
struct client *c = ctx->client; struct client *c = ctx->client;
struct screen *s = &c->session->curw->window->screen;
struct hdr hdr; struct hdr hdr;
va_list ap; va_list ap;
char *msg; char *msg;
@ -170,25 +172,35 @@ key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...)
buffer_add(c->out, sizeof hdr); buffer_add(c->out, sizeof hdr);
size = BUFFER_USED(c->out); 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); 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_two(c->out, CODE_CURSORMOVE, i + 1, 1);
input_store_zero(c->out, CODE_CLEARLINE); input_store_zero(c->out, CODE_CLEARLINE);
} }
input_store_two(c->out, CODE_CURSORMOVE, 1, 1); input_store_two(c->out, CODE_CURSORMOVE, 1, 1);
input_store_two(c->out, CODE_ATTRIBUTES, 0, 0x88); input_store_two(c->out, CODE_ATTRIBUTES, 0, 0x88);
line = 0;
c->flags |= CLIENT_HOLD; 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); va_start(ap, fmt);
xvasprintf(&msg, fmt, ap); xvasprintf(&msg, fmt, ap);
va_end(ap); va_end(ap);
if (strlen(msg) > s->sx / 2)
msg[s->sx / 2] = '\0';
buffer_write(c->out, msg, strlen(msg)); buffer_write(c->out, msg, strlen(msg));
input_store8(c->out, '\r'); if (line != s->sy && line != 2 * s->sy) {
input_store8(c->out, '\n'); input_store8(c->out, '\r');
input_store8(c->out, '\n');
}
xfree(msg); xfree(msg);
size = BUFFER_USED(c->out) - size; size = BUFFER_USED(c->out) - size;