compat: only clear cells when scrolling to add text

and to delete lines, but not when just moving the cursor
This commit is contained in:
Boris Faure 2013-04-18 23:12:15 +02:00
parent 13a11e5a92
commit cff21ea5b8
3 changed files with 30 additions and 24 deletions

View File

@ -309,7 +309,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
for (i = 0; i < arg; i++)
{
ty->state.cy--;
_termpty_text_scroll_rev_test(ty);
_termpty_text_scroll_rev_test(ty, EINA_FALSE);
}
break;
case 'B': // cursor down N
@ -319,7 +319,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
for (i = 0; i < arg; i++)
{
ty->state.cy++;
_termpty_text_scroll_test(ty);
_termpty_text_scroll_test(ty, EINA_FALSE);
}
break;
case 'D': // cursor left N
@ -413,12 +413,12 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
case 'S': // scroll up N lines
arg = _csi_arg_get(&b);
if (arg < 1) arg = 1;
for (i = 0; i < arg; i++) _termpty_text_scroll(ty);
for (i = 0; i < arg; i++) _termpty_text_scroll(ty, EINA_FALSE);
break;
case 'T': // scroll down N lines
arg = _csi_arg_get(&b);
if (arg < 1) arg = 1;
for (i = 0; i < arg; i++) _termpty_text_scroll_rev(ty);
for (i = 0; i < arg; i++) _termpty_text_scroll_rev(ty, EINA_FALSE);
break;
case 'M': // delete N lines - cy
case 'L': // insert N lines - cy
@ -442,8 +442,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (arg < 1) arg = 1;
for (i = 0; i < arg; i++)
{
if (*cc == 'M') _termpty_text_scroll(ty);
else _termpty_text_scroll_rev(ty);
if (*cc == 'M') _termpty_text_scroll(ty, EINA_TRUE);
else _termpty_text_scroll_rev(ty, EINA_TRUE);
}
ty->state.scroll_y1 = sy1;
ty->state.scroll_y2 = sy2;
@ -1136,18 +1136,18 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
case 'M': // move to prev line
ty->state.wrapnext = 0;
ty->state.cy--;
_termpty_text_scroll_rev_test(ty);
_termpty_text_scroll_rev_test(ty, EINA_FALSE);
return 1;
case 'D': // move to next line
ty->state.wrapnext = 0;
ty->state.cy++;
_termpty_text_scroll_test(ty);
_termpty_text_scroll_test(ty, EINA_FALSE);
return 1;
case 'E': // add \n\r
ty->state.wrapnext = 0;
ty->state.cx = 0;
ty->state.cy++;
_termpty_text_scroll_test(ty);
_termpty_text_scroll_test(ty, EINA_FALSE);
return 1;
case 'Z': // same a 'ESC [ Pn c'
_term_txt_write(ty, "\033[?1;2C");
@ -1310,7 +1310,7 @@ _termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
ty->state.wrapnext = 0;
if (ty->state.crlf) ty->state.cx = 0;
ty->state.cy++;
_termpty_text_scroll_test(ty);
_termpty_text_scroll_test(ty, EINA_TRUE);
ty->state.had_cr = 0;
return 1;
case 0x0d: // CR '\r' (carriage ret)

View File

@ -55,7 +55,7 @@ termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max)
}
void
_termpty_text_scroll(Termpty *ty)
_termpty_text_scroll(Termpty *ty, Eina_Bool clear)
{
Termcell *cells = NULL, *cells2;
int y, start_y = 0, end_y = ty->h - 1;
@ -78,6 +78,9 @@ _termpty_text_scroll(Termpty *ty)
}
DBG("... scroll!!!!! [%i->%i]", start_y, end_y);
if (!clear)
return;
if (start_y == 0 && end_y == ty->h - 1)
{
// screen is a circular buffer now
@ -86,7 +89,7 @@ _termpty_text_scroll(Termpty *ty)
ty->circular_offset++;
if (ty->circular_offset >= ty->h)
ty->circular_offset = 0;
ty->circular_offset = 0;
}
else
{
@ -102,7 +105,7 @@ _termpty_text_scroll(Termpty *ty)
}
void
_termpty_text_scroll_rev(Termpty *ty)
_termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
{
Termcell *cells, *cells2 = NULL;
int y, start_y = 0, end_y = ty->h - 1;
@ -114,12 +117,15 @@ _termpty_text_scroll_rev(Termpty *ty)
}
DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y);
if (!clear)
return;
if (start_y == 0 && end_y == ty->h - 1)
{
// screen is a circular buffer now
ty->circular_offset--;
if (ty->circular_offset < 0)
ty->circular_offset = ty->h - 1;
ty->circular_offset = ty->h - 1;
cells = &(ty->screen[ty->circular_offset * ty->w]);
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
@ -139,27 +145,27 @@ _termpty_text_scroll_rev(Termpty *ty)
}
void
_termpty_text_scroll_test(Termpty *ty)
_termpty_text_scroll_test(Termpty *ty, Eina_Bool clear)
{
int e = ty->h;
if (ty->state.scroll_y2 != 0) e = ty->state.scroll_y2;
if (ty->state.cy >= e)
{
_termpty_text_scroll(ty);
_termpty_text_scroll(ty, clear);
ty->state.cy = e - 1;
}
}
void
_termpty_text_scroll_rev_test(Termpty *ty)
_termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear)
{
int b = 0;
if (ty->state.scroll_y2 != 0) b = ty->state.scroll_y1;
if (ty->state.scroll_y1 != 0) b = ty->state.scroll_y1;
if (ty->state.cy < b)
{
_termpty_text_scroll_rev(ty);
_termpty_text_scroll_rev(ty, clear);
ty->state.cy = b;
}
}
@ -181,7 +187,7 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
ty->state.wrapnext = 0;
ty->state.cx = 0;
ty->state.cy++;
_termpty_text_scroll_test(ty);
_termpty_text_scroll_test(ty, EINA_TRUE);
cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy));
}
if (ty->state.insert)

View File

@ -7,10 +7,10 @@ typedef enum _Termpty_Clear
void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max);
void _termpty_text_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count);
void _termpty_text_scroll(Termpty *ty);
void _termpty_text_scroll_rev(Termpty *ty);
void _termpty_text_scroll_test(Termpty *ty);
void _termpty_text_scroll_rev_test(Termpty *ty);
void _termpty_text_scroll(Termpty *ty, Eina_Bool clear);
void _termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear);
void _termpty_text_scroll_test(Termpty *ty, Eina_Bool clear);
void _termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear);
void _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len);
void _termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit);
void _termpty_clear_screen(Termpty *ty, Termpty_Clear mode);