termptyesc: CNL and margins + tests

This commit is contained in:
Boris Faure 2018-12-24 17:01:11 +01:00
parent 4b32aec0ed
commit 3c47cc36e0
3 changed files with 64 additions and 11 deletions

View File

@ -1111,6 +1111,31 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
}
}
static void
_handle_esc_csi_cnl(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
int arg = _csi_arg_get(ty, &b);
int max = ty->h;
if (arg == -CSI_ARG_ERROR)
return;
if (arg < 1)
arg = 1;
DBG("CNL - Cursor Next Line: %d", arg);
ty->termstate.wrapnext = 0;
ty->cursor_state.cy += arg;
if (ty->termstate.bottom_margin)
{
max = ty->termstate.bottom_margin;
}
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy,
ty->termstate.top_margin,
max);
ty->cursor_state.cx = ty->termstate.left_margin;
}
static void
_handle_esc_csi_dch(Termpty *ty, Eina_Unicode **ptr,
const Eina_Unicode * const end)
@ -1712,17 +1737,8 @@ CUF:
ty->cursor_state.cx = ty->termstate.left_margin;
}
break;
case 'E': // down relative N rows, and to col 0
arg = _csi_arg_get(ty, &b);
if (arg == -CSI_ARG_ERROR)
goto error;
if (arg < 1)
arg = 1;
DBG("CNL - Cursor Next Line: %d", arg);
ty->termstate.wrapnext = 0;
ty->cursor_state.cy += arg;
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
ty->cursor_state.cx = 0;
case 'E':
_handle_esc_csi_cnl(ty, &b);
break;
case 'F': // up relative N rows, and to col 0
arg = _csi_arg_get(ty, &b);

36
tests/cnl.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
# fill space with E
printf '\033[69;1;1;25;80$x'
#set color
printf '\033[46;31;3m'
# move to 3; 3
printf '\033[3;3H'
printf 'a\033[Eb'
printf 'c\033[2Ed'
# 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$x'
# move
printf '\033[19;19H'
printf 'e\033[5Ef'
# set left/right margins:
printf '\033[25;35s'
# fill margin with @
printf '\033[64;10;25;20;35$x'
# restrict cursor
printf '\033[?6h'
# move
printf '\033[10;10H'
printf 'g\033[5Eh'

View File

@ -32,3 +32,4 @@ sgr-long.sh ec0425b1daabaa59096c10939e79b105
decsclm.sh 1ffcea3bfc4704d9091272dc59cbb311
cha.sh 04092c42102eb0d71ae700ee47c9ac34
dch.sh 40cf655681c098251f0dc3e7733c4db9
cnl.sh 1f1512179c8e47e4bd880142774a3c66