termptyesc: DCH shall handle margins. space created follows SGR + test

This commit is contained in:
Boris Faure 2018-12-17 23:03:19 +01:00
parent c162b07b16
commit 4b32aec0ed
3 changed files with 148 additions and 27 deletions

View File

@ -1111,6 +1111,52 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
}
}
static void
_handle_esc_csi_dch(Termpty *ty, Eina_Unicode **ptr,
const Eina_Unicode * const end)
{
Eina_Unicode *b = *ptr;
int arg = _csi_arg_get(ty, &b);
Termcell *cells;
int x, lim, max;
if (arg == -CSI_ARG_ERROR)
return;
DBG("DCH - Delete Character: %d chars", arg);
cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
max = ty->w;
if (ty->termstate.left_margin)
{
if (ty->cursor_state.cx < ty->termstate.left_margin)
return;
}
if (ty->termstate.right_margin)
{
if (ty->cursor_state.cx > ty->termstate.right_margin)
return;
max = ty->termstate.right_margin;
}
TERMPTY_RESTRICT_FIELD(arg, 1, max + 1);
lim = max - arg;
for (x = ty->cursor_state.cx; x < max; x++)
{
if (x < lim)
TERMPTY_CELL_COPY(ty, &(cells[x + arg]), &(cells[x]), 1);
else
{
cells[x].codepoint = ' ';
if (EINA_UNLIKELY(cells[x].att.link_id))
term_link_refcount_dec(ty, cells[x].att.link_id, 1);
cells[x].att = ty->termstate.att;
cells[x].att.link_id = 0;
cells[x].att.dblwidth = 0;
}
}
}
static void
_handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
{
@ -1819,33 +1865,7 @@ CUF:
}
break;
case 'P': // erase and scrollback N chars
arg = _csi_arg_get(ty, &b);
if (arg == -CSI_ARG_ERROR)
goto error;
TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
DBG("DCH - Delete Character: %d chars", arg);
{
Termcell *cells;
int x, lim;
cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
lim = ty->w - arg;
for (x = ty->cursor_state.cx; x < (ty->w); x++)
{
if (x < lim)
TERMPTY_CELL_COPY(ty, &(cells[x + arg]), &(cells[x]), 1);
else
{
cells[x].codepoint = ' ';
cells[x].att.underline = 0;
cells[x].att.blink = 0;
cells[x].att.blink2 = 0;
cells[x].att.inverse = 0;
cells[x].att.strike = 0;
cells[x].att.dblwidth = 0;
}
}
}
_handle_esc_csi_dch(ty, &b, be);
break;
case 'S': // scroll up N lines
arg = _csi_arg_get(ty, &b);

100
tests/dch.sh Executable file
View File

@ -0,0 +1,100 @@
#!/bin/sh
# move to 0; 0
printf '\033[H'
# fill space
for Y in $(seq 0 23); do
for X in $(seq 0 7); do
printf '\-/|\\~_>^<'
done
done
# move to 0; 0
printf '\033[H'
#set color
printf '\033[46;31;3m'
# move to 2; 1
printf '\033[2;1H'
# remove one char
printf '\033[P'
# move to 3; 1
printf '\033[3;1H'
# remove 8 chars
printf '\033[8P'
# move to 4; 1
printf '\033[4;1H'
# remove too many chars
printf '\033[888P'
# allow left/right margins
printf '\033[?69h'
# set left/right margins:
printf '\033[5;22s'
# outside margins
# move to 5; 2
printf '\033[5;5H'
# remove one char
printf '\033[P'
# move to 6; 2
printf '\033[6;2H'
# remove 8 chars
printf '\033[8P'
# move to 7; 2
printf '\033[7;2H'
# remove too many chars
printf '\033[888P'
# outside margins
# move to 8; 22
printf '\033[8;22H'
# remove one char
printf '\033[P'
# move to 9; 2
printf '\033[9;27H'
# remove 8 chars
printf '\033[8P'
# move to 10; 2
printf '\033[10;27H'
# remove too many chars
printf '\033[888P'
# inside margins
# move to 11; 2
printf '\033[11;7H'
# remove one char
printf '\033[P'
# move to 12; 2
printf '\033[12;7H'
# remove 8 chars
printf '\033[8P'
# move to 13; 2
printf '\033[13;7H'
# remove too many chars
printf '\033[888P'
# restrict cursor
printf '\033[?6h'
# inside margins
# move to 14; 2
printf '\033[14;2H'
# remove one char
printf '\033[P'
# move to 15; 2
printf '\033[15;2H'
# remove 8 chars
printf '\033[8P'
# move to 16; 2
printf '\033[16;2H'
# remove too many chars
printf '\033[888P'
#remove margins
printf '\033[?69l'
# move to 20; 41
printf '\033[20;41H'
# remove 40 chars
printf '\033[40P'

View File

@ -31,3 +31,4 @@ sgr-truecolors.sh 9db4becc728bb9f1730f3573dc7fc668
sgr-long.sh ec0425b1daabaa59096c10939e79b105
decsclm.sh 1ffcea3bfc4704d9091272dc59cbb311
cha.sh 04092c42102eb0d71ae700ee47c9ac34
dch.sh 40cf655681c098251f0dc3e7733c4db9