billiob pushed a commit to branch master.

commit 55d2d0e48347808394ac447411c6d210508c005b
Author: Boris Faure <[email protected]>
Date:   Sat Mar 23 14:43:20 2013 +0100

    reflow: dummy vertical shrink
---
 src/bin/termpty.c | 41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index f36b7d3..3c869a7 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -743,23 +743,46 @@ static void
 _termpty_vertically_shrink(Termpty *ty, int old_w, int old_h,
                            Termcell *old_screen)
 {
-   /* TODO */
-   int hh, y;
+   int to_history = old_h - ty->h,
+       circular_offset,
+       w,
+       h,
+       y;
+   Termcell *screen;
 
-   hh = ty->h;
+   if (old_screen)
+     {
+        screen = old_screen;
+        w = old_w;
+        h = old_h;
+        circular_offset = ty->circular_offset;
+     }
+   else
+     {
+        screen = ty->screen;
+        w = ty->w;
+        h = ty->h;
+        circular_offset = 0;
+     }
 
-   if (!old_screen) return;
+#define _SCREEN(_X, _Y) \
+        screen[_X + (((_Y + circular_offset) % h) * w)]
 
-   // FIXME: handle pointer copy here
-   for (y = 0; y < hh; y++)
+   for (y = 0; y < to_history; y++)
+     {
+        termpty_text_save_top(ty, &(_SCREEN(0, y)), w);
+     }
+
+   for (y = 0; y < ty->h; y++)
      {
         Termcell *c1, *c2;
 
-        c1 = &(old_screen[y * ty->w]);
+        c1 = &(_SCREEN(0, y + to_history));
         c2 = &(TERMPTY_SCREEN(ty, 0, y));
-        _termpty_text_copy(ty, c1, c2, ty->w);
-        termpty_cell_fill(ty, NULL, c1, ty->w);
+        _termpty_text_copy(ty, c1, c2, old_w);
      }
+
+#undef _SCREEN
 }
 
 

-- 

------------------------------------------------------------------------------
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