diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-09 07:58:15 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-09 07:58:15 +0000 |
commit | f611886813b25f4fc192f65a291468dbadfa05de (patch) | |
tree | a4c5bb70a56d17e374cc2e93264f7138d4088a59 /usr.bin | |
parent | 7102133cd17130c7a4ab4135de6eaf688869f918 (diff) |
Change inserting and deleting lines inside the scroll region to properly clear
lines that should be inserted/deleted but not moved. Fixes problems with mutt
reported by Brian Lewis, thanks.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/grid-view.c | 16 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 40 |
2 files changed, 46 insertions, 10 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c index 4475c9bffd9..76017828c50 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.4 2009/07/09 00:29:32 nicm Exp $ */ +/* $OpenBSD: grid-view.c,v 1.5 2009/07/09 07:58:14 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -134,13 +134,17 @@ grid_view_insert_lines(struct grid *gd, u_int py, u_int ny) void grid_view_insert_lines_region(struct grid *gd, u_int rlower, u_int py, u_int ny) { + u_int ny2; + GRID_DEBUG(gd, "rlower=%u, py=%u, ny=%u", rlower, py, ny); rlower = grid_view_y(gd, rlower); py = grid_view_y(gd, py); - grid_move_lines(gd, py + ny, py, (rlower + 1) - py - ny); + ny2 = rlower + 1 - py - ny; + grid_move_lines(gd, rlower + 1 - ny2, py, ny2); + grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2); } /* Delete lines. */ @@ -156,20 +160,24 @@ 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)); + grid_clear(gd, 0, sy - ny, gd->sx, py + ny - (sy - ny)); } /* Delete lines inside scroll region. */ void grid_view_delete_lines_region(struct grid *gd, u_int rlower, u_int py, u_int ny) { + u_int ny2; + GRID_DEBUG(gd, "rlower=%u, py=%u, ny=%u", rlower, py, ny); rlower = grid_view_y(gd, rlower); py = grid_view_y(gd, py); - grid_move_lines(gd, py, py + ny, (rlower + 1) - py - ny); + ny2 = rlower + 1 - py - ny; + grid_move_lines(gd, py, py + ny, ny2); + grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2); } /* Insert characters. */ diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 6796e422f7d..3ea24263f17 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.10 2009/07/09 00:29:32 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.11 2009/07/09 07:58:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -369,11 +369,25 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) if (ny == 0) ny = 1; - if (ny > screen_size_y(s) - s->cy) - ny = screen_size_y(s) - s->cy; - if (ny == 0) + if (s->cy < s->rupper || s->cy > s->rlower) { + if (ny > screen_size_y(s) - s->cy) + ny = screen_size_y(s) - s->cy; + if (ny == 0) + return; + + screen_write_save(ctx); + + grid_view_insert_lines(s->grid, s->cy, ny); + + tty_write_cmd(ctx->wp, TTY_INSERTLINE, ny); return; + } + if (ny > s->rlower + 1 - s->cy) + ny = s->rlower + 1 - s->cy; + if (ny == 0) + return; + screen_write_save(ctx); if (s->cy < s->rupper || s->cy > s->rlower) @@ -393,8 +407,22 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny) if (ny == 0) ny = 1; - if (ny > screen_size_y(s) - s->cy) - ny = screen_size_y(s) - s->cy; + if (s->cy < s->rupper || s->cy > s->rlower) { + if (ny > screen_size_y(s) - s->cy) + ny = screen_size_y(s) - s->cy; + if (ny == 0) + return; + + screen_write_save(ctx); + + grid_view_delete_lines(s->grid, s->cy, ny); + + tty_write_cmd(ctx->wp, TTY_DELETELINE, ny); + return; + } + + if (ny > s->rlower + 1 - s->cy) + ny = s->rlower + 1 - s->cy; if (ny == 0) return; |