aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2016-12-20 22:43:37 +0100
committerBoris Faure <billiob@gmail.com>2016-12-20 22:43:37 +0100
commit99f55b7bbc4d375d3b4525e449001dad6e536cdd (patch)
tree89efa6f0c927678275a327a2a73fc61a1f5f87ad
parenttermio: fix getting selection of known link. CID1367486 (diff)
downloadterminology-99f55b7bbc4d375d3b4525e449001dad6e536cdd.tar.gz
termptyesc: support DECSED3 to erase the backlog. Closes https://phab.enlightenment.org/T3713
-rw-r--r--src/bin/termptyesc.c58
-rw-r--r--src/bin/termptyops.c43
-rw-r--r--src/bin/termptyops.h1
3 files changed, 67 insertions, 35 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 774bc79..7cb1357 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -980,30 +980,56 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
termpty_write(ty, bf, strlen(bf));
}
break;
- case 'J': // "2j" erases the screen, 1j erase from screen start to curs, 0j erase cursor to end of screen
- DBG("2j erases the screen, 1j erase from screen start to curs, 0j erase cursor to end of screen");
- arg = _csi_arg_get(&b);
- if (b)
+ case 'J':
+ if (*b == '?')
{
- if ((arg >= TERMPTY_CLR_END) && (arg <= TERMPTY_CLR_ALL))
- termpty_clear_screen(ty, arg);
- else
- WRN("invalid clr scr %i", arg);
+ b++;
+ arg = _csi_arg_get(&b);
+ WRN("Unsupported selected erase in display %d", arg);
}
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;
case 'K': // 0K erase to end of line, 1K erase from screen start to cursor, 2K erase all of line
+ if (*b == '?')
+ {
+ b++;
+ arg = _csi_arg_get(&b);
+ WRN("Unsupported selected erase in line %d", arg);
+ }
arg = _csi_arg_get(&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 < 1) arg = 0;
+ DBG("EL/DECSEL %d: erase in line", arg);
+ switch (arg)
{
- if ((arg >= TERMPTY_CLR_END) && (arg <= TERMPTY_CLR_ALL))
- termpty_clear_line(ty, arg, ty->w);
- else
- WRN("invalid clr lin %i", 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;
case 'h':
case 'l':
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index 0a69ed2..698efbb 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -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
termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
@@ -370,7 +393,6 @@ termpty_reset_att(Termatt *att)
void
termpty_reset_state(Termpty *ty)
{
- int backsize;
int i;
ty->cursor_state.cx = 0;
@@ -403,24 +425,7 @@ termpty_reset_state(Termpty *ty)
ty->mouse_ext = MOUSE_EXT_NONE;
ty->bracketed_paste = 0;
- ty->backlog_beacon.screen_y = 0;
- 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_backlog(ty);
termpty_clear_tabs_on_screen(ty);
for (i = 0; i < ty->w; i += TAB_WIDTH)
{
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index deaf204..c2be8f2 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -23,6 +23,7 @@ void termpty_reset_att(Termatt *att);
void termpty_reset_state(Termpty *ty);
void termpty_cursor_copy(Termpty *ty, Eina_Bool save);
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)