termptyesc: extract CBT handler to its own function + tests
This commit is contained in:
parent
bf3d3991cd
commit
c1d030da0a
|
@ -2803,6 +2803,31 @@ _handle_esc_csi_ech(Termpty *ty, Eina_Unicode **ptr)
|
||||||
termpty_clear_line(ty, TERMPTY_CLR_END, arg);
|
termpty_clear_line(ty, TERMPTY_CLR_END, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_esc_csi_cbt(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int cx = ty->cursor_state.cx;
|
||||||
|
int arg = _csi_arg_get(ty, &b);
|
||||||
|
|
||||||
|
if (arg == -CSI_ARG_ERROR)
|
||||||
|
return;
|
||||||
|
DBG("CBT - Cursor Horizontal Backward Tabulation: %d", arg);
|
||||||
|
|
||||||
|
TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
|
||||||
|
for (; arg > 0; arg--)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cx--;
|
||||||
|
}
|
||||||
|
while ((cx >= 0) && (!TAB_TEST(ty, cx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
ty->cursor_state.cx = cx;
|
||||||
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -2908,26 +2933,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
_handle_esc_csi_ech(ty, &b);
|
_handle_esc_csi_ech(ty, &b);
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
{
|
_handle_esc_csi_cbt(ty, &b);
|
||||||
int cx = ty->cursor_state.cx;
|
|
||||||
|
|
||||||
arg = _csi_arg_get(ty, &b);
|
|
||||||
if (arg == -CSI_ARG_ERROR)
|
|
||||||
goto error;
|
|
||||||
DBG("Cursor Backward Tabulation (CBT): %d", arg);
|
|
||||||
TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
|
|
||||||
for (; arg > 0; arg--)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
cx--;
|
|
||||||
}
|
|
||||||
while ((cx >= 0) && (!TAB_TEST(ty, cx)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ty->cursor_state.cx = cx;
|
|
||||||
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case '`': // HPA
|
case '`': // HPA
|
||||||
arg = _csi_arg_get(ty, &b);
|
arg = _csi_arg_get(ty, &b);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/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 '\033[Z@'
|
||||||
|
printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#'
|
||||||
|
printf '\033[0Z@'
|
||||||
|
printf '\n#\t#\t#\t#\t#\t#\t#\t#\t#\t#\t#'
|
||||||
|
printf '\033[3Z@'
|
|
@ -67,3 +67,4 @@ ctc.sh d35eeacdb2e99f5ac8cc3c4e8d72f8b0
|
||||||
tbc.sh d0216e4056e5ab1cb4d411b6d6074785
|
tbc.sh d0216e4056e5ab1cb4d411b6d6074785
|
||||||
ech.sh 57a3ff127abbb3efa4082fab7de59970
|
ech.sh 57a3ff127abbb3efa4082fab7de59970
|
||||||
text_append_after_right_margin.sh 26b334188d39e2b12538a6ca91ca168c
|
text_append_after_right_margin.sh 26b334188d39e2b12538a6ca91ca168c
|
||||||
|
cbt.sh 417cd352d3eba45d6016df67a0314444
|
||||||
|
|
Loading…
Reference in New Issue