billiob pushed a commit to branch master.
commit 18c8aff57c73ebea11e97d40ac4dbb93b905b968
Author: Boris Faure <[email protected]>
Date: Wed Mar 20 22:04:59 2013 +0100
reflow: add vertically expansion support
---
src/bin/termpty.c | 68 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 37 insertions(+), 31 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index f019ad1..be4a379 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -703,62 +703,61 @@ expand_screen:
}
static void
-_termpty_vertically_expand(Termpty *ty, int oldh,
- Termcell *oldscreen, Termcell *oldscreen2)
+_termpty_vertically_expand(Termpty *ty, int old_w, int old_h,
+ Termcell *old_screen)
{
- /* TODO */
- int hh, y;
+ if (old_screen)
+ {
+ int y,
+ old_circular_offset = ty->circular_offset;
- hh = oldh;
+ ty->circular_offset = 0;
- // FIXME: handle pointer copy here
- for (y = 0; y < hh; y++)
- {
- Termcell *c1, *c2;
+#define OLD_SCREEN(_X, _Y) \
+ old_screen[_X + (((_Y + old_circular_offset) % old_h) * old_w)]
- c1 = &(oldscreen[y * ty->w]);
- c2 = &(TERMPTY_SCREEN(ty, 0, y));
- _termpty_text_copy(ty, c1, c2, ty->w);
- termpty_cell_fill(ty, NULL, c1, ty->w);
+ for (y = 0; y < old_h; y++)
+ {
+ Termcell *c1, *c2;
- c1 = &(oldscreen2[y * ty->w]);
- c2 = &(ty->screen2[y * ty->w]);
- _termpty_text_copy(ty, c1, c2, ty->w);
- termpty_cell_fill(ty, NULL, c1, ty->w);
+ c1 = &(OLD_SCREEN(0, y));
+ c2 = &(TERMPTY_SCREEN(ty, 0, y));
+ _termpty_text_copy(ty, c1, c2, old_w);
+ }
+#undef OLD_SCREEN
}
+
+ /* TODO: display content from backlog */
}
static void
-_termpty_vertically_shrink(Termpty *ty, int oldh,
- Termcell *oldscreen, Termcell *oldscreen2)
+_termpty_vertically_shrink(Termpty *ty, int old_w, int old_h,
+ Termcell *old_screen)
{
/* TODO */
int hh, y;
hh = ty->h;
+ if (!old_screen) return;
+
// FIXME: handle pointer copy here
for (y = 0; y < hh; y++)
{
Termcell *c1, *c2;
- c1 = &(oldscreen[y * ty->w]);
+ c1 = &(old_screen[y * ty->w]);
c2 = &(TERMPTY_SCREEN(ty, 0, y));
_termpty_text_copy(ty, c1, c2, ty->w);
termpty_cell_fill(ty, NULL, c1, ty->w);
-
- c1 = &(oldscreen2[y * ty->w]);
- c2 = &(ty->screen2[y * ty->w]);
- _termpty_text_copy(ty, c1, c2, ty->w);
- termpty_cell_fill(ty, NULL, c1, ty->w);
}
}
static void
-_termpty_horizontally_shrink(Termpty *ty, int oldw, int oldh,
- Termcell *oldscreen, Termcell *oldscreen2)
+_termpty_horizontally_shrink(Termpty *ty, int old_w, int old_h,
+ Termcell *old_screen)
{
/* TODO */
}
@@ -801,18 +800,25 @@ termpty_resize(Termpty *ty, int w, int h)
if (ty->w > oldw)
_termpty_horizontally_expand(ty, oldw, oldh, olds);
else
- _termpty_horizontally_shrink(ty, oldw, oldh, olds, olds2);
+ _termpty_horizontally_shrink(ty, oldw, oldh, olds);
+
+ free(olds); olds = NULL;
+ free(olds2); olds2 = NULL;
+ ty->circular_offset = 0;
+ }
+ else
+ {
+
}
if (oldh != ty->h)
{
if (ty->h > oldh)
- _termpty_vertically_expand(ty, oldh, olds, olds2);
+ _termpty_vertically_expand(ty, oldw, oldh, olds);
else
- _termpty_vertically_shrink(ty, oldh, olds, olds2);
+ _termpty_vertically_shrink(ty, oldw, oldh, olds);
}
- ty->circular_offset = 0;
free(olds);
free(olds2);
--
------------------------------------------------------------------------------
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