From 392c04bbe02aae2065fc756f66ea69eb31d39c19 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 20 Jan 2019 12:06:19 +0100 Subject: [PATCH] termptyesc: support Unset Tab Stop (only VTE so far) + tests --- src/bin/termptyesc.c | 38 ++++++++++++++++++++++++++++---------- tests/tests.results | 1 + tests/uts.sh | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 10 deletions(-) create mode 100755 tests/uts.sh diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 6dd989a3..a311760b 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -2940,6 +2940,19 @@ _handle_esc_csi_da(Termpty *ty, Eina_Unicode **ptr) termpty_write(ty, bf, len); } +static void +_handle_esc_csi_uts(Termpty *ty, Eina_Unicode **ptr) +{ + Eina_Unicode *b = *ptr; + int arg = _csi_arg_get(ty, &b); + + if (arg == -CSI_ARG_ERROR) + return; + DBG("UTS - Unset Tab Stop: %d", arg); + TERMPTY_RESTRICT_FIELD(arg, 0, ty->w); + TAB_UNSET(ty, arg); +} + static int _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) { @@ -3059,16 +3072,21 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) case 'c': _handle_esc_csi_da(ty, &b); break; - case 'd': // to row N - arg = _csi_arg_get(ty, &b); - if (arg == -CSI_ARG_ERROR) - goto error; - if (arg < 1) - arg = 1; - DBG("to row %d", arg); - ty->termstate.wrapnext = 0; - ty->cursor_state.cy = arg - 1; - TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h); + case 'd': + if (*(cc-1) == ' ') + _handle_esc_csi_uts(ty, &b); + else + { + arg = _csi_arg_get(ty, &b); + if (arg == -CSI_ARG_ERROR) + goto error; + if (arg < 1) + arg = 1; + DBG("to row %d", arg); + ty->termstate.wrapnext = 0; + ty->cursor_state.cy = arg - 1; + TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h); + } break; case 'e': _handle_esc_csi_cud(ty, &b); diff --git a/tests/tests.results b/tests/tests.results index ba005fe7..022f4375 100644 --- a/tests/tests.results +++ b/tests/tests.results @@ -71,3 +71,4 @@ cbt.sh 417cd352d3eba45d6016df67a0314444 hpa.sh 0f86ca83e072d41b89dd1a012f0749a7 rep.sh b91ebb46fb5ebd95aa2cb87ad12bb4ba da.sh 3083fbec33befe5299ca3726a19fcff2 +uts.sh 1c72fe49e7f98aac137d436ac4906bc8 diff --git a/tests/uts.sh b/tests/uts.sh new file mode 100755 index 00000000..0ba8ecbe --- /dev/null +++ b/tests/uts.sh @@ -0,0 +1,20 @@ +#!/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 '\nRemoved tab on position 3' +# remove tab on col 0 (has no effect) +printf '\033[ d' +# remove tab on col 3 +printf '\033[3 d' +printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#'