forked from enlightenment/terminology
termptyesc: CHA has to take into account DECOM + tests
This commit is contained in:
parent
a0db416469
commit
36682a1b4e
|
@ -2451,6 +2451,35 @@ _handle_esc_csi_cub(Termpty *ty, Eina_Unicode **ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_esc_csi_cha(Termpty *ty, Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int arg = _csi_arg_get(ty, &b);
|
||||||
|
int min = 0;
|
||||||
|
int max = ty->w;
|
||||||
|
|
||||||
|
DBG("CHA - Cursor Horizontal Absolute: %d", arg);
|
||||||
|
if (arg == -CSI_ARG_ERROR)
|
||||||
|
return;
|
||||||
|
if (arg < 1)
|
||||||
|
arg = 1;
|
||||||
|
ty->termstate.wrapnext = 0;
|
||||||
|
if (ty->termstate.restrict_cursor)
|
||||||
|
{
|
||||||
|
if (ty->termstate.left_margin)
|
||||||
|
{
|
||||||
|
arg += ty->termstate.left_margin;
|
||||||
|
}
|
||||||
|
if (ty->termstate.right_margin)
|
||||||
|
{
|
||||||
|
max = ty->termstate.right_margin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ty->cursor_state.cx = arg - 1;
|
||||||
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, min, max);
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -2504,17 +2533,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
case 'F':
|
case 'F':
|
||||||
_handle_esc_csi_cpl(ty, &b);
|
_handle_esc_csi_cpl(ty, &b);
|
||||||
break;
|
break;
|
||||||
case 'G': // to column N
|
case 'G':
|
||||||
arg = _csi_arg_get(ty, &b);
|
_handle_esc_csi_cha(ty, &b);
|
||||||
DBG("CHA - Cursor Horizontal Absolute: %d", arg);
|
|
||||||
if (arg == -CSI_ARG_ERROR)
|
|
||||||
goto error;
|
|
||||||
if (arg < 1)
|
|
||||||
arg = 1;
|
|
||||||
DBG("to column %d", arg);
|
|
||||||
ty->termstate.wrapnext = 0;
|
|
||||||
ty->cursor_state.cx = arg - 1;
|
|
||||||
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
|
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
_handle_esc_csi_cursor_pos_set(ty, &b, cc);
|
_handle_esc_csi_cursor_pos_set(ty, &b, cc);
|
||||||
|
|
38
tests/cha.sh
38
tests/cha.sh
|
@ -6,6 +6,38 @@ printf '\033[69;1;1;25;80\044x'
|
||||||
#set color
|
#set color
|
||||||
printf '\033[46;31;3m'
|
printf '\033[46;31;3m'
|
||||||
|
|
||||||
printf '\033[3G1'
|
# arg = 3
|
||||||
printf '\033[G2'
|
printf '\033[1;10H1\033[3G1'
|
||||||
printf '\033[444444G3'
|
|
||||||
|
# no arg
|
||||||
|
printf '\033[2;10H2\033[G2'
|
||||||
|
|
||||||
|
# go too far
|
||||||
|
printf '\033[3;10H3\033[3333G3'
|
||||||
|
|
||||||
|
# arg == 0
|
||||||
|
printf '\033[4;10H4\033[0G4'
|
||||||
|
|
||||||
|
# set top/bottom margins:
|
||||||
|
printf '\033[10;20r'
|
||||||
|
# allow left/right margins
|
||||||
|
printf '\033[?69h'
|
||||||
|
# set left/right margins:
|
||||||
|
printf '\033[5;15s'
|
||||||
|
# fill margin with @
|
||||||
|
printf '\033[64;10;5;20;15\044x'
|
||||||
|
|
||||||
|
# From inside to outside
|
||||||
|
printf '\033[12;12HA\033[20GA'
|
||||||
|
|
||||||
|
# From outside (on the left) to outside (on the right)
|
||||||
|
printf '\033[12;2HB\033[40GB'
|
||||||
|
|
||||||
|
# restrict cursor
|
||||||
|
printf '\033[?6h'
|
||||||
|
|
||||||
|
# From inside to inside
|
||||||
|
printf '\033[4;4HC\033[6GC'
|
||||||
|
|
||||||
|
# From inside to outside
|
||||||
|
printf '\033[5;2HD\033[40GD'
|
||||||
|
|
Loading…
Reference in New Issue