diff options
author | nicm <nicm> | 2017-03-15 09:21:21 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-03-15 09:21:21 +0000 |
commit | 3c3c08b6d9704b00a12e14772b95f7a40c20b10e (patch) | |
tree | 1dfef2e7baf9623f9e629baad862444c9c2c80ff /tty.c | |
parent | 8e9b10062b56b29d4834798d4264825ca1b3a8dd (diff) | |
download | rtmux-3c3c08b6d9704b00a12e14772b95f7a40c20b10e.tar.gz rtmux-3c3c08b6d9704b00a12e14772b95f7a40c20b10e.tar.bz2 rtmux-3c3c08b6d9704b00a12e14772b95f7a40c20b10e.zip |
Try to avoid moving the cursor to the start of the next line when
printing cells if it is already at the very end of the line and the
terminal will wrap it to the next line itself, this means terminals
still see it as a wrapped line for the purposes of their own mouse
selection. Reported by millert@.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -41,6 +41,8 @@ static int tty_try_colour(struct tty *, int, const char *); static void tty_force_cursor_colour(struct tty *, const char *); static void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int); +static void tty_cursor_pane_unless_wrap(struct tty *, + const struct tty_ctx *, u_int, u_int); static void tty_invalidate(struct tty *); static void tty_colours(struct tty *, const struct grid_cell *); static void tty_check_fg(struct tty *, const struct window_pane *, @@ -1188,7 +1190,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) tty_margin_off(tty); } - tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); + tty_cursor_pane_unless_wrap(tty, ctx, ctx->ocx, ctx->ocy); tty_cell(tty, ctx->cell, ctx->wp); } @@ -1196,7 +1198,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) void tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx) { - tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); + tty_cursor_pane_unless_wrap(tty, ctx, ctx->ocx, ctx->ocy); tty_attributes(tty, ctx->cell, ctx->wp); tty_putn(tty, ctx->ptr, ctx->num, ctx->num); @@ -1389,6 +1391,24 @@ tty_margin(struct tty *tty, u_int rleft, u_int rright) tty->cx = tty->cy = UINT_MAX; } +/* + * Move the cursor, unless it would wrap itself when the next character is + * printed. + */ +static void +tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx, + u_int cx, u_int cy) +{ + if (!tty_pane_full_width(tty, ctx) || + (tty->term->flags & TERM_EARLYWRAP) || + ctx->xoff + cx != 0 || + ctx->yoff + cy != tty->cy + 1 || + tty->cx < tty->sx) + tty_cursor_pane(tty, ctx, cx, cy); + else + log_debug("%s: will wrap at %u,%u", __func__, tty->cx, tty->cy); +} + /* Move cursor inside pane. */ static void tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy) |