diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-29 21:30:51 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-29 21:30:51 +0000 |
commit | 5b1a0601e6f53f31340c43392d7d686bc4a865dc (patch) | |
tree | 0533da0eb860b6255dbed47ae5c55e6c3db64c38 | |
parent | da24eaf0186f5a621288ff3249188207046bd4e0 (diff) |
Fix two errors with character/line insertion and deletion: the maximum number
of characters which may be inserted or deleted is the screen width, not one
less (and similarly for lines and height); and if characters or lines are
deleted by moving the ones that follow, the space at the end needs to be
cleared.
This appears to solve long-standing redraw issues most visible when using the
force-width option then scrolling in view(1) or unwrapping lines in emacs.
-rw-r--r-- | usr.bin/tmux/grid-view.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 18 |
2 files changed, 14 insertions, 12 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c index 8154495b544..8e6c1dc0354 100644 --- a/usr.bin/tmux/grid-view.c +++ b/usr.bin/tmux/grid-view.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid-view.c,v 1.2 2009/06/24 22:04:18 nicm Exp $ */ +/* $OpenBSD: grid-view.c,v 1.3 2009/06/29 21:30:50 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -158,6 +158,7 @@ grid_view_delete_lines(struct grid *gd, u_int py, u_int ny) sy = grid_view_y(gd, gd->sy); grid_move_lines(gd, py, py + ny, sy - py - ny); + grid_clear(gd, 0, sy - ny, gd->sx, py + ny - (sy - ny)); } /* Delete lines inside scroll region. */ @@ -191,7 +192,7 @@ grid_view_insert_cells(struct grid *gd, u_int px, u_int py, u_int nx) if (px == sx - 1) grid_clear(gd, px, py, 1, 1); else - grid_move_cells(gd, px + nx, px, py, (sx - 1) - (px + nx)); + grid_move_cells(gd, px + nx, px, py, sx - px - nx); } /* Delete characters. */ @@ -207,7 +208,8 @@ grid_view_delete_cells(struct grid *gd, u_int px, u_int py, u_int nx) sx = grid_view_x(gd, gd->sx); - grid_move_cells(gd, px, px + nx, py, (sx - 1) - (px + nx)); + grid_move_cells(gd, px, px + nx, py, sx - px - nx); + grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1); } /* Convert cells into a string. */ diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index ea3c2473f1b..ad37cb099a8 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.8 2009/06/26 15:13:39 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.9 2009/06/29 21:30:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -325,8 +325,8 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx) if (nx == 0) nx = 1; - if (nx > screen_size_x(s) - 1 - s->cx) - nx = screen_size_x(s) - 1 - s->cx; + if (nx > screen_size_x(s) - s->cx) + nx = screen_size_x(s) - s->cx; if (nx == 0) return; @@ -347,8 +347,8 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx) if (nx == 0) nx = 1; - if (nx > screen_size_x(s) - 1 - s->cx) - nx = screen_size_x(s) - 1 - s->cx; + if (nx > screen_size_x(s) - s->cx) + nx = screen_size_x(s) - s->cx; if (nx == 0) return; @@ -369,8 +369,8 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) if (ny == 0) ny = 1; - if (ny > screen_size_y(s) - 1 - s->cy) - ny = screen_size_y(s) - 1 - s->cy; + if (ny > screen_size_y(s) - s->cy) + ny = screen_size_y(s) - s->cy; if (ny == 0) return; @@ -395,8 +395,8 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny) if (ny == 0) ny = 1; - if (ny > screen_size_y(s) - 1 - s->cy) - ny = screen_size_y(s) - 1 - s->cy; + if (ny > screen_size_y(s) - s->cy) + ny = screen_size_y(s) - s->cy; if (ny == 0) return; |