=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.213 retrieving revision 1.214 diff -c -r1.213 -r1.214 *** src/usr.bin/tmux/tty.c 2016/11/15 14:08:27 1.213 --- src/usr.bin/tmux/tty.c 2016/11/15 15:17:28 1.214 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.213 2016/11/15 14:08:27 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.214 2016/11/15 15:17:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 55,61 **** --- 55,63 ---- static void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int); + static void tty_region(struct tty *, u_int, u_int); static void tty_margin_pane(struct tty *, const struct tty_ctx *); + static void tty_margin(struct tty *, u_int, u_int); static int tty_large_region(struct tty *, const struct tty_ctx *); static int tty_fake_bce(const struct tty *, const struct window_pane *, u_int); *************** *** 73,79 **** #define tty_use_acs(tty) \ (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) #define tty_use_margin(tty) \ ! (0 && (tty)->term_type == TTY_VT420) #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) --- 75,81 ---- #define tty_use_acs(tty) \ (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) #define tty_use_margin(tty) \ ! ((tty)->term_type == TTY_VT420) #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) *************** *** 153,160 **** */ if (tty->flags & TTY_STARTED) { tty_cursor(tty, 0, 0); ! tty_region(tty, 0, tty->sy - 1); ! tty_margin(tty, 0, tty->sx - 1); } return (1); --- 155,162 ---- */ if (tty->flags & TTY_STARTED) { tty_cursor(tty, 0, 0); ! tty_region_off(tty); ! tty_margin_off(tty); } return (1); *************** *** 696,701 **** --- 698,706 ---- tty->flags |= TTY_NOCURSOR; tty_update_mode(tty, tty->mode, s); + tty_region_off(tty); + tty_margin_off(tty); + sx = screen_size_x(s); if (sx > s->grid->linedata[s->grid->hsize + py].cellsize) sx = s->grid->linedata[s->grid->hsize + py].cellsize; *************** *** 855,861 **** tty_default_attributes(tty, ctx->wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_pane(tty, ctx); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); --- 860,866 ---- tty_default_attributes(tty, ctx->wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_off(tty); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); *************** *** 875,881 **** tty_default_attributes(tty, ctx->wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_pane(tty, ctx); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); --- 880,886 ---- tty_default_attributes(tty, ctx->wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_off(tty); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); *************** *** 952,958 **** tty_attributes(tty, &grid_default_cell, ctx->wp); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_pane(tty, ctx); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); tty_putcode(tty, TTYC_RI); --- 957,963 ---- tty_attributes(tty, &grid_default_cell, ctx->wp); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_off(tty); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); tty_putcode(tty, TTYC_RI); *************** *** 981,987 **** * using margins, don't do anything - the cursor can just be moved * to the last cell and wrap naturally. */ ! if (!tty_use_margin(tty) && ctx->num != 0 && !(tty->term->flags & TERM_EARLYWRAP)) { return; --- 986,993 ---- * using margins, don't do anything - the cursor can just be moved * to the last cell and wrap naturally. */ ! if ((!tty_use_margin(tty) || ! tty_pane_full_width(tty, ctx)) && ctx->num != 0 && !(tty->term->flags & TERM_EARLYWRAP)) { return; *************** *** 1015,1021 **** tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_pane(tty, ctx); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); if (tty_pane_full_width(tty, ctx) && --- 1021,1027 ---- tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_off(tty); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); if (tty_pane_full_width(tty, ctx) && *************** *** 1051,1057 **** tty_attributes(tty, &grid_default_cell, wp); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_pane(tty, ctx); tty_cursor_pane(tty, ctx, 0, 0); if (tty_pane_full_width(tty, ctx) && --- 1057,1063 ---- tty_attributes(tty, &grid_default_cell, wp); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_off(tty); tty_cursor_pane(tty, ctx, 0, 0); if (tty_pane_full_width(tty, ctx) && *************** *** 1081,1087 **** tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_pane(tty, ctx); tty_cursor_pane(tty, ctx, 0, 0); if (tty_pane_full_width(tty, ctx) && --- 1087,1093 ---- tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_off(tty); tty_cursor_pane(tty, ctx, 0, 0); if (tty_pane_full_width(tty, ctx) && *************** *** 1112,1118 **** tty_attributes(tty, &grid_default_cell, wp); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_pane(tty, ctx); for (j = 0; j < screen_size_y(s); j++) { tty_cursor_pane(tty, ctx, 0, j); --- 1118,1124 ---- tty_attributes(tty, &grid_default_cell, wp); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); ! tty_margin_off(tty); for (j = 0; j < screen_size_y(s); j++) { tty_cursor_pane(tty, ctx, 0, j); *************** *** 1130,1136 **** if (ctx->ocy == ctx->orlower) tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_pane(tty, ctx); /* Is the cursor in the very last position? */ width = ctx->cell->data.width; --- 1136,1142 ---- if (ctx->ocy == ctx->orlower) tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); ! tty_margin_off(tty); /* Is the cursor in the very last position? */ width = ctx->cell->data.width; *************** *** 1258,1263 **** --- 1264,1276 ---- memcpy(gc, &grid_default_cell, sizeof *gc); } + /* Turn off margin. */ + void + tty_region_off(struct tty *tty) + { + tty_region(tty, 0, tty->sy - 1); + } + /* Set region inside pane. */ static void tty_region_pane(struct tty *tty, const struct tty_ctx *ctx, u_int rupper, *************** *** 1267,1273 **** } /* Set region at absolute position. */ ! void tty_region(struct tty *tty, u_int rupper, u_int rlower) { if (tty->rlower == rlower && tty->rupper == rupper) --- 1280,1286 ---- } /* Set region at absolute position. */ ! static void tty_region(struct tty *tty, u_int rupper, u_int rlower) { if (tty->rlower == rlower && tty->rupper == rupper) *************** *** 1291,1296 **** --- 1304,1316 ---- tty_cursor(tty, 0, 0); } + /* Turn off margin. */ + void + tty_margin_off(struct tty *tty) + { + tty_margin(tty, 0, tty->sx - 1); + } + /* Set margin inside pane. */ static void tty_margin_pane(struct tty *tty, const struct tty_ctx *ctx) *************** *** 1299,1305 **** } /* Set margin at absolute position. */ ! void tty_margin(struct tty *tty, u_int rleft, u_int rright) { char s[64]; --- 1319,1325 ---- } /* Set margin at absolute position. */ ! static void tty_margin(struct tty *tty, u_int rleft, u_int rright) { char s[64];