=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.76 retrieving revision 1.77 diff -c -r1.76 -r1.77 *** src/usr.bin/tmux/tty.c 2009/12/02 22:13:15 1.76 --- src/usr.bin/tmux/tty.c 2009/12/03 22:50:10 1.77 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.76 2009/12/02 22:13:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.77 2009/12/03 22:50:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 44,50 **** 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, int fd, char *term) --- 44,50 ---- 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, int fd, char *term) *************** *** 502,508 **** if (screen_check_selection(s, i, py)) { memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc); tmpgc.data = gc->data; ! tmpgc.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256); tmpgc.flags |= s->sel.cell.flags & (GRID_FLAG_FG256|GRID_FLAG_BG256); --- 502,508 ---- if (screen_check_selection(s, i, py)) { memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc); tmpgc.data = gc->data; ! tmpgc.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256); tmpgc.flags |= s->sel.cell.flags & (GRID_FLAG_FG256|GRID_FLAG_BG256); *************** *** 562,568 **** void tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; --- 562,568 ---- void tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; *************** *** 573,584 **** 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); ! else if (tty_term_has(tty->term, TTYC_SMIR) && tty_term_has(tty->term, TTYC_RMIR)) { tty_putcode(tty, TTYC_SMIR); for (i = 0; i < ctx->num; i++) --- 573,584 ---- 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); ! else if (tty_term_has(tty->term, TTYC_SMIR) && tty_term_has(tty->term, TTYC_RMIR)) { tty_putcode(tty, TTYC_SMIR); for (i = 0; i < ctx->num; i++) *************** *** 591,597 **** void tty_cmd_deletecharacter(struct tty *tty, const 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 || --- 591,597 ---- void tty_cmd_deletecharacter(struct tty *tty, const 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 || *************** *** 603,609 **** 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)) --- 603,609 ---- 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)) *************** *** 613,623 **** void tty_cmd_insertline(struct tty *tty, const 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) || !tty_term_has(tty->term, TTYC_IL1)) { tty_redraw_region(tty, ctx); return; --- 613,623 ---- void tty_cmd_insertline(struct tty *tty, const 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) || !tty_term_has(tty->term, TTYC_IL1)) { tty_redraw_region(tty, ctx); return; *************** *** 625,632 **** 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); } --- 625,632 ---- 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); } *************** *** 634,643 **** void tty_cmd_deleteline(struct tty *tty, const 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) || !tty_term_has(tty->term, TTYC_DL1)) { tty_redraw_region(tty, ctx); --- 634,643 ---- void tty_cmd_deleteline(struct tty *tty, const 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) || !tty_term_has(tty->term, TTYC_DL1)) { tty_redraw_region(tty, ctx); *************** *** 646,653 **** 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); } --- 646,653 ---- 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); } *************** *** 655,667 **** void tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; 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)) { --- 655,667 ---- void tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; 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)) { *************** *** 675,681 **** void tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; --- 675,681 ---- void tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; *************** *** 695,701 **** void tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; u_int i; tty_reset(tty); --- 695,701 ---- void tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; u_int i; tty_reset(tty); *************** *** 713,725 **** void tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; if (ctx->ocy != ctx->orupper) return; ! if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR) || !tty_term_has(tty->term, TTYC_RI)) { tty_redraw_region(tty, ctx); --- 713,725 ---- void tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; if (ctx->ocy != ctx->orupper) return; ! if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR) || !tty_term_has(tty->term, TTYC_RI)) { tty_redraw_region(tty, ctx); *************** *** 727,749 **** } 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); } void tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; if (ctx->ocy != ctx->orlower) return; ! if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { tty_redraw_region(tty, ctx); return; --- 727,749 ---- } 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); } void tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; if (ctx->ocy != ctx->orlower) return; ! if (wp->xoff != 0 || screen_size_x(s) < tty->sx || !tty_term_has(tty->term, TTYC_CSR)) { tty_redraw_region(tty, ctx); return; *************** *** 758,774 **** return; 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'); } void tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i, j; --- 758,774 ---- return; 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'); } void tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i, j; *************** *** 804,810 **** void tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i, j; --- 804,810 ---- void tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i, j; *************** *** 834,840 **** void tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i, j; --- 834,840 ---- void tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx) { ! struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i, j; *************** *** 921,927 **** * Cannot rely on not being a partial character, so just redraw the * whole line. */ ! tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); } void --- 921,927 ---- * Cannot rely on not being a partial character, so just redraw the * whole line. */ ! tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); } void *************** *** 980,986 **** tty_region_pane( struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower) { ! struct window_pane *wp = ctx->wp; tty_region(tty, wp->yoff + rupper, wp->yoff + rlower); } --- 980,986 ---- tty_region_pane( struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower) { ! struct window_pane *wp = ctx->wp; tty_region(tty, wp->yoff + rupper, wp->yoff + rlower); } *************** *** 1016,1022 **** 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); } --- 1016,1022 ---- 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); } *************** *** 1028,1034 **** struct tty_term *term = tty->term; u_int thisx, thisy; int change; ! if (cx > tty->sx - 1) cx = tty->sx - 1; --- 1028,1034 ---- struct tty_term *term = tty->term; u_int thisx, thisy; int change; ! if (cx > tty->sx - 1) cx = tty->sx - 1; *************** *** 1103,1109 **** */ /* One above. */ ! if (thisy != tty->rupper && cy == thisy - 1 && tty_term_has(term, TTYC_CUU1)) { tty_putcode(tty, TTYC_CUU1); goto out; --- 1103,1109 ---- */ /* One above. */ ! if (thisy != tty->rupper && cy == thisy - 1 && tty_term_has(term, TTYC_CUU1)) { tty_putcode(tty, TTYC_CUU1); goto out; *************** *** 1120,1127 **** change = thisy - cy; /* +ve up, -ve down */ /* ! * Try to use VPA if change is larger than absolute or if this change ! * would cross the scroll region, otherwise use CUU/CUD. */ if (abs(change) > cy || (change < 0 && cy - change > tty->rlower) || --- 1120,1127 ---- change = thisy - cy; /* +ve up, -ve down */ /* ! * Try to use VPA if change is larger than absolute or if this ! * change would cross the scroll region, otherwise use CUU/CUD. */ if (abs(change) > cy || (change < 0 && cy - change > tty->rlower) || *************** *** 1265,1271 **** } if (bg_default && bg != tc->bg && !(tc->flags & GRID_FLAG_BG256)) { ! if (have_ax) tty_puts(tty, "\033[49m"); else if (tc->bg != 0) tty_putcode1(tty, TTYC_SETAB, 0); --- 1265,1271 ---- } if (bg_default && bg != tc->bg && !(tc->flags & GRID_FLAG_BG256)) { ! if (have_ax) tty_puts(tty, "\033[49m"); else if (tc->bg != 0) tty_putcode1(tty, TTYC_SETAB, 0); *************** *** 1315,1321 **** /* Otherwise set the foreground colour. */ tty_putcode1(tty, TTYC_SETAF, fg); ! save_fg: /* Save the new values in the terminal current cell. */ tc->fg = fg; tc->flags &= ~GRID_FLAG_FG256; --- 1315,1321 ---- /* Otherwise set the foreground colour. */ tty_putcode1(tty, TTYC_SETAF, fg); ! save_fg: /* Save the new values in the terminal current cell. */ tc->fg = fg; tc->flags &= ~GRID_FLAG_FG256;