=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.40 retrieving revision 1.41 diff -c -r1.40 -r1.41 *** src/usr.bin/tmux/tty.c 2009/10/12 09:16:59 1.40 --- src/usr.bin/tmux/tty.c 2009/10/12 09:29:58 1.41 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.40 2009/10/12 09:16:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.41 2009/10/12 09:29:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 451,457 **** if (sx > tty->sx) sx = tty->sx; ! tty_cursor(tty, 0, py, ox, oy); for (i = 0; i < sx; i++) { gc = grid_view_peek_cell(s->grid, i, py); --- 451,457 ---- if (sx > tty->sx) sx = tty->sx; ! tty_cursor(tty, ox, oy + py); for (i = 0; i < sx; i++) { gc = grid_view_peek_cell(s->grid, i, py); *************** *** 477,483 **** } tty_reset(tty); ! tty_cursor(tty, sx, py, ox, oy); if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) tty_putcode(tty, TTYC_EL); else { --- 477,483 ---- } tty_reset(tty); ! tty_cursor(tty, ox + sx, oy + py); if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) tty_putcode(tty, TTYC_EL); else { *************** *** 532,538 **** 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); --- 532,539 ---- tty_reset(tty); ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); ! 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); *************** *** 559,565 **** tty_reset(tty); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); if (tty_term_has(tty->term, TTYC_DCH) || tty_term_has(tty->term, TTYC_DCH1)) tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num); --- 560,567 ---- tty_reset(tty); ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); ! if (tty_term_has(tty->term, TTYC_DCH) || tty_term_has(tty->term, TTYC_DCH1)) tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num); *************** *** 580,587 **** tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); - tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); } --- 582,589 ---- tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); + tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); } *************** *** 600,607 **** tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); - tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); } --- 602,609 ---- tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); + tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); } *************** *** 614,620 **** 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); --- 616,623 ---- tty_reset(tty); ! tty_cursor_pane(tty, ctx, 0, ctx->ocy); ! if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { tty_putcode(tty, TTYC_EL); *************** *** 633,639 **** 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); --- 636,643 ---- tty_reset(tty); ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); ! if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) tty_putcode(tty, TTYC_EL); *************** *** 652,661 **** 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, ' '); } --- 656,665 ---- tty_reset(tty); if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) { ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_putcode(tty, TTYC_EL1); } else { ! tty_cursor_pane(tty, ctx, 0, ctx->ocy); for (i = 0; i < ctx->ocx + 1; i++) tty_putc(tty, ' '); } *************** *** 677,683 **** tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff); tty_putcode(tty, TTYC_RI); } --- 681,687 ---- tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); tty_putcode(tty, TTYC_RI); } *************** *** 699,705 **** tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff); tty_putc(tty, '\n'); } --- 703,709 ---- tty_reset(tty); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_putc(tty, '\n'); } *************** *** 715,727 **** tty_reset(tty); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! 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) --- 719,731 ---- tty_reset(tty); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); 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_pane(tty, ctx, 0, ctx->ocy + 1); for (i = ctx->ocy + 1; i < screen_size_y(s); i++) { tty_putcode(tty, TTYC_EL); if (i == screen_size_y(s) - 1) *************** *** 734,740 **** 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, ' '); } --- 738,744 ---- 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_pane(tty, ctx, 0, j); for (i = 0; i < screen_size_x(s); i++) tty_putc(tty, ' '); } *************** *** 751,757 **** tty_reset(tty); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! 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)) { --- 755,761 ---- tty_reset(tty); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_cursor_pane(tty, ctx, 0, 0); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { *************** *** 762,768 **** } } 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, ' '); } --- 766,772 ---- } } else { for (j = 0; j < ctx->ocy; j++) { ! tty_cursor_pane(tty, ctx, 0, j); for (i = 0; i < screen_size_x(s); i++) tty_putc(tty, ' '); } *************** *** 781,787 **** tty_reset(tty); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! 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)) { --- 785,791 ---- tty_reset(tty); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_cursor_pane(tty, ctx, 0, 0); if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL)) { *************** *** 794,800 **** } } else { 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, ' '); } --- 798,804 ---- } } else { for (j = 0; j < screen_size_y(s); j++) { ! tty_cursor_pane(tty, ctx, 0, j); for (i = 0; i < screen_size_x(s); i++) tty_putc(tty, ' '); } *************** *** 813,819 **** tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); 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'); } --- 817,823 ---- tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); for (j = 0; j < screen_size_y(s); j++) { ! tty_cursor_pane(tty, ctx, 0, j); for (i = 0; i < screen_size_x(s); i++) tty_putc(tty, 'E'); } *************** *** 822,831 **** void tty_cmd_cell(struct tty *tty, const 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); } --- 826,833 ---- void tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) { ! tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cell(tty, ctx->cell, ctx->utf8); } *************** *** 922,935 **** } void ! tty_cursor(struct tty *tty, u_int cx, u_int cy, u_int ox, u_int oy) { ! if (ox + cx == 0 && tty->cx != 0 && tty->cy == oy + cy) { tty->cx = 0; tty_putc(tty, '\r'); ! } else if (tty->cx != ox + cx || tty->cy != oy + cy) { ! tty->cx = ox + cx; ! tty->cy = oy + cy; tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); } } --- 924,945 ---- } void ! tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy) { ! struct window_pane *wp = ctx->wp; ! ! tty_cursor(tty, wp->xoff + cx, wp->yoff + cy); ! } ! ! void ! tty_cursor(struct tty *tty, u_int cx, u_int cy) ! { ! if (cx == 0 && tty->cx != 0 && tty->cy == cy) { tty->cx = 0; tty_putc(tty, '\r'); ! } else if (tty->cx != cx || tty->cy != cy) { ! tty->cx = cx; ! tty->cy = cy; tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx); } }