termptyesc: support Unset Tab Stop (only VTE so far) + tests

This commit is contained in:
Boris Faure 2019-01-20 12:06:19 +01:00
parent 96bbfd054b
commit 392c04bbe0
3 changed files with 49 additions and 10 deletions

View File

@ -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,7 +3072,11 @@ _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
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;
@ -3069,6 +3086,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
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);

View File

@ -71,3 +71,4 @@ cbt.sh 417cd352d3eba45d6016df67a0314444
hpa.sh 0f86ca83e072d41b89dd1a012f0749a7
rep.sh b91ebb46fb5ebd95aa2cb87ad12bb4ba
da.sh 3083fbec33befe5299ca3726a19fcff2
uts.sh 1c72fe49e7f98aac137d436ac4906bc8

20
tests/uts.sh Executable file
View File

@ -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#'