From 395404c243ab97817721f3e62ae1b080c89dd3ec Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Tue, 8 Jan 2019 22:55:48 +0100 Subject: [PATCH] termptyesc: handle CTC + tests --- src/bin/termptyesc.c | 21 +++++++++++++++++++-- tests/ctc.sh | 29 +++++++++++++++++++++++++++++ tests/tests.results | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 tests/ctc.sh diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 4c13670c..dae3b742 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -2735,8 +2735,25 @@ _handle_esc_csi_ctc(Termpty *ty, Eina_Unicode **ptr) if (arg == -CSI_ARG_ERROR) return; - DBG("CTC - Cursor Tab Control: %d", arg); - /* TODO */ + switch (arg) + { + case -CSI_ARG_NO_VALUE: + EINA_FALLTHROUGH; + case 0: + TAB_SET(ty, ty->cursor_state.cx); + break; + case 2: + TAB_UNSET(ty, ty->cursor_state.cx); + break; + case 4: + EINA_FALLTHROUGH; + case 5: + termpty_clear_tabs_on_screen(ty); + break; + default: + ERR("invalid CTC argument %d", arg); + ty->decoding_error = EINA_TRUE; + } } static int diff --git a/tests/ctc.sh b/tests/ctc.sh new file mode 100755 index 00000000..6fd5773c --- /dev/null +++ b/tests/ctc.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# fill space with E +printf '\033#8' +# set color +printf '\033[46;31;3m' +# move to 0;0 +printf '\033[H' +# set tabs +printf '\033H\033H\033[3C\033[W\033[4C\033[0W\033[5C\033H\033[6C\033H' +printf '\033[7C\033H\033[8C\033H\033[9C' +printf '\nTabs set:' +# show # on tabs +printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#' +printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#' +# remove and add a tab +printf '\n# \033[2W@ \033[0W# \033[W#(One tab removed, two added)' +printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#' +# remove all tabs +printf '\n\033[4WRemove all tabs:' +printf '\n#\t#\t#\t#' +# set tabs +printf '\nAdd them again\033[?5W:' +printf '\r\033H\033H\033[3C\033[W\033[4C\033[0W\033[5C\033H\033[6C\033H' +printf '\033[7C\033H\033[8C\033H\033[9C' +printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#' +# remove all tabs +printf '\n\033[5WRemove all tabs:' +printf '\n#\t#\t#\t#' diff --git a/tests/tests.results b/tests/tests.results index ba29cbd1..e97ef43e 100644 --- a/tests/tests.results +++ b/tests/tests.results @@ -63,3 +63,4 @@ dl.sh e1e0ba19345d2ebf888f5a3e37f27037 su.sh 591185f42b75daa61726217033a17eaf sd.sh 4bfda7ec3e6192acab077de2bc270525 decst8c.sh 0ea805e8f4c2626ce66c566a10548d0f +ctc.sh d35eeacdb2e99f5ac8cc3c4e8d72f8b0