aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termptyops.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2013-01-20 10:48:17 +0000
committerCedric BAIL <cedric.bail@free.fr>2013-01-20 10:48:17 +0000
commit548e12472eb4afc3cd6362a4cd5101fe8ce1483b (patch)
tree5de1ec664d9e533a4c50f6be1647665cd36f9951 /src/bin/termptyops.c
parentterminology: use a circular buffer for the screen. (diff)
downloadterminology-548e12472eb4afc3cd6362a4cd5101fe8ce1483b.tar.gz
terminology: revert previous commit at it is not ready yet for primetime.
SVN revision: 83013
Diffstat (limited to 'src/bin/termptyops.c')
-rw-r--r--src/bin/termptyops.c68
1 files changed, 26 insertions, 42 deletions
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index b9c88a3..c56fbdd 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -50,7 +50,7 @@ _text_save_top(Termpty *ty)
if (ty->backmax <= 0) return;
ts = malloc(sizeof(Termsave) + ((ty->w - 1) * sizeof(Termcell)));
ts->w = ty->w;
- _termpty_text_copy(ty, &(TERMPTY_SCREEN(ty, 0, 0)), ts->cell, ty->w);
+ _termpty_text_copy(ty, ty->screen, ts->cell, ty->w);
if (!ty->back) ty->back = calloc(1, sizeof(Termsave *) * ty->backmax);
if (ty->back[ty->backpos]) free(ty->back[ty->backpos]);
ty->back[ty->backpos] = ts;
@@ -69,8 +69,8 @@ _termpty_text_copy(Termpty *ty __UNUSED__, Termcell *cells, Termcell *dest, int
void
_termpty_text_scroll(Termpty *ty)
{
- Termcell /* *cells = NULL, */ *cells2;
- int start_y = 0, end_y = ty->h - 1;
+ Termcell *cells = NULL, *cells2;
+ int y, start_y = 0, end_y = ty->h - 1;
if (ty->state.scroll_y2 != 0)
{
@@ -89,20 +89,21 @@ _termpty_text_scroll(Termpty *ty)
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
}
DBG("... scroll!!!!! [%i->%i]", start_y, end_y);
- // screen is a circular buffer now
- ty->circular_offset++;
- if (ty->circular_offset >= ty->h)
- ty->circular_offset = 0;
-
- cells2 = &(TERMPTY_SCREEN(ty, 0, end_y));
+ cells2 = &(ty->screen[end_y * ty->w]);
+ for (y = start_y; y < end_y; y++)
+ {
+ cells = &(ty->screen[y * ty->w]);
+ cells2 = &(ty->screen[(y + 1) * ty->w]);
+ _termpty_text_copy(ty, cells2, cells, ty->w);
+ }
_text_clear(ty, cells2, ty->w, ' ', EINA_TRUE);
}
void
_termpty_text_scroll_rev(Termpty *ty)
{
- Termcell *cells/* , *cells2 = NULL */;
- int start_y = 0, end_y = ty->h - 1;
+ Termcell *cells, *cells2 = NULL;
+ int y, start_y = 0, end_y = ty->h - 1;
if (ty->state.scroll_y2 != 0)
{
@@ -110,12 +111,13 @@ _termpty_text_scroll_rev(Termpty *ty)
end_y = ty->state.scroll_y2 - 1;
}
DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y);
- // screen is a circular buffer now
- ty->circular_offset--;
- if (ty->circular_offset < 0)
- ty->circular_offset = ty->h - 1;
-
- cells = &(TERMPTY_SCREEN(ty, 0, end_y));
+ cells = &(ty->screen[end_y * ty->w]);
+ for (y = end_y; y > start_y; y--)
+ {
+ cells = &(ty->screen[(y - 1) * ty->w]);
+ cells2 = &(ty->screen[y * ty->w]);
+ _termpty_text_copy(ty, cells, cells2, ty->w);
+ }
_text_clear(ty, cells, ty->w, ' ', EINA_TRUE);
}
@@ -151,7 +153,7 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
Termcell *cells;
int i, j;
- cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy));
+ cells = &(ty->screen[ty->state.cy * ty->w]);
for (i = 0; i < len; i++)
{
Eina_Unicode g;
@@ -163,7 +165,7 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
ty->state.cx = 0;
ty->state.cy++;
_termpty_text_scroll_test(ty);
- cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy));
+ cells = &(ty->screen[ty->state.cy * ty->w]);
}
if (ty->state.insert)
{
@@ -233,7 +235,7 @@ _termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit)
Termcell *cells;
int n = 0;
- cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy));
+ cells = &(ty->screen[ty->state.cy * ty->w]);
switch (mode)
{
case TERMPTY_CLR_END:
@@ -258,42 +260,24 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
{
Termcell *cells;
- // FIXME: Handle clear with the new layout
- cells = &(TERMPTY_SCREEN(ty, 0, 0));
+ cells = ty->screen;
switch (mode)
{
case TERMPTY_CLR_END:
_termpty_clear_line(ty, mode, ty->w);
if (ty->state.cy < (ty->h - 1))
{
- cells = &(TERMPTY_SCREEN(ty, 0, (ty->state.cy + 1)));
+ cells = &(ty->screen[(ty->state.cy + 1) * ty->w]);
_text_clear(ty, cells, ty->w * (ty->h - ty->state.cy - 1), 0, EINA_TRUE);
}
break;
case TERMPTY_CLR_BEGIN:
if (ty->state.cy > 0)
- {
- // First clear from circular > height, then from 0 to circular
- int y = ty->state.cy + ty->circular_offset;
-
- if (y < ty->h)
- {
- _text_clear(ty, cells, ty->w * ty->state.cy, 0, EINA_TRUE);
- }
- else
- {
- int yt = y % ty->w;
- int yb = ty->h - ty->circular_offset;
-
- _text_clear(ty, cells, ty->w * yb, 0, EINA_TRUE);
- _text_clear(ty, ty->screen, ty->w * yt, 0, EINA_TRUE);
- }
- }
+ _text_clear(ty, cells, ty->w * ty->state.cy, 0, EINA_TRUE);
_termpty_clear_line(ty, mode, ty->w);
break;
case TERMPTY_CLR_ALL:
- ty->circular_offset = 0;
- _text_clear(ty, ty->screen, ty->w * ty->h, 0, EINA_TRUE);
+ _text_clear(ty, cells, ty->w * ty->h, 0, EINA_TRUE);
ty->state.scroll_y2 = 0;
break;
default: