=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/tmux/tty.c 2009/07/22 15:55:32 1.11 --- src/usr.bin/tmux/tty.c 2009/07/22 16:45:31 1.12 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.11 2009/07/22 15:55:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.12 2009/07/22 16:45:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 38,60 **** 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); ! void tty_cmd_clearline(struct tty *, struct window_pane *, va_list); ! void tty_cmd_clearscreen(struct tty *, struct window_pane *, va_list); ! void tty_cmd_clearstartofline(struct tty *, struct window_pane *, va_list); ! void tty_cmd_clearstartofscreen(struct tty *, struct window_pane *, va_list); ! void tty_cmd_deletecharacter(struct tty *, struct window_pane *, va_list); ! void tty_cmd_deleteline(struct tty *, struct window_pane *, va_list); ! void tty_cmd_insertcharacter(struct tty *, struct window_pane *, va_list); ! void tty_cmd_insertline(struct tty *, struct window_pane *, va_list); ! void tty_cmd_linefeed(struct tty *, struct window_pane *, va_list); ! void tty_cmd_utf8character(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, --- 38,60 ---- 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 tty_ctx *); ! void tty_cmd_cell(struct tty *, struct tty_ctx *); ! void tty_cmd_clearendofline(struct tty *, struct tty_ctx *); ! void tty_cmd_clearendofscreen(struct tty *, struct tty_ctx *); ! void tty_cmd_clearline(struct tty *, struct tty_ctx *); ! void tty_cmd_clearscreen(struct tty *, struct tty_ctx *); ! void tty_cmd_clearstartofline(struct tty *, struct tty_ctx *); ! void tty_cmd_clearstartofscreen(struct tty *, struct tty_ctx *); ! void tty_cmd_deletecharacter(struct tty *, struct tty_ctx *); ! void tty_cmd_deleteline(struct tty *, struct tty_ctx *); ! void tty_cmd_insertcharacter(struct tty *, struct tty_ctx *); ! void tty_cmd_insertline(struct tty *, struct tty_ctx *); ! void tty_cmd_linefeed(struct tty *, struct tty_ctx *); ! void tty_cmd_utf8character(struct tty *, struct tty_ctx *); ! void tty_cmd_reverseindex(struct tty *, struct tty_ctx *); ! void (*tty_cmds[])(struct tty *, struct tty_ctx *) = { tty_cmd_alignmenttest, tty_cmd_cell, tty_cmd_clearendofline, *************** *** 545,610 **** } void ! tty_vwrite( ! struct tty *tty, struct window_pane *wp, enum tty_cmd cmd, va_list ap) { if (tty->flags & TTY_FREEZE || tty->term == NULL) return; if (tty_cmds[cmd] != NULL) ! tty_cmds[cmd](tty, wp, ap); } void ! tty_cmd_insertcharacter(struct tty *tty, struct window_pane *wp, va_list ap) { ! struct screen *s = wp->screen; ! u_int ua; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff); return; } - ua = va_arg(ap, u_int); - tty_reset(tty); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); if (tty_term_has(tty->term, TTYC_ICH) || tty_term_has(tty->term, TTYC_ICH1)) ! tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ua); else { tty_putcode(tty, TTYC_SMIR); ! while (ua-- > 0) tty_putc(tty, ' '); tty_putcode(tty, TTYC_RMIR); } } void ! tty_cmd_deletecharacter(struct tty *tty, struct window_pane *wp, va_list ap) { ! struct screen *s = wp->screen; ! u_int ua; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff); return; } - ua = va_arg(ap, u_int); - tty_reset(tty); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ua); } void ! tty_cmd_insertline(struct tty *tty, struct window_pane *wp, va_list ap) { ! struct screen *s = wp->screen; ! u_int ua; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { --- 545,605 ---- } void ! tty_write(struct tty *tty, enum tty_cmd cmd, struct tty_ctx *ctx) { if (tty->flags & TTY_FREEZE || tty->term == NULL) return; if (tty_cmds[cmd] != NULL) ! tty_cmds[cmd](tty, ctx); } void ! tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff); return; } tty_reset(tty); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); if (tty_term_has(tty->term, TTYC_ICH) || tty_term_has(tty->term, TTYC_ICH1)) ! tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); else { tty_putcode(tty, TTYC_SMIR); ! while (ctx->num-- > 0) tty_putc(tty, ' '); tty_putcode(tty, TTYC_RMIR); } } void ! tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff); return; } tty_reset(tty); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num); } void ! tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { *************** *** 612,632 **** return; } - ua = va_arg(ap, u_int); - tty_reset(tty); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ua); } void ! tty_cmd_deleteline(struct tty *tty, struct window_pane *wp, va_list ap) { ! struct screen *s = wp->screen; ! u_int ua; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { --- 607,625 ---- return; } tty_reset(tty); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); } void ! tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { *************** *** 634,654 **** return; } - ua = va_arg(ap, u_int); - tty_reset(tty); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ua); } void ! tty_cmd_clearline(struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; ! u_int i; tty_reset(tty); --- 627,646 ---- return; } tty_reset(tty); tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); } void ! tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i; tty_reset(tty); *************** *** 663,673 **** } void ! tty_cmd_clearendofline( ! struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; ! u_int i; tty_reset(tty); --- 655,665 ---- } void ! tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i; tty_reset(tty); *************** *** 682,692 **** } void ! tty_cmd_clearstartofline( ! struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; ! u_int i; tty_reset(tty); --- 674,684 ---- } void ! tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i; tty_reset(tty); *************** *** 701,709 **** } void ! tty_cmd_reverseindex(struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { --- 693,702 ---- } void ! tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { *************** *** 722,730 **** } void ! tty_cmd_linefeed(struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { --- 715,724 ---- } void ! tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { *************** *** 743,753 **** } void ! tty_cmd_clearendofscreen( ! struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); --- 737,747 ---- } void ! tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); *************** *** 778,788 **** } void ! tty_cmd_clearstartofscreen( ! struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); --- 772,782 ---- } void ! tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); *************** *** 807,817 **** } void ! tty_cmd_clearscreen( ! struct tty *tty, struct window_pane *wp, unused va_list ap) { ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); --- 801,811 ---- } void ! tty_cmd_clearscreen(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); *************** *** 836,846 **** } 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); --- 830,840 ---- } void ! tty_cmd_alignmenttest(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i, j; tty_reset(tty); *************** *** 854,886 **** } void ! tty_cmd_cell(struct tty *tty, struct window_pane *wp, va_list ap) { struct screen *s = wp->screen; - struct grid_cell *gc; - struct grid_utf8 *gu; - gc = va_arg(ap, struct grid_cell *); - gu = va_arg(ap, struct grid_utf8 *); - tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_cell(tty, gc, gu); } void ! tty_cmd_utf8character( ! struct tty *tty, unused struct window_pane *wp, va_list ap) { ! u_char *buf; size_t i; - buf = va_arg(ap, u_char *); - for (i = 0; i < UTF8_SIZE; i++) { ! if (buf[i] == 0xff) break; ! tty_putc(tty, buf[i]); } } --- 848,873 ---- } void ! tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx) { + struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); ! tty_cell(tty, ctx->cell, ctx->utf8); } void ! tty_cmd_utf8character(struct tty *tty, struct tty_ctx *ctx) { ! u_char *ptr = ctx->ptr; size_t i; for (i = 0; i < UTF8_SIZE; i++) { ! if (ptr[i] == 0xff) break; ! tty_putc(tty, ptr[i]); } }