diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-03 23:30:41 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-03 23:30:41 +0000 |
commit | c343c54e7e06f65e055482dd38bf60a1af95f807 (patch) | |
tree | 72b1d2684b86e746c1ec5874aff33f4bab433180 | |
parent | 1a98409cc428d08343951a211c5ab412792a09bf (diff) |
Implement the DEC alignment test. With the last change this is enough for the
first cursor test in vttest (in ports) to pass; it still shops a few more
problems though.
-rw-r--r-- | usr.bin/tmux/input.c | 29 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 27 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 22 |
4 files changed, 73 insertions, 9 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 2906e702665..388e306bd08 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.2 2009/06/03 19:33:04 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.3 2009/06/03 23:30:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -630,6 +630,9 @@ input_handle_c1_control(u_char ch, struct input_ctx *ictx) log_debug2("-- c1 %zu: %hhu (%c)", ictx->off, ch, ch); switch (ch) { + case 'D': /* IND */ + screen_write_linefeed(&ictx->ctx); + break; case 'E': /* NEL */ screen_write_carriagereturn(&ictx->ctx); screen_write_linefeed(&ictx->ctx); @@ -652,7 +655,7 @@ input_handle_private_two(u_char ch, struct input_ctx *ictx) "-- p2 %zu: %hhu (%c) %hhu", ictx->off, ch, ch, ictx->intermediate); switch (ch) { - case '0': /* Dscs (graphics) */ + case '0': /* SCS */ /* * Not really supported, but fake it up enough for those that * use it to switch character sets (by redefining G0 to @@ -665,22 +668,36 @@ input_handle_private_two(u_char ch, struct input_ctx *ictx) } break; case '=': /* DECKPAM */ + if (ictx->intermediate != '\0') + break; screen_write_kkeypadmode(&ictx->ctx, 1); log_debug("kkeypad on (application mode)"); break; case '>': /* DECKPNM */ + if (ictx->intermediate != '\0') + break; screen_write_kkeypadmode(&ictx->ctx, 0); log_debug("kkeypad off (number mode)"); break; case '7': /* DECSC */ + if (ictx->intermediate != '\0') + break; memcpy(&ictx->saved_cell, &ictx->cell, sizeof ictx->saved_cell); ictx->saved_cx = s->cx; ictx->saved_cy = s->cy; break; - case '8': /* DECRC */ - memcpy(&ictx->cell, &ictx->saved_cell, sizeof ictx->cell); - screen_write_cursormove( - &ictx->ctx, ictx->saved_cx, ictx->saved_cy); + case '8': + switch (ictx->intermediate) { + case '\0': /* DECRC */ + memcpy( + &ictx->cell, &ictx->saved_cell, sizeof ictx->cell); + screen_write_cursormove( + &ictx->ctx, ictx->saved_cx, ictx->saved_cy); + break; + case '#': /* DECALN */ + screen_write_alignmenttest(&ictx->ctx); + break; + } break; default: log_debug("unknown p2: %hhu", ch); diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 3e45e497cd9..9908ffa8049 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.4 2009/06/03 23:26:56 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.5 2009/06/03 23:30:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -291,6 +291,31 @@ screen_write_cursorleft(struct screen_write_ctx *ctx, u_int nx) s->cx -= nx; } +/* VT100 alignment test. */ +void +screen_write_alignmenttest(struct screen_write_ctx *ctx) +{ + struct screen *s = ctx->s; + struct grid_cell gc; + u_int xx, yy; + + memcpy(&gc, &grid_default_cell, sizeof gc); + gc.data = 'E'; + + for (yy = 0; yy < screen_size_y(s); yy++) { + for (xx = 0; xx < screen_size_x(s); xx++) + grid_view_set_cell(s->grid, xx, yy, &gc); + } + + s->cx = 0; + s->cy = 0; + + s->rupper = 0; + s->rlower = screen_size_y(s) - 1; + + tty_write_cmd(ctx->wp, TTY_ALIGNMENTTEST); +} + /* Insert nx characters. */ void screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx) diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 067c89e7acc..04024f54865 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.4 2009/06/03 16:54:26 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.5 2009/06/03 23:30:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -279,6 +279,7 @@ struct tty_term_code_entry { /* Output commands. */ enum tty_cmd { + TTY_ALIGNMENTTEST, TTY_CELL, TTY_CLEARENDOFLINE, TTY_CLEARENDOFSCREEN, @@ -1363,6 +1364,7 @@ void screen_write_cursorup(struct screen_write_ctx *, u_int); void screen_write_cursordown(struct screen_write_ctx *, u_int); void screen_write_cursorright(struct screen_write_ctx *, u_int); void screen_write_cursorleft(struct screen_write_ctx *, u_int); +void screen_write_alignmenttest(struct screen_write_ctx *); void screen_write_insertcharacter(struct screen_write_ctx *, u_int); void screen_write_deletecharacter(struct screen_write_ctx *, u_int); void screen_write_insertline(struct screen_write_ctx *, u_int); diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 834ef713026..8f1bb963b3b 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.3 2009/06/03 23:26:56 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.4 2009/06/03 23:30:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -38,6 +38,7 @@ void tty_attributes(struct tty *, const struct grid_cell *); void tty_attributes_fg(struct tty *, const struct grid_cell *); void tty_attributes_bg(struct tty *, const struct grid_cell *); +void tty_cmd_alignmenttest(struct tty *, struct window_pane *, va_list); void tty_cmd_cell(struct tty *, struct window_pane *, va_list); void tty_cmd_clearendofline(struct tty *, struct window_pane *, va_list); void tty_cmd_clearendofscreen(struct tty *, struct window_pane *, va_list); @@ -54,6 +55,7 @@ void tty_cmd_raw(struct tty *, struct window_pane *, va_list); void tty_cmd_reverseindex(struct tty *, struct window_pane *, va_list); void (*tty_cmds[])(struct tty *, struct window_pane *, va_list) = { + tty_cmd_alignmenttest, tty_cmd_cell, tty_cmd_clearendofline, tty_cmd_clearendofscreen, @@ -831,6 +833,24 @@ tty_cmd_clearscreen( } void +tty_cmd_alignmenttest( + struct tty *tty, struct window_pane *wp, unused va_list ap) +{ + struct screen *s = wp->screen; + u_int i, j; + + tty_reset(tty); + + tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); + + for (j = 0; j < screen_size_y(s); j++) { + tty_cursor(tty, 0, j, wp->xoff, wp->yoff); + for (i = 0; i < screen_size_x(s); i++) + tty_putc(tty, 'E'); + } +} + +void tty_cmd_cell(struct tty *tty, struct window_pane *wp, va_list ap) { struct screen *s = wp->screen; |