termptyesc: extract TBC to its own function + tests
This commit is contained in:
parent
395404c243
commit
ff830fbc42
|
@ -2717,7 +2717,10 @@ _handle_esc_csi_decst8c(Termpty *ty, Eina_Unicode **ptr)
|
||||||
if (arg == -CSI_ARG_ERROR)
|
if (arg == -CSI_ARG_ERROR)
|
||||||
return;
|
return;
|
||||||
if ((arg != -CSI_ARG_NO_VALUE) && (arg != 5))
|
if ((arg != -CSI_ARG_NO_VALUE) && (arg != 5))
|
||||||
|
{
|
||||||
|
ty->decoding_error = EINA_TRUE;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DBG("DECST8C - Set Tab at Every 8 Columns: %d", arg);
|
DBG("DECST8C - Set Tab at Every 8 Columns: %d", arg);
|
||||||
termpty_clear_tabs_on_screen(ty);
|
termpty_clear_tabs_on_screen(ty);
|
||||||
|
@ -2735,6 +2738,8 @@ _handle_esc_csi_ctc(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
|
||||||
if (arg == -CSI_ARG_ERROR)
|
if (arg == -CSI_ARG_ERROR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
DBG("CTC - Cursor Tab Control: %d", arg);
|
||||||
switch (arg)
|
switch (arg)
|
||||||
{
|
{
|
||||||
case -CSI_ARG_NO_VALUE:
|
case -CSI_ARG_NO_VALUE:
|
||||||
|
@ -2756,6 +2761,35 @@ _handle_esc_csi_ctc(Termpty *ty, Eina_Unicode **ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_esc_csi_tbc(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int arg = _csi_arg_get(ty, &b);
|
||||||
|
|
||||||
|
if (arg == -CSI_ARG_ERROR)
|
||||||
|
return;
|
||||||
|
DBG("TBC - Tab Clear: %d", arg);
|
||||||
|
switch (arg)
|
||||||
|
{
|
||||||
|
case -CSI_ARG_NO_VALUE:
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
|
case 0:
|
||||||
|
TAB_UNSET(ty, ty->cursor_state.cx);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
|
case 3:
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
|
case 5:
|
||||||
|
termpty_clear_tabs_on_screen(ty);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERR("Tabulation Clear (TBC) with invalid argument: %d", arg);
|
||||||
|
ty->decoding_error = EINA_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
{
|
{
|
||||||
|
@ -2971,26 +3005,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
case 'f':
|
case 'f':
|
||||||
_handle_esc_csi_cursor_pos_set(ty, &b, cc);
|
_handle_esc_csi_cursor_pos_set(ty, &b, cc);
|
||||||
break;
|
break;
|
||||||
case 'g': // clear tabulation
|
case 'g':
|
||||||
arg = _csi_arg_get(ty, &b);
|
_handle_esc_csi_tbc(ty, &b);
|
||||||
if (arg == -CSI_ARG_ERROR)
|
|
||||||
goto error;
|
|
||||||
if (arg < 0)
|
|
||||||
arg = 0;
|
|
||||||
if (arg == 0)
|
|
||||||
{
|
|
||||||
int cx = ty->cursor_state.cx;
|
|
||||||
TAB_UNSET(ty, cx);
|
|
||||||
}
|
|
||||||
else if (arg == 3)
|
|
||||||
{
|
|
||||||
termpty_clear_tabs_on_screen(ty);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ERR("Tabulation Clear (TBC) with invalid argument: %d", arg);
|
|
||||||
ty->decoding_error = EINA_TRUE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
_handle_esc_csi_reset_mode(ty, *cc, b, be);
|
_handle_esc_csi_reset_mode(ty, *cc, b, be);
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/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#'
|
||||||
|
# remove a tab
|
||||||
|
printf '\n# \033[0g@ \033[g@ Two tabs removed'
|
||||||
|
printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#'
|
||||||
|
# remove all tabs
|
||||||
|
printf '\n\033[2gRemove all tabs:'
|
||||||
|
printf '\n#\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[3gRemove all tabs:'
|
||||||
|
printf '\n#\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[5gRemove all tabs:'
|
||||||
|
printf '\n#\t#'
|
|
@ -64,3 +64,4 @@ su.sh 591185f42b75daa61726217033a17eaf
|
||||||
sd.sh 4bfda7ec3e6192acab077de2bc270525
|
sd.sh 4bfda7ec3e6192acab077de2bc270525
|
||||||
decst8c.sh 0ea805e8f4c2626ce66c566a10548d0f
|
decst8c.sh 0ea805e8f4c2626ce66c566a10548d0f
|
||||||
ctc.sh d35eeacdb2e99f5ac8cc3c4e8d72f8b0
|
ctc.sh d35eeacdb2e99f5ac8cc3c4e8d72f8b0
|
||||||
|
tbc.sh d0216e4056e5ab1cb4d411b6d6074785
|
||||||
|
|
Loading…
Reference in New Issue