=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.143 retrieving revision 1.144 diff -u -r1.143 -r1.144 --- src/usr.bin/tmux/screen-write.c 2018/11/13 11:36:37 1.143 +++ src/usr.bin/tmux/screen-write.c 2019/03/12 07:39:27 1.144 @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.143 2018/11/13 11:36:37 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.144 2019/03/12 07:39:27 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -74,10 +74,16 @@ if (cx != -1 && (u_int)cx == s->cx && cy != -1 && (u_int)cy == s->cy) return; - if (cx != -1) + if (cx != -1) { + if ((u_int)cx > screen_size_x(s) - 1) + cx = screen_size_x(s) - 1; s->cx = cx; - if (cy != -1) + } + if (cy != -1) { + if ((u_int)cy > screen_size_y(s) - 1) + cy = screen_size_y(s) - 1; s->cy = cy; + } if (wp == NULL) return; @@ -147,7 +153,7 @@ s->mode = MODE_CURSOR | MODE_WRAP; screen_write_clearscreen(ctx, 8); - screen_write_cursormove(ctx, 0, 0); + screen_write_set_cursor(ctx, 0, 0); } /* Write character. */ @@ -419,7 +425,7 @@ screen_write_cell(ctx, &gc); } cy++; - screen_write_cursormove(ctx, cx, cy); + screen_write_set_cursor(ctx, cx, cy); } } @@ -477,7 +483,7 @@ screen_write_putc(ctx, &gc, 'q'); screen_write_putc(ctx, &gc, right ? 'u' : 'q'); - screen_write_cursormove(ctx, cx, cy); + screen_write_set_cursor(ctx, cx, cy); } /* Draw a horizontal line on screen. */ @@ -496,13 +502,13 @@ screen_write_putc(ctx, &gc, top ? 'w' : 'x'); for (i = 1; i < ny - 1; i++) { - screen_write_cursormove(ctx, cx, cy + i); + screen_write_set_cursor(ctx, cx, cy + i); screen_write_putc(ctx, &gc, 'x'); } - screen_write_cursormove(ctx, cx, cy + ny - 1); + screen_write_set_cursor(ctx, cx, cy + ny - 1); screen_write_putc(ctx, &gc, bottom ? 'v' : 'x'); - screen_write_cursormove(ctx, cx, cy); + screen_write_set_cursor(ctx, cx, cy); } /* Draw a box on screen. */ @@ -524,22 +530,22 @@ screen_write_putc(ctx, &gc, 'q'); screen_write_putc(ctx, &gc, 'k'); - screen_write_cursormove(ctx, cx, cy + ny - 1); + screen_write_set_cursor(ctx, cx, cy + ny - 1); screen_write_putc(ctx, &gc, 'm'); for (i = 1; i < nx - 1; i++) screen_write_putc(ctx, &gc, 'q'); screen_write_putc(ctx, &gc, 'j'); for (i = 1; i < ny - 1; i++) { - screen_write_cursormove(ctx, cx, cy + i); + screen_write_set_cursor(ctx, cx, cy + i); screen_write_putc(ctx, &gc, 'x'); } for (i = 1; i < ny - 1; i++) { - screen_write_cursormove(ctx, cx + nx - 1, cy + i); + screen_write_set_cursor(ctx, cx + nx - 1, cy + i); screen_write_putc(ctx, &gc, 'x'); } - screen_write_cursormove(ctx, cx, cy); + screen_write_set_cursor(ctx, cx, cy); } /* @@ -594,7 +600,7 @@ if (src->mode & MODE_CURSOR) { grid_view_get_cell(src->grid, src->cx, src->cy, &gc); gc.attr |= GRID_ATTR_REVERSE; - screen_write_cursormove(ctx, cx + (src->cx - px), + screen_write_set_cursor(ctx, cx + (src->cx - px), cy + (src->cy - py)); screen_write_cell(ctx, &gc); } @@ -1032,10 +1038,12 @@ { struct screen *s = ctx->s; - if (px > screen_size_x(s) - 1) - px = screen_size_x(s) - 1; - if (py > screen_size_y(s) - 1) - py = screen_size_y(s) - 1; + if (s->mode & MODE_ORIGIN) { + if (py > s->rlower - s->rupper) + py = s->rlower; + else + py += s->rupper; + } screen_write_set_cursor(ctx, px, py); } @@ -1296,7 +1304,7 @@ cx = s->cx; cy = s->cy; for (y = 0; y < screen_size_y(s); y++) { TAILQ_FOREACH_SAFE(ci, &ctx->list[y].items, entry, tmp) { - screen_write_cursormove(ctx, ci->x, y); + screen_write_set_cursor(ctx, ci->x, y); screen_write_initctx(ctx, &ttyctx); ttyctx.cell = &ci->gc; ttyctx.wrapped = ci->wrapped; @@ -1441,7 +1449,7 @@ screen_write_collect_flush(ctx, 0); if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) { cx = s->cx; cy = s->cy; - screen_write_cursormove(ctx, xx, s->cy); + screen_write_set_cursor(ctx, xx, s->cy); screen_write_initctx(ctx, &ttyctx); ttyctx.cell = gc; tty_write(tty_cmd_cell, &ttyctx);