summaryrefslogtreecommitdiffstats
path: root/screen.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2013-02-05 11:08:59 +0000
committerNicholas Marriott <nicm@openbsd.org>2013-02-05 11:08:59 +0000
commit8903c1f167839569b7514508b38988aa6486575c (patch)
tree8f57ca70d42fa94d4bbef04341b6ecac62f1b7f9 /screen.c
parenta5521597b0e0771d5ad698bba92801ea88302c4f (diff)
Automatically reflow wrapped lines when a pane is resized, requested by
many over the years and finally implemented by Richard Woodbury.
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/screen.c b/screen.c
index 7ffe2a24..1c0c0d36 100644
--- a/screen.c
+++ b/screen.c
@@ -120,7 +120,7 @@ screen_set_title(struct screen *s, const char *title)
/* Resize screen. */
void
-screen_resize(struct screen *s, u_int sx, u_int sy)
+screen_resize(struct screen *s, u_int sx, u_int sy, int reflow)
{
if (sx < 1)
sx = 1;
@@ -140,6 +140,9 @@ screen_resize(struct screen *s, u_int sx, u_int sy)
if (sy != screen_size_y(s))
screen_resize_y(s, sy);
+
+ if (reflow)
+ screen_reflow(s, sx);
}
void
@@ -356,3 +359,18 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
return (1);
}
+
+/* Reflow wrapped lines. */
+void
+screen_reflow(struct screen *s, u_int sx)
+{
+ struct grid *old, *new;
+
+ old = s->grid;
+ new = grid_create(old->sx, old->sy, old->hlimit);
+
+ s->cy -= grid_reflow(new, old, sx);
+ s->grid = new;
+
+ grid_destroy(old);
+}