termptyesc: handle DECFRA

devs/iscaro/meson
Boris Faure 6 years ago
parent 7ea4b65c8d
commit 9f72ea3a9d
  1. 60
      src/bin/termptyesc.c
  2. 12
      src/bin/termptyops.c
  3. 1
      src/bin/termptyops.h

@ -825,6 +825,63 @@ bad:
ty->termstate.bottom_margin = 0;
}
static void
_handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
{
int c = _csi_arg_get(b);
int top = _csi_arg_get(b);
int left = _csi_arg_get(b);
int bottom = _csi_arg_get(b);
int right = _csi_arg_get(b);
int len;
DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area",
c, top, left, bottom, right);
if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255)))
return;
TERMPTY_RESTRICT_FIELD(top, 1, ty->h);
top--;
if (ty->termstate.restrict_cursor)
top += ty->termstate.top_margin;
TERMPTY_RESTRICT_FIELD(left, 1, ty->w);
left--;
if (ty->termstate.restrict_cursor)
left += ty->termstate.left_margin;
if (right < 1)
right = ty->w;
if (ty->termstate.restrict_cursor)
{
right += ty->termstate.left_margin;
if (ty->termstate.right_margin && right >= ty->termstate.right_margin)
right = ty->termstate.right_margin;
}
if (bottom < 1)
bottom = ty->h;
if (ty->termstate.restrict_cursor)
{
bottom += ty->termstate.top_margin;
if (ty->termstate.bottom_margin && bottom >= ty->termstate.bottom_margin)
bottom = ty->termstate.bottom_margin - 1;
}
bottom--;
if ((bottom < top) || (right < left))
return;
len = right - left;
for (; top <= bottom; top++)
{
Termcell *cells = &(TERMPTY_SCREEN(ty, left, top));
termpty_cells_fill(ty, c, cells, len);
}
}
static void
_handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
const Eina_Unicode *cc)
@ -990,6 +1047,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
ty->cursor_state.cx = 0;
break;
case 'x':
_handle_esc_csi_decfra(ty, &b);
break;
case 'X': // erase N chars
arg = _csi_arg_get(&b);
TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);

@ -22,16 +22,24 @@
#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
void
termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
termpty_cells_fill(Termpty *ty, Eina_Unicode codepoint,
Termcell *cells, int count)
{
Termcell src;
memset(&src, 0, sizeof(src));
src.codepoint = 0;
src.codepoint = codepoint;
src.att = ty->termstate.att;
termpty_cell_fill(ty, &src, cells, count);
}
void
termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
{
termpty_cells_fill(ty, 0, cells, count);
}
void
termpty_text_scroll(Termpty *ty, Eina_Bool clear)
{

@ -10,6 +10,7 @@ typedef enum _Termpty_Clear
void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max);
void termpty_cells_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count);
void termpty_cells_fill(Termpty *ty, Eina_Unicode codepoint, Termcell *cells, int count);
void termpty_cells_clear(Termpty *ty, Termcell *cells, int count);
void termpty_text_scroll(Termpty *ty, Eina_Bool clear);
void termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear);

Loading…
Cancel
Save