termptyesc: support DECSED3 to erase the backlog. Closes T3713

This commit is contained in:
Boris Faure 2016-12-20 22:43:37 +01:00
parent e5f3676e32
commit 99f55b7bbc
3 changed files with 68 additions and 36 deletions

View File

@ -980,30 +980,56 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
termpty_write(ty, bf, strlen(bf)); termpty_write(ty, bf, strlen(bf));
} }
break; break;
case 'J': // "2j" erases the screen, 1j erase from screen start to curs, 0j erase cursor to end of screen case 'J':
DBG("2j erases the screen, 1j erase from screen start to curs, 0j erase cursor to end of screen"); if (*b == '?')
arg = _csi_arg_get(&b);
if (b)
{ {
if ((arg >= TERMPTY_CLR_END) && (arg <= TERMPTY_CLR_ALL)) b++;
termpty_clear_screen(ty, arg); arg = _csi_arg_get(&b);
else WRN("Unsupported selected erase in display %d", arg);
WRN("invalid clr scr %i", arg);
} }
else else
termpty_clear_screen(ty, TERMPTY_CLR_END); arg = _csi_arg_get(&b);
if (arg < 1) arg = 0;
/* 3J erases the backlog,
* 2J erases the screen,
* 1J erase from screen start to cursor,
* 0J erase form cursor to end of screen
*/
DBG("ED/DECSED %d: erase in display", arg);
switch (arg)
{
case TERMPTY_CLR_END:
case TERMPTY_CLR_BEGIN:
case TERMPTY_CLR_ALL:
termpty_clear_screen(ty, arg);
break;
case 3:
termpty_clear_backlog(ty);
break;
default:
ERR("invalid EL/DECSEL argument %d", arg);
}
break; break;
case 'K': // 0K erase to end of line, 1K erase from screen start to cursor, 2K erase all of line case 'K': // 0K erase to end of line, 1K erase from screen start to cursor, 2K erase all of line
arg = _csi_arg_get(&b); if (*b == '?')
DBG("0K erase to end of line, 1K erase from screen start to cursor, 2K erase all of line: %d", arg);
if (b)
{ {
if ((arg >= TERMPTY_CLR_END) && (arg <= TERMPTY_CLR_ALL)) b++;
termpty_clear_line(ty, arg, ty->w); arg = _csi_arg_get(&b);
else WRN("Unsupported selected erase in line %d", arg);
WRN("invalid clr lin %i", arg); }
arg = _csi_arg_get(&b);
if (arg < 1) arg = 0;
DBG("EL/DECSEL %d: erase in line", arg);
switch (arg)
{
case TERMPTY_CLR_END:
case TERMPTY_CLR_BEGIN:
case TERMPTY_CLR_ALL:
termpty_clear_line(ty, arg, ty->w);
break;
default:
ERR("invalid EL/DECSEL argument %d", arg);
} }
else termpty_clear_line(ty, TERMPTY_CLR_END, ty->w);
break; break;
case 'h': case 'h':
case 'l': case 'l':

View File

@ -275,6 +275,29 @@ termpty_clear_tabs_on_screen(Termpty *ty)
} }
} }
void
termpty_clear_backlog(Termpty *ty)
{
int backsize;
ty->backlog_beacon.screen_y = 0;
ty->backlog_beacon.backlog_y = 0;
termpty_backlog_lock();
if (ty->back)
{
size_t i;
for (i = 0; i < ty->backsize; i++)
termpty_save_free(&ty->back[i]);
free(ty->back);
ty->back = NULL;
}
ty->backpos = 0;
backsize = ty->backsize;
ty->backsize = 0;
termpty_backlog_size_set(ty, backsize);
termpty_backlog_unlock();
}
void void
termpty_clear_screen(Termpty *ty, Termpty_Clear mode) termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
@ -370,7 +393,6 @@ termpty_reset_att(Termatt *att)
void void
termpty_reset_state(Termpty *ty) termpty_reset_state(Termpty *ty)
{ {
int backsize;
int i; int i;
ty->cursor_state.cx = 0; ty->cursor_state.cx = 0;
@ -403,24 +425,7 @@ termpty_reset_state(Termpty *ty)
ty->mouse_ext = MOUSE_EXT_NONE; ty->mouse_ext = MOUSE_EXT_NONE;
ty->bracketed_paste = 0; ty->bracketed_paste = 0;
ty->backlog_beacon.screen_y = 0; termpty_clear_backlog(ty);
ty->backlog_beacon.backlog_y = 0;
termpty_backlog_lock();
if (ty->back)
{
size_t j;
for (j = 0; j < ty->backsize; j++)
termpty_save_free(&ty->back[j]);
free(ty->back);
ty->back = NULL;
}
ty->backpos = 0;
backsize = ty->backsize;
ty->backsize = 0;
termpty_backlog_size_set(ty, backsize);
termpty_backlog_unlock();
termpty_clear_tabs_on_screen(ty); termpty_clear_tabs_on_screen(ty);
for (i = 0; i < ty->w; i += TAB_WIDTH) for (i = 0; i < ty->w; i += TAB_WIDTH)
{ {

View File

@ -23,6 +23,7 @@ void termpty_reset_att(Termatt *att);
void termpty_reset_state(Termpty *ty); void termpty_reset_state(Termpty *ty);
void termpty_cursor_copy(Termpty *ty, Eina_Bool save); void termpty_cursor_copy(Termpty *ty, Eina_Bool save);
void termpty_clear_tabs_on_screen(Termpty *ty); void termpty_clear_tabs_on_screen(Termpty *ty);
void termpty_clear_backlog(Termpty *ty);
#define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1) #define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1)