billiob pushed a commit to branch master.

commit 274e2b13b215f79703bbe51662f46478460bbe2f
Author: Boris Faure <[email protected]>
Date:   Fri Apr 12 18:35:56 2013 +0200

    reflow: fix vertical shrinking
---
 src/bin/termpty.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index c2f92d8..cd5eb17 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -810,27 +810,41 @@ _termpty_vertically_shrink(Termpty *ty, int old_w, int 
old_h,
    else
      {
         /* in place */
+        int len, pos, offset;
+
         if (to_history <= 0)
           return;
-        old_circular_offset = (old_circular_offset + to_history) % old_h;
-        ty->circular_offset = old_circular_offset;
+
         if (ty->circular_offset == 0)
           return;
 
+        ty->circular_offset = (ty->circular_offset + to_history) % old_h;
+        len = real_h - to_history;
+        pos = (len + ty->circular_offset) % old_h;
+        offset = len - pos;
+
         /* 2 times */
-        for (y = ty->circular_offset - 1; y > 0; y--)
+        for (y = pos - 1; y >= 0; y--)
           {
              src = &(old_screen[y * old_w]);
-             dst = &(OLD_SCREEN(0, y));
+             dst = &(old_screen[(y + offset) * old_w]);
              termpty_cell_copy(ty, src, dst, old_w);
           }
-        for (y = 0; y < ty->circular_offset; y++)
+        for (y = 0; y < offset; y++)
           {
-             src = &(OLD_SCREEN(0, y));
+             src = &(old_screen[(ty->circular_offset + y) * old_w]);
              dst = &(old_screen[y * old_w]);
              termpty_cell_copy(ty, src, dst, old_w);
           }
         ty->circular_offset = 0;
+
+        len = ty->h - len;
+        if (len)
+          {
+             memset(&old_screen[(old_h - len) * old_w],
+                    0,
+                    sizeof(Termcell) * len * old_w);
+          }
      }
 }
 

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to