summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/grid.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-09-02 20:57:20 +0000
committernicm <nicm@openbsd.org>2016-09-02 20:57:20 +0000
commit93ccd604c0f86dc80a6b0a1f527908e639d95e7f (patch)
treeaf2ca8175535d53869f9bf4fc65394ae54d89809 /usr.bin/tmux/grid.c
parentclarify that -L will exit without running a command. (diff)
downloadwireguard-openbsd-93ccd604c0f86dc80a6b0a1f527908e639d95e7f.tar.xz
wireguard-openbsd-93ccd604c0f86dc80a6b0a1f527908e639d95e7f.zip
Remember the number of lines scrolled into the history (versus cleared
into the history) and when resizing only use scrolled lines and not cleared lines (which are probably not intended to reappear). From Chaoren Lin.
Diffstat (limited to 'usr.bin/tmux/grid.c')
-rw-r--r--usr.bin/tmux/grid.c13
1 files changed, 12 insertions, 1 deletions
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);