termptyesc: export VPA handler to its own function + tests
This commit is contained in:
parent
bef8cb1373
commit
7dccab5481
|
@ -2962,6 +2962,25 @@ _handle_esc_csi_uts(Termpty *ty, Eina_Unicode **ptr)
|
||||||
TAB_UNSET(ty, arg);
|
TAB_UNSET(ty, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_esc_csi_vpa(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int arg = _csi_arg_get(ty, &b);
|
||||||
|
int max = ty->h + 1;
|
||||||
|
|
||||||
|
if (arg == -CSI_ARG_ERROR)
|
||||||
|
return;
|
||||||
|
DBG("VPA - Cursor Vertical Position Absolute: %d", arg);
|
||||||
|
if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin > 0))
|
||||||
|
{
|
||||||
|
max = ty->termstate.bottom_margin + 1;
|
||||||
|
}
|
||||||
|
TERMPTY_RESTRICT_FIELD(arg, 1, max);
|
||||||
|
ty->termstate.wrapnext = 0;
|
||||||
|
ty->cursor_state.cy = arg - 1;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -3085,17 +3104,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
if (*(cc-1) == ' ')
|
if (*(cc-1) == ' ')
|
||||||
_handle_esc_csi_uts(ty, &b);
|
_handle_esc_csi_uts(ty, &b);
|
||||||
else
|
else
|
||||||
{
|
_handle_esc_csi_vpa(ty, &b);
|
||||||
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;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
_handle_esc_csi_cud_or_vpr(ty, &b, cc);
|
_handle_esc_csi_cud_or_vpr(ty, &b, cc);
|
||||||
|
|
|
@ -72,3 +72,4 @@ hpa.sh 0f86ca83e072d41b89dd1a012f0749a7
|
||||||
rep.sh b91ebb46fb5ebd95aa2cb87ad12bb4ba
|
rep.sh b91ebb46fb5ebd95aa2cb87ad12bb4ba
|
||||||
da.sh 3083fbec33befe5299ca3726a19fcff2
|
da.sh 3083fbec33befe5299ca3726a19fcff2
|
||||||
uts.sh 1c72fe49e7f98aac137d436ac4906bc8
|
uts.sh 1c72fe49e7f98aac137d436ac4906bc8
|
||||||
|
vpa.sh c712e5c3c5e31a362e4257200d92d9a6
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# fill space with E
|
||||||
|
printf '\033#8'
|
||||||
|
# set color
|
||||||
|
printf '\033[46;31;3m'
|
||||||
|
# move to 2;2
|
||||||
|
printf '\033[2;2H'
|
||||||
|
|
||||||
|
# VPA 0
|
||||||
|
printf '\033[0d0'
|
||||||
|
|
||||||
|
# VPA 1
|
||||||
|
printf '\033[2;4H'
|
||||||
|
printf '\033[1d1'
|
||||||
|
|
||||||
|
# VPA 2
|
||||||
|
printf '\033[2;6H'
|
||||||
|
printf '\033[2d2'
|
||||||
|
|
||||||
|
# VPA default
|
||||||
|
printf '\033[2;8H'
|
||||||
|
printf '\033[ddefault'
|
||||||
|
|
||||||
|
# VPA 23
|
||||||
|
printf '\033[2;6H'
|
||||||
|
printf '\033[23d23'
|
||||||
|
|
||||||
|
# VPA 24
|
||||||
|
printf '\033[2;6H'
|
||||||
|
printf '\033[24dbottom'
|
||||||
|
|
||||||
|
# VPA too far
|
||||||
|
printf '\033[2;20H'
|
||||||
|
printf '\033[33333dtoo far'
|
||||||
|
|
||||||
|
|
||||||
|
# VPA with margins
|
||||||
|
# set top/bottom margins:
|
||||||
|
printf '\033[10;20r'
|
||||||
|
# allow left/right margins
|
||||||
|
printf '\033[?69h'
|
||||||
|
# set left/right margins:
|
||||||
|
printf '\033[25;50s'
|
||||||
|
# change color
|
||||||
|
printf '\033[0m\033[45;32;1m'
|
||||||
|
# fill restricted region with @
|
||||||
|
printf '\033[64;10;25;20;50\044x'
|
||||||
|
# change color back
|
||||||
|
printf '\033[0m\033[46;31;3m'
|
||||||
|
printf '\033[2;30H'
|
||||||
|
printf '\033[22d22 with margins'
|
||||||
|
|
||||||
|
# VPA with cursor restricted
|
||||||
|
# restrict cursor
|
||||||
|
printf '\033[?6h'
|
||||||
|
printf '\033[2;20H'
|
||||||
|
printf '\033[22d22 with margins and DECOM'
|
Loading…
Reference in New Issue