diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/grid-view.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/grid.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/screen.c | 17 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
5 files changed, 28 insertions, 12 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c index adb20b93e1b..95041712ff7 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.24 2016/01/19 15:59:12 nicm Exp $ */ +/* $OpenBSD: grid-view.c,v 1.25 2016/09/02 20:57:20 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -67,6 +67,7 @@ grid_view_clear_history(struct grid *gd) grid_collect_history(gd); grid_scroll_history(gd); } + gd->hscrolled = 0; } /* Clear area. */ diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 9fce513f98c..364eaba687b 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.54 2016/07/15 00:49:08 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.55 2016/09/02 20:57:20 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -99,6 +99,7 @@ grid_create(u_int sx, u_int sy, u_int hlimit) gd->flags = GRID_HISTORY; + gd->hscrolled = 0; gd->hsize = 0; gd->hlimit = hlimit; @@ -170,6 +171,8 @@ grid_collect_history(struct grid *gd) grid_move_lines(gd, 0, yy, gd->hsize + gd->sy - yy); gd->hsize -= yy; + if (gd->hscrolled > gd->hsize) + gd->hscrolled = gd->hsize; } /* @@ -186,6 +189,7 @@ grid_scroll_history(struct grid *gd) sizeof *gd->linedata); memset(&gd->linedata[yy], 0, sizeof gd->linedata[yy]); + gd->hscrolled++; gd->hsize++; } @@ -196,7 +200,9 @@ grid_clear_history(struct grid *gd) grid_clear_lines(gd, 0, gd->hsize); grid_move_lines(gd, 0, gd->hsize, gd->sy); + gd->hscrolled = 0; gd->hsize = 0; + gd->linedata = xreallocarray(gd->linedata, gd->sy, sizeof *gd->linedata); } @@ -231,6 +237,7 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower) memset(gl_lower, 0, sizeof *gl_lower); /* Move the history offset down over the line. */ + gd->hscrolled++; gd->hsize++; } @@ -914,6 +921,10 @@ grid_reflow(struct grid *dst, struct grid *src, u_int new_x) grid_reflow_join(dst, &py, src_gl, new_x); } previous_wrapped = (src_gl->flags & GRID_LINE_WRAPPED); + + /* This is where we started scrolling. */ + if (line == sy + src->hsize - src->hscrolled - 1) + dst->hscrolled = 0; } grid_destroy(src); diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index fac63708c56..40ce80c7de3 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.92 2016/07/15 00:49:08 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.93 2016/09/02 20:57:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1016,7 +1016,7 @@ screen_write_clearhistory(struct screen_write_ctx *ctx) struct grid *gd = s->grid; grid_move_lines(gd, 0, gd->hsize, gd->sy); - gd->hsize = 0; + gd->hscrolled = gd->hsize = 0; } /* Write cell data. */ diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c index 2ede81792f8..429aeaa8476 100644 --- a/usr.bin/tmux/screen.c +++ b/usr.bin/tmux/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.39 2016/07/15 00:49:08 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.40 2016/09/02 20:57:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -177,8 +177,9 @@ screen_resize_y(struct screen *s, u_int sy) * If the height is decreasing, delete lines from the bottom until * hitting the cursor, then push lines from the top into the history. * - * When increasing, pull as many lines as possible from the history to - * the top, then fill the remaining with blanks at the bottom. + * When increasing, pull as many lines as possible from scrolled + * history (not explicitly cleared from view) to the top, then fill the + * remaining with blanks at the bottom. */ /* Size decreasing. */ @@ -200,9 +201,10 @@ screen_resize_y(struct screen *s, u_int sy) * lines from the top. */ available = s->cy; - if (gd->flags & GRID_HISTORY) + if (gd->flags & GRID_HISTORY) { + gd->hscrolled += needed; gd->hsize += needed; - else if (needed > 0 && available > 0) { + } else if (needed > 0 && available > 0) { if (available > needed) available = needed; grid_view_delete_lines(gd, 0, available); @@ -219,13 +221,14 @@ screen_resize_y(struct screen *s, u_int sy) needed = sy - oldy; /* - * Try to pull as much as possible out of the history, if is + * Try to pull as much as possible out of scrolled history, if is * is enabled. */ - available = gd->hsize; + available = gd->hscrolled; if (gd->flags & GRID_HISTORY && available > 0) { if (available > needed) available = needed; + gd->hscrolled -= available; gd->hsize -= available; s->cy += available; } else diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 335fb7d4dfa..8fc21251735 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.641 2016/08/03 09:07:02 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.642 2016/09/02 20:57:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -691,6 +691,7 @@ struct grid { u_int sx; u_int sy; + u_int hscrolled; u_int hsize; u_int hlimit; |