aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-01-02 23:32:38 +0100
committerBoris Faure <billiob@gmail.com>2019-01-02 23:32:38 +0100
commit0ca634cd698006eba8f9235fc0e6df4df14c7f90 (patch)
tree52dab7e655fea55c13140df215aaaf7802f7139b /src
parenttermptyesc: move ED handler to its own functions + add tests (diff)
downloadterminology-0ca634cd698006eba8f9235fc0e6df4df14c7f90.tar.gz
termptyesc: export EL handler to its own function + add tests
Diffstat (limited to 'src')
-rw-r--r--src/bin/termptyesc.c62
-rw-r--r--src/bin/termptyops.h6
2 files changed, 38 insertions, 30 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 9551f80..b70fe89 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -2533,6 +2533,37 @@ _handle_esc_csi_decsed(Termpty *ty, Eina_Unicode **ptr)
_handle_esc_csi_ed(ty, ptr);
}
+static void
+_handle_esc_csi_el(Termpty *ty, Eina_Unicode **ptr)
+{
+ Eina_Unicode *b = *ptr;
+ int arg = _csi_arg_get(ty, &b);
+
+ if (arg == -CSI_ARG_ERROR)
+ return;
+ if (arg < 1)
+ arg = 0;
+ DBG("EL - Erase in Line: %d", 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);
+ ty->decoding_error = EINA_TRUE;
+ }
+}
+
+static void
+_handle_esc_csi_decsel(Termpty *ty, Eina_Unicode **ptr)
+{
+ WRN("DECSEL - Selective Erase in Line: Unsupported");
+ _handle_esc_csi_el(ty, ptr);
+}
+
static int
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@@ -2601,34 +2632,11 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
else
_handle_esc_csi_ed(ty, &b);
break;
- case 'K': // 0K erase to end of line, 1K erase from screen start to cursor, 2K erase all of line
+ case 'K':
if (*b == '?')
- {
- b++;
- arg = _csi_arg_get(ty, &b);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- WRN("Unsupported selected erase in line %d", arg);
- ty->decoding_error = EINA_TRUE;
- break;
- }
- arg = _csi_arg_get(ty, &b);
- if (arg == -CSI_ARG_ERROR)
- goto error;
- 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);
- ty->decoding_error = EINA_TRUE;
- }
+ _handle_esc_csi_decsel(ty, &b);
+ else
+ _handle_esc_csi_el(ty, &b);
break;
case 'L': // insert N lines - cy
EINA_FALLTHROUGH;
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index 48cbc0a..dd5bd1d 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -3,9 +3,9 @@
typedef enum _Termpty_Clear
{
- TERMPTY_CLR_END,
- TERMPTY_CLR_BEGIN,
- TERMPTY_CLR_ALL
+ TERMPTY_CLR_END = 0,
+ TERMPTY_CLR_BEGIN = 1,
+ TERMPTY_CLR_ALL = 2
} Termpty_Clear;
void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max);