=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.13 retrieving revision 1.14 diff -c -r1.13 -r1.14 *** src/usr.bin/tmux/tty.c 2009/07/22 18:02:23 1.13 --- src/usr.bin/tmux/tty.c 2009/07/22 20:53:38 1.14 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.13 2009/07/22 18:02:23 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.14 2009/07/22 20:53:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 38,47 **** void tty_attributes_fg(struct tty *, const struct grid_cell *); void tty_attributes_bg(struct tty *, const struct grid_cell *); void tty_emulate_repeat( struct tty *, enum tty_code_code, enum tty_code_code, u_int); ! void tty_cell(struct tty *, ! const struct grid_cell *, const struct grid_utf8 *); void tty_init(struct tty *tty, char *path, char *term) --- 38,48 ---- void tty_attributes_fg(struct tty *, const struct grid_cell *); void tty_attributes_bg(struct tty *, const struct grid_cell *); + void tty_redraw_region(struct tty *, struct tty_ctx *); void tty_emulate_repeat( struct tty *, enum tty_code_code, enum tty_code_code, u_int); ! void tty_cell(struct tty *, ! const struct grid_cell *, const struct grid_utf8 *); void tty_init(struct tty *tty, char *path, char *term) *************** *** 449,458 **** * width of the terminal. */ void ! tty_redraw_region(struct tty *tty, struct window_pane *wp) { ! struct screen *s = wp->screen; ! u_int i; /* * If region is >= 50% of the screen, just schedule a window redraw. In --- 450,460 ---- * width of the terminal. */ void ! tty_redraw_region(struct tty *tty, struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; ! struct screen *s = wp->screen; ! u_int i; /* * If region is >= 50% of the screen, just schedule a window redraw. In *************** *** 460,475 **** * without this, the entire pane ends up being redrawn many times which * can be much more data. */ ! if (s->old_rupper - s->old_rlower >= screen_size_y(s) / 2) { wp->flags |= PANE_REDRAW; return; } ! if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) { ! for (i = s->old_cy; i < screen_size_y(s); i++) tty_draw_line(tty, s, i, wp->xoff, wp->yoff); } else { ! for (i = s->old_rupper; i <= s->old_rlower; i++) tty_draw_line(tty, s, i, wp->xoff, wp->yoff); } } --- 462,477 ---- * without this, the entire pane ends up being redrawn many times which * can be much more data. */ ! if (ctx->orupper - ctx->orlower >= screen_size_y(s) / 2) { wp->flags |= PANE_REDRAW; return; } ! if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) { ! for (i = ctx->ocy; i < screen_size_y(s); i++) tty_draw_line(tty, s, i, wp->xoff, wp->yoff); } else { ! for (i = ctx->orupper; i <= ctx->orlower; i++) tty_draw_line(tty, s, i, wp->xoff, wp->yoff); } } *************** *** 522,534 **** 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); --- 524,536 ---- struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { ! tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); return; } tty_reset(tty); ! tty_cursor(tty, ctx->ocx, ctx->ocy, 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); *************** *** 547,559 **** 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); } --- 549,561 ---- struct screen *s = wp->screen; if (wp->xoff != 0 || screen_size_x(s) < tty->sx) { ! tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); return; } tty_reset(tty); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num); } *************** *** 565,579 **** if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, wp); 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); } --- 567,581 ---- if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, ctx); return; } tty_reset(tty); ! tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); } *************** *** 585,599 **** if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, wp); 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); } --- 587,601 ---- if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, ctx); return; } tty_reset(tty); ! tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); } *************** *** 606,612 **** tty_reset(tty); ! tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { tty_putcode(tty, TTYC_EL); --- 608,614 ---- tty_reset(tty); ! tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { tty_putcode(tty, TTYC_EL); *************** *** 625,636 **** tty_reset(tty); ! tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) tty_putcode(tty, TTYC_EL); else { ! for (i = s->old_cx; i < screen_size_x(s); i++) tty_putc(tty, ' '); } } --- 627,638 ---- tty_reset(tty); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) tty_putcode(tty, TTYC_EL); else { ! for (i = ctx->ocx; i < screen_size_x(s); i++) tty_putc(tty, ' '); } } *************** *** 639,655 **** 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); if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) { ! tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); tty_putcode(tty, TTYC_EL1); } else { ! tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff); ! for (i = 0; i < s->old_cx + 1; i++) tty_putc(tty, ' '); } } --- 641,656 ---- tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; u_int i; tty_reset(tty); if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) { ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_putcode(tty, TTYC_EL1); } else { ! tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff); ! for (i = 0; i < ctx->ocx + 1; i++) tty_putc(tty, ' '); } } *************** *** 662,677 **** if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, wp); return; } tty_reset(tty); ! tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); ! if (s->old_cy == s->old_rupper) { ! tty_cursor(tty, s->old_cx, s->old_rupper, wp->xoff, wp->yoff); tty_putcode(tty, TTYC_RI); } } --- 663,678 ---- if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, ctx); return; } tty_reset(tty); ! tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); ! if (ctx->ocy == ctx->orupper) { ! tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff); tty_putcode(tty, TTYC_RI); } } *************** *** 684,699 **** if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, wp); return; } tty_reset(tty); ! tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff); ! if (s->old_cy == s->old_rlower) { ! tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); tty_putc(tty, '\n'); } } --- 685,700 ---- if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { ! tty_redraw_region(tty, ctx); return; } tty_reset(tty); ! tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff); ! if (ctx->ocy == ctx->orlower) { ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_putc(tty, '\n'); } } *************** *** 708,720 **** tty_reset(tty); tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); ! tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { tty_putcode(tty, TTYC_EL); ! if (s->old_cy != screen_size_y(s) - 1) { ! tty_cursor(tty, 0, s->old_cy + 1, wp->xoff, wp->yoff); ! for (i = s->old_cy + 1; i < screen_size_y(s); i++) { tty_putcode(tty, TTYC_EL); if (i == screen_size_y(s) - 1) continue; --- 709,721 ---- tty_reset(tty); tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { tty_putcode(tty, TTYC_EL); ! if (ctx->ocy != screen_size_y(s) - 1) { ! tty_cursor(tty, 0, ctx->ocy + 1, wp->xoff, wp->yoff); ! for (i = ctx->ocy + 1; i < screen_size_y(s); i++) { tty_putcode(tty, TTYC_EL); if (i == screen_size_y(s) - 1) continue; *************** *** 723,731 **** } } } else { ! for (i = s->old_cx; i < screen_size_x(s); i++) tty_putc(tty, ' '); ! for (j = s->old_cy; 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, ' '); --- 724,732 ---- } } } else { ! for (i = ctx->ocx; i < screen_size_x(s); i++) tty_putc(tty, ' '); ! for (j = ctx->ocy; 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, ' '); *************** *** 746,764 **** tty_cursor(tty, 0, 0, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { ! for (i = 0; i < s->old_cy; i++) { tty_putcode(tty, TTYC_EL); tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1); tty->cy++; } } else { ! for (j = 0; j < s->old_cy; j++) { tty_cursor(tty, 0, j, wp->xoff, wp->yoff); for (i = 0; i < screen_size_x(s); i++) tty_putc(tty, ' '); } } ! for (i = 0; i <= s->old_cx; i++) tty_putc(tty, ' '); } --- 747,765 ---- tty_cursor(tty, 0, 0, wp->xoff, wp->yoff); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { ! for (i = 0; i < ctx->ocy; i++) { tty_putcode(tty, TTYC_EL); tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1); tty->cy++; } } else { ! for (j = 0; j < ctx->ocy; j++) { tty_cursor(tty, 0, j, wp->xoff, wp->yoff); for (i = 0; i < screen_size_x(s); i++) tty_putc(tty, ' '); } } ! for (i = 0; i <= ctx->ocx; i++) tty_putc(tty, ' '); } *************** *** 813,821 **** 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); } --- 814,821 ---- tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx) { struct window_pane *wp = ctx->wp; ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_cell(tty, ctx->cell, ctx->utf8); }