separate "termstate" from cursor state and screens. Closes T725

This commit is contained in:
Boris Faure 2015-04-19 19:59:29 +02:00
parent caf4e92302
commit be62d87f89
11 changed files with 365 additions and 367 deletions

View File

@ -69,8 +69,8 @@ _key_try(Termpty *ty, const Tty_Key *map, int len, const Evas_Event_Key_Down *ev
const struct _s *s = NULL; const struct _s *s = NULL;
const Key_Values *kv; const Key_Values *kv;
if (!ty->state.appcursor) kv = &map[i].default_mode; if (!ty->termstate.appcursor) kv = &map[i].default_mode;
else kv = &map[i].cursor; else kv = &map[i].cursor;
if (!alt && !ctrl && !shift) s = &kv->plain; if (!alt && !ctrl && !shift) s = &kv->plain;
else if (alt && !ctrl && !shift) s = &kv->alt; else if (alt && !ctrl && !shift) s = &kv->alt;
else if (!alt && ctrl && !shift) s = &kv->ctrl; else if (!alt && ctrl && !shift) s = &kv->ctrl;
@ -112,7 +112,7 @@ _handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
{ {
if (alt) if (alt)
termpty_write(ty, "\033", 1); termpty_write(ty, "\033", 1);
if (ty->state.send_bs) if (ty->termstate.send_bs)
{ {
termpty_write(ty, "\b", 1); termpty_write(ty, "\b", 1);
} }
@ -135,7 +135,7 @@ _handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
{ {
if (alt) if (alt)
termpty_write(ty, "\033", 1); termpty_write(ty, "\033", 1);
if (ty->state.crlf) if (ty->termstate.crlf)
{ {
termpty_write(ty, "\r\n", sizeof("\r\n") - 1); termpty_write(ty, "\r\n", sizeof("\r\n") - 1);
return; return;
@ -150,7 +150,7 @@ _handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
{ {
if (!evas_key_lock_is_set(ev->locks, "Num_Lock")) if (!evas_key_lock_is_set(ev->locks, "Num_Lock"))
{ {
if (ty->state.alt_kp) if (ty->termstate.alt_kp)
{ {
if (_key_try(ty, tty_keys_kp_app, if (_key_try(ty, tty_keys_kp_app,
sizeof(tty_keys_kp_app)/sizeof(tty_keys_kp_app[0]), sizeof(tty_keys_kp_app)/sizeof(tty_keys_kp_app[0]),
@ -242,10 +242,10 @@ keyin_handle(Keys_Handler *khdl, Termpty *ty, const Evas_Event_Key_Down *ev,
} }
// if term app asked for kbd lock - dont handle here // if term app asked for kbd lock - dont handle here
if (ty->state.kbd_lock) return EINA_TRUE; if (ty->termstate.kbd_lock) return EINA_TRUE;
// if app asked us to not do autorepeat - ignore press if is it is the same // if app asked us to not do autorepeat - ignore press if is it is the same
// timestamp as last one // timestamp as last one
if ((ty->state.no_autorepeat) && if ((ty->termstate.no_autorepeat) &&
(ev->timestamp == khdl->last_keyup)) return EINA_TRUE; (ev->timestamp == khdl->last_keyup)) return EINA_TRUE;
if (!khdl->composing) if (!khdl->composing)
{ {

View File

@ -81,7 +81,7 @@ static void
_draw_cell(const Termpty *ty, unsigned int *pixel, const Termcell *cell, unsigned int *colors) _draw_cell(const Termpty *ty, unsigned int *pixel, const Termcell *cell, unsigned int *colors)
{ {
int fg, bg, fgext, bgext; int fg, bg, fgext, bgext;
int inv = ty->state.reverse; int inv = ty->termstate.reverse;
Eina_Unicode codepoint; Eina_Unicode codepoint;
codepoint = cell->codepoint; codepoint = cell->codepoint;

View File

@ -4512,7 +4512,7 @@ _smart_apply(Evas_Object *obj)
blk->was_active = blk->active; blk->was_active = blk->active;
blk->active = EINA_FALSE; blk->active = EINA_FALSE;
} }
inv = sd->pty->state.reverse; inv = sd->pty->termstate.reverse;
termpty_cellcomp_freeze(sd->pty); termpty_cellcomp_freeze(sd->pty);
for (y = 0; y < sd->grid.h; y++) for (y = 0; y < sd->grid.h; y++)
{ {
@ -4753,12 +4753,12 @@ _smart_apply(Evas_Object *obj)
(sd->pty->block.active, l); (sd->pty->block.active, l);
} }
} }
if ((sd->scroll != 0) || (sd->pty->state.hidecursor)) if ((sd->scroll != 0) || (sd->pty->termstate.hide_cursor))
evas_object_hide(sd->cursor.obj); evas_object_hide(sd->cursor.obj);
else else
evas_object_show(sd->cursor.obj); evas_object_show(sd->cursor.obj);
sd->cursor.x = sd->pty->state.cx; sd->cursor.x = sd->pty->cursor_state.cx;
sd->cursor.y = sd->pty->state.cy; sd->cursor.y = sd->pty->cursor_state.cy;
evas_object_move(sd->cursor.obj, evas_object_move(sd->cursor.obj,
ox + ((sd->cursor.x + preedit_x) * sd->font.chw), ox + ((sd->cursor.x + preedit_x) * sd->font.chw),
oy + ((sd->cursor.y + preedit_y) * sd->font.chh)); oy + ((sd->cursor.y + preedit_y) * sd->font.chh));

View File

@ -268,13 +268,23 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
} }
static void static void
_limit_coord(Termpty *ty, Termstate *state) _limit_coord(Termpty *ty)
{ {
state->wrapnext = 0; ty->termstate.wrapnext = 0;
if (state->cx >= ty->w) state->cx = ty->w - 1; if (ty->termstate.had_cr_x >= ty->w)
if (state->cy >= ty->h) state->cy = ty->h - 1; ty->termstate.had_cr_x = ty->w - 1;
if (state->had_cr_x >= ty->w) state->had_cr_x = ty->w - 1; if (ty->termstate.had_cr_y >= ty->h)
if (state->had_cr_y >= ty->h) state->had_cr_y = ty->h - 1; ty->termstate.had_cr_y = ty->h - 1;
if (ty->cursor_state.cx >= ty->w)
ty->cursor_state.cx = ty->w - 1;
if (ty->cursor_state.cy >= ty->h)
ty->cursor_state.cy = ty->h - 1;
if (ty->cursor_save.cx >= ty->w)
ty->cursor_save.cx = ty->w - 1;
if (ty->cursor_save.cy >= ty->h)
ty->cursor_save.cy = ty->h - 1;
} }
Termpty * Termpty *
@ -298,8 +308,6 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
ty->backmax = backscroll; ty->backmax = backscroll;
_termpty_reset_state(ty); _termpty_reset_state(ty);
ty->save = ty->state;
ty->swap = ty->state;
ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h); ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h);
if (!ty->screen) if (!ty->screen)
@ -799,7 +807,7 @@ termpty_line_rewrap(Termpty *ty, int y_start, int y_end,
new_back[new_y + ty->backmax] = new_ts; new_back[new_y + ty->backmax] = new_ts;
} }
} }
if (y == ty->state.cy) if (y == ty->cursor_state.cy)
{ {
*new_cyp = new_y_start; *new_cyp = new_y_start;
} }
@ -831,7 +839,7 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
Termcell *new_screen = NULL; Termcell *new_screen = NULL;
Termsave **new_back = NULL; Termsave **new_back = NULL;
int y_start = 0, y_end = 0, new_y_start = 0, new_y_end, int y_start = 0, y_end = 0, new_y_start = 0, new_y_end,
new_cy = ty->state.cy; new_cy = ty->cursor_state.cy;
int i, altbuf = 0; int i, altbuf = 0;
if ((ty->w == new_w) && (ty->h == new_h)) return; if ((ty->w == new_w) && (ty->h == new_h)) return;
@ -855,7 +863,7 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
goto bad; goto bad;
new_back = calloc(sizeof(Termsave *), ty->backmax); new_back = calloc(sizeof(Termsave *), ty->backmax);
y_end = ty->state.cy; y_end = ty->cursor_state.cy;
new_y_end = new_h - 1; new_y_end = new_h - 1;
/* For each "full line" in old buffers, rewrap. /* For each "full line" in old buffers, rewrap.
* From most recent to oldest */ * From most recent to oldest */
@ -885,15 +893,13 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
ty->circular_offset = MAX(new_y_start, 0); ty->circular_offset = MAX(new_y_start, 0);
ty->backpos = 0; ty->backpos = 0;
ty->backscroll_num = MAX(-new_y_start, 0); ty->backscroll_num = MAX(-new_y_start, 0);
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
ty->state.cy = (new_cy + new_h - ty->circular_offset) % new_h; ty->cursor_state.cy = (new_cy + new_h - ty->circular_offset) % new_h;
if (altbuf) termpty_screen_swap(ty); if (altbuf) termpty_screen_swap(ty);
_limit_coord(ty, &(ty->state)); _limit_coord(ty);
_limit_coord(ty, &(ty->swap));
_limit_coord(ty, &(ty->save));
_pty_size(ty); _pty_size(ty);
@ -1100,25 +1106,11 @@ termpty_screen_swap(Termpty *ty)
{ {
Termcell *tmp_screen; Termcell *tmp_screen;
int tmp_circular_offset; int tmp_circular_offset;
Termstate tmp;
tmp_screen = ty->screen; tmp_screen = ty->screen;
ty->screen = ty->screen2; ty->screen = ty->screen2;
ty->screen2 = tmp_screen; ty->screen2 = tmp_screen;
if (ty->altbuf)
{
tmp = ty->state;
ty->state = ty->swap;
ty->swap = tmp;
}
else
{
tmp = ty->swap;
ty->swap = ty->state;
ty->state = tmp;
}
tmp_circular_offset = ty->circular_offset; tmp_circular_offset = ty->circular_offset;
ty->circular_offset = ty->circular_offset2; ty->circular_offset = ty->circular_offset2;
ty->circular_offset2 = tmp_circular_offset; ty->circular_offset2 = tmp_circular_offset;

View File

@ -6,7 +6,6 @@
typedef struct _Termpty Termpty; typedef struct _Termpty Termpty;
typedef struct _Termcell Termcell; typedef struct _Termcell Termcell;
typedef struct _Termatt Termatt; typedef struct _Termatt Termatt;
typedef struct _Termstate Termstate;
typedef struct _Termsave Termsave; typedef struct _Termsave Termsave;
typedef struct _Termsavecomp Termsavecomp; typedef struct _Termsavecomp Termsavecomp;
typedef struct _Termblock Termblock; typedef struct _Termblock Termblock;
@ -84,32 +83,6 @@ struct _Termatt
#endif #endif
}; };
struct _Termstate
{
int cx, cy;
Termatt att;
unsigned char charset;
unsigned char charsetch;
unsigned char chset[4];
int scroll_y1, scroll_y2;
int had_cr_x, had_cr_y;
int margin_top; // soon, more to come...
unsigned int multibyte : 1;
unsigned int alt_kp : 1;
unsigned int insert : 1;
unsigned int appcursor : 1;
unsigned int wrap : 1;
unsigned int wrapnext : 1;
unsigned int hidecursor : 1;
unsigned int crlf : 1;
unsigned int had_cr : 1;
unsigned int send_bs : 1;
unsigned int kbd_lock : 1;
unsigned int reverse : 1;
unsigned int no_autorepeat : 1;
unsigned int cjk_ambiguous_wide : 1;
};
struct _Termpty struct _Termpty
{ {
Evas_Object *obj; Evas_Object *obj;
@ -158,7 +131,32 @@ struct _Termpty
unsigned char by_line : 1; unsigned char by_line : 1;
unsigned char is_top_to_bottom : 1; unsigned char is_top_to_bottom : 1;
} selection; } selection;
Termstate state, save, swap; struct {
Termatt att;
unsigned char charset;
unsigned char charsetch;
unsigned char chset[4];
int scroll_y1, scroll_y2;
int had_cr_x, had_cr_y;
int margin_top; // soon, more to come...
unsigned int multibyte : 1;
unsigned int alt_kp : 1;
unsigned int insert : 1;
unsigned int appcursor : 1;
unsigned int wrap : 1;
unsigned int wrapnext : 1;
unsigned int crlf : 1;
unsigned int had_cr : 1;
unsigned int send_bs : 1;
unsigned int kbd_lock : 1;
unsigned int reverse : 1;
unsigned int no_autorepeat : 1;
unsigned int cjk_ambiguous_wide : 1;
unsigned int hide_cursor : 1;
} termstate;
struct {
int cx, cy;
} cursor_state, cursor_save;
int exit_code; int exit_code;
pid_t pid; pid_t pid;
unsigned int altbuf : 1; unsigned int altbuf : 1;

View File

@ -41,7 +41,7 @@ _termpty_is_dblwidth_slow_get(Termpty *ty, int g)
return EINA_TRUE; return EINA_TRUE;
// FIXME: can optimize by breaking into tree and ranges // FIXME: can optimize by breaking into tree and ranges
// (A) // (A)
if (ty->state.cjk_ambiguous_wide) if (ty->termstate.cjk_ambiguous_wide)
{ {
// grep ';A #' EastAsianWidth.txt | wc -l // grep ';A #' EastAsianWidth.txt | wc -l
// :( // :(

View File

@ -58,51 +58,51 @@ _handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
switch (*cc) switch (*cc)
{ {
case 0x07: // BEL '\a' (bell) case 0x07: // BEL '\a' (bell)
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
if (ty->cb.bell.func) ty->cb.bell.func(ty->cb.bell.data); if (ty->cb.bell.func) ty->cb.bell.func(ty->cb.bell.data);
return; return;
case 0x08: // BS '\b' (backspace) case 0x08: // BS '\b' (backspace)
DBG("->BS"); DBG("->BS");
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cx--; ty->cursor_state.cx--;
if (ty->state.cx < 0) ty->state.cx = 0; if (ty->cursor_state.cx < 0) ty->cursor_state.cx = 0;
return; return;
case 0x09: // HT '\t' (horizontal tab) case 0x09: // HT '\t' (horizontal tab)
DBG("->HT"); DBG("->HT");
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
TERMPTY_SCREEN(ty, ty->state.cx, ty->state.cy).att.tab = 1; TERMPTY_SCREEN(ty, ty->cursor_state.cx, ty->cursor_state.cy).att.tab = 1;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cx += 8; ty->cursor_state.cx += 8;
ty->state.cx = (ty->state.cx / 8) * 8; ty->cursor_state.cx = (ty->cursor_state.cx / 8) * 8;
if (ty->state.cx >= ty->w) if (ty->cursor_state.cx >= ty->w)
ty->state.cx = ty->w - 1; ty->cursor_state.cx = ty->w - 1;
return; return;
case 0x0a: // LF '\n' (new line) case 0x0a: // LF '\n' (new line)
case 0x0b: // VT '\v' (vertical tab) case 0x0b: // VT '\v' (vertical tab)
case 0x0c: // FF '\f' (form feed) case 0x0c: // FF '\f' (form feed)
DBG("->LF"); DBG("->LF");
if (ty->state.had_cr) if (ty->termstate.had_cr)
{ {
TERMPTY_SCREEN(ty, ty->state.had_cr_x, TERMPTY_SCREEN(ty, ty->termstate.had_cr_x,
ty->state.had_cr_y).att.newline = 1; ty->termstate.had_cr_y).att.newline = 1;
} }
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
if (ty->state.crlf) ty->state.cx = 0; if (ty->termstate.crlf) ty->cursor_state.cx = 0;
ty->state.cy++; ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_TRUE); _termpty_text_scroll_test(ty, EINA_TRUE);
return; return;
case 0x0d: // CR '\r' (carriage ret) case 0x0d: // CR '\r' (carriage ret)
DBG("->CR"); DBG("->CR");
if (ty->state.cx != 0) if (ty->cursor_state.cx != 0)
{ {
ty->state.had_cr_x = ty->state.cx; ty->termstate.had_cr_x = ty->cursor_state.cx;
ty->state.had_cr_y = ty->state.cy; ty->termstate.had_cr_y = ty->cursor_state.cy;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
} }
ty->state.cx = 0; ty->cursor_state.cx = 0;
// ty->state.had_cr = 1; // ty->termstate.had_cr = 1;
return; return;
default: default:
return; return;
@ -149,14 +149,14 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
switch (arg) switch (arg)
{ {
case 1: case 1:
ty->state.appcursor = mode; ty->termstate.appcursor = mode;
break; break;
case 2: case 2:
ty->state.kbd_lock = mode; ty->termstate.kbd_lock = mode;
break; break;
case 3: // 132 column mode… should we handle this? case 3: // 132 column mode… should we handle this?
#if defined(SUPPORT_80_132_COLUMNS) #if defined(SUPPORT_80_132_COLUMNS)
if (ty->state.att.is_80_132_mode_allowed) if (ty->termstate.att.is_80_132_mode_allowed)
{ {
/* ONLY FOR TESTING PURPOSE FTM */ /* ONLY FOR TESTING PURPOSE FTM */
Evas_Object *wn; Evas_Object *wn;
@ -180,18 +180,18 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
WRN("TODO: scrolling mode (DECSCLM): %i", mode); WRN("TODO: scrolling mode (DECSCLM): %i", mode);
break; break;
case 5: case 5:
ty->state.reverse = mode; ty->termstate.reverse = mode;
break; break;
case 6: case 6:
if (mode) if (mode)
{ {
ty->state.margin_top = ty->state.cy; ty->termstate.margin_top = ty->cursor_state.cy;
ty->state.cx = 0; ty->cursor_state.cx = 0;
} }
else else
{ {
ty->state.cx = 0; ty->cursor_state.cx = 0;
ty->state.margin_top = 0; ty->termstate.margin_top = 0;
} }
DBG("origin mode (%d): cursor is at 0,0" DBG("origin mode (%d): cursor is at 0,0"
" cursor limited to screen/start point" " cursor limited to screen/start point"
@ -200,10 +200,10 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
break; break;
case 7: case 7:
DBG("set wrap mode to %i", mode); DBG("set wrap mode to %i", mode);
ty->state.wrap = mode; ty->termstate.wrap = mode;
break; break;
case 8: case 8:
ty->state.no_autorepeat = !mode; ty->termstate.no_autorepeat = !mode;
DBG("auto repeat %i", mode); DBG("auto repeat %i", mode);
break; break;
case 9: case 9:
@ -218,10 +218,10 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
WRN("TODO: set print extent to full screen"); WRN("TODO: set print extent to full screen");
break; break;
case 20: // crfl==1 -> cur moves to col 0 on LF, FF or VT, ==0 -> mode is cr+lf case 20: // crfl==1 -> cur moves to col 0 on LF, FF or VT, ==0 -> mode is cr+lf
ty->state.crlf = mode; ty->termstate.crlf = mode;
break; break;
case 25: case 25:
ty->state.hidecursor = !mode; ty->termstate.hide_cursor = !mode;
DBG("hide cursor: %d", !mode); DBG("hide cursor: %d", !mode);
break; break;
case 30: // ignore case 30: // ignore
@ -242,7 +242,7 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
case 40: case 40:
DBG("Allow 80 -> 132 Mode %i", mode); DBG("Allow 80 -> 132 Mode %i", mode);
#if defined(SUPPORT_80_132_COLUMNS) #if defined(SUPPORT_80_132_COLUMNS)
ty->state.att.is_80_132_mode_allowed = mode; ty->termstate.att.is_80_132_mode_allowed = mode;
#endif #endif
break; break;
case 45: // ignore case 45: // ignore
@ -255,7 +255,7 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
WRN("TODO: app keypad mode %i", mode); WRN("TODO: app keypad mode %i", mode);
break; break;
case 67: case 67:
ty->state.send_bs = mode; ty->termstate.send_bs = mode;
DBG("backspace send bs not del = %i", mode); DBG("backspace send bs not del = %i", mode);
break; break;
case 1000: case 1000:
@ -312,10 +312,7 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
break; break;
case 1048: case 1048:
case 1049: case 1049:
if (mode) _termpty_cursor_copy(ty, mode);
_termpty_cursor_copy(&(ty->state), &(ty->save));
else
_termpty_cursor_copy(&(ty->save), &(ty->state));
if (arg == 1049) if (arg == 1049)
_switch_to_alternative_screen(ty, mode); _switch_to_alternative_screen(ty, mode);
break; break;
@ -345,11 +342,11 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
switch (arg) switch (arg)
{ {
case 1: case 1:
ty->state.appcursor = mode; ty->termstate.appcursor = mode;
break; break;
case 4: case 4:
DBG("set insert mode to %i", mode); DBG("set insert mode to %i", mode);
ty->state.insert = mode; ty->termstate.insert = mode;
break; break;
case 34: case 34:
WRN("TODO: hebrew keyboard mapping: %i", mode); WRN("TODO: hebrew keyboard mapping: %i", mode);
@ -381,75 +378,75 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
{ {
int arg = _csi_arg_get(&b); int arg = _csi_arg_get(&b);
if ((first) && (!b)) if ((first) && (!b))
_termpty_reset_att(&(ty->state.att)); _termpty_reset_att(&(ty->termstate.att));
else if (b) else if (b)
{ {
first = 0; first = 0;
switch (arg) switch (arg)
{ {
case 0: // reset to normal case 0: // reset to normal
_termpty_reset_att(&(ty->state.att)); _termpty_reset_att(&(ty->termstate.att));
break; break;
case 1: // bold/bright case 1: // bold/bright
ty->state.att.bold = 1; ty->termstate.att.bold = 1;
break; break;
case 2: // faint case 2: // faint
ty->state.att.faint = 1; ty->termstate.att.faint = 1;
break; break;
case 3: // italic case 3: // italic
#if defined(SUPPORT_ITALIC) #if defined(SUPPORT_ITALIC)
ty->state.att.italic = 1; ty->termstate.att.italic = 1;
#endif #endif
break; break;
case 4: // underline case 4: // underline
ty->state.att.underline = 1; ty->termstate.att.underline = 1;
break; break;
case 5: // blink case 5: // blink
ty->state.att.blink = 1; ty->termstate.att.blink = 1;
break; break;
case 6: // blink rapid case 6: // blink rapid
ty->state.att.blink2 = 1; ty->termstate.att.blink2 = 1;
break; break;
case 7: // reverse case 7: // reverse
ty->state.att.inverse = 1; ty->termstate.att.inverse = 1;
break; break;
case 8: // invisible case 8: // invisible
ty->state.att.invisible = 1; ty->termstate.att.invisible = 1;
break; break;
case 9: // strikethrough case 9: // strikethrough
ty->state.att.strike = 1; ty->termstate.att.strike = 1;
break; break;
case 20: // fraktur! case 20: // fraktur!
ty->state.att.fraktur = 1; ty->termstate.att.fraktur = 1;
break; break;
case 21: // no bold/bright case 21: // no bold/bright
ty->state.att.bold = 0; ty->termstate.att.bold = 0;
break; break;
case 22: // no bold/bright, no faint case 22: // no bold/bright, no faint
ty->state.att.bold = 0; ty->termstate.att.bold = 0;
ty->state.att.faint = 0; ty->termstate.att.faint = 0;
break; break;
case 23: // no italic, not fraktur case 23: // no italic, not fraktur
#if defined(SUPPORT_ITALIC) #if defined(SUPPORT_ITALIC)
ty->state.att.italic = 0; ty->termstate.att.italic = 0;
#endif #endif
ty->state.att.fraktur = 0; ty->termstate.att.fraktur = 0;
break; break;
case 24: // no underline case 24: // no underline
ty->state.att.underline = 0; ty->termstate.att.underline = 0;
break; break;
case 25: // no blink case 25: // no blink
ty->state.att.blink = 0; ty->termstate.att.blink = 0;
ty->state.att.blink2 = 0; ty->termstate.att.blink2 = 0;
break; break;
case 27: // no reverse case 27: // no reverse
ty->state.att.inverse = 0; ty->termstate.att.inverse = 0;
break; break;
case 28: // no invisible case 28: // no invisible
ty->state.att.invisible = 0; ty->termstate.att.invisible = 0;
break; break;
case 29: // no strikethrough case 29: // no strikethrough
ty->state.att.strike = 0; ty->termstate.att.strike = 0;
break; break;
case 30: // fg case 30: // fg
case 31: case 31:
@ -459,9 +456,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
case 35: case 35:
case 36: case 36:
case 37: case 37:
ty->state.att.fg256 = 0; ty->termstate.att.fg256 = 0;
ty->state.att.fg = (arg - 30) + COL_BLACK; ty->termstate.att.fg = (arg - 30) + COL_BLACK;
ty->state.att.fgintense = 0; ty->termstate.att.fgintense = 0;
break; break;
case 38: // xterm 256 fg color ??? case 38: // xterm 256 fg color ???
// now check if next arg is 5 // now check if next arg is 5
@ -474,16 +471,16 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
if (!b) ERR("Failed xterm 256 color fg esc val"); if (!b) ERR("Failed xterm 256 color fg esc val");
else else
{ {
ty->state.att.fg256 = 1; ty->termstate.att.fg256 = 1;
ty->state.att.fg = arg; ty->termstate.att.fg = arg;
} }
} }
ty->state.att.fgintense = 0; ty->termstate.att.fgintense = 0;
break; break;
case 39: // default fg color case 39: // default fg color
ty->state.att.fg256 = 0; ty->termstate.att.fg256 = 0;
ty->state.att.fg = COL_DEF; ty->termstate.att.fg = COL_DEF;
ty->state.att.fgintense = 0; ty->termstate.att.fgintense = 0;
break; break;
case 40: // bg case 40: // bg
case 41: case 41:
@ -493,9 +490,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
case 45: case 45:
case 46: case 46:
case 47: case 47:
ty->state.att.bg256 = 0; ty->termstate.att.bg256 = 0;
ty->state.att.bg = (arg - 40) + COL_BLACK; ty->termstate.att.bg = (arg - 40) + COL_BLACK;
ty->state.att.bgintense = 0; ty->termstate.att.bgintense = 0;
break; break;
case 48: // xterm 256 bg color ??? case 48: // xterm 256 bg color ???
// now check if next arg is 5 // now check if next arg is 5
@ -508,16 +505,16 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
if (!b) ERR("Failed xterm 256 color bg esc val"); if (!b) ERR("Failed xterm 256 color bg esc val");
else else
{ {
ty->state.att.bg256 = 1; ty->termstate.att.bg256 = 1;
ty->state.att.bg = arg; ty->termstate.att.bg = arg;
} }
} }
ty->state.att.bgintense = 0; ty->termstate.att.bgintense = 0;
break; break;
case 49: // default bg color case 49: // default bg color
ty->state.att.bg256 = 0; ty->termstate.att.bg256 = 0;
ty->state.att.bg = COL_DEF; ty->termstate.att.bg = COL_DEF;
ty->state.att.bgintense = 0; ty->termstate.att.bgintense = 0;
break; break;
case 90: // fg case 90: // fg
case 91: case 91:
@ -527,9 +524,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
case 95: case 95:
case 96: case 96:
case 97: case 97:
ty->state.att.fg256 = 0; ty->termstate.att.fg256 = 0;
ty->state.att.fg = (arg - 90) + COL_BLACK; ty->termstate.att.fg = (arg - 90) + COL_BLACK;
ty->state.att.fgintense = 1; ty->termstate.att.fgintense = 1;
break; break;
case 98: // xterm 256 fg color ??? case 98: // xterm 256 fg color ???
// now check if next arg is 5 // now check if next arg is 5
@ -542,16 +539,16 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
if (!b) ERR("Failed xterm 256 color fg esc val"); if (!b) ERR("Failed xterm 256 color fg esc val");
else else
{ {
ty->state.att.fg256 = 1; ty->termstate.att.fg256 = 1;
ty->state.att.fg = arg; ty->termstate.att.fg = arg;
} }
} }
ty->state.att.fgintense = 1; ty->termstate.att.fgintense = 1;
break; break;
case 99: // default fg color case 99: // default fg color
ty->state.att.fg256 = 0; ty->termstate.att.fg256 = 0;
ty->state.att.fg = COL_DEF; ty->termstate.att.fg = COL_DEF;
ty->state.att.fgintense = 1; ty->termstate.att.fgintense = 1;
break; break;
case 100: // bg case 100: // bg
case 101: case 101:
@ -561,9 +558,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
case 105: case 105:
case 106: case 106:
case 107: case 107:
ty->state.att.bg256 = 0; ty->termstate.att.bg256 = 0;
ty->state.att.bg = (arg - 100) + COL_BLACK; ty->termstate.att.bg = (arg - 100) + COL_BLACK;
ty->state.att.bgintense = 1; ty->termstate.att.bgintense = 1;
break; break;
case 108: // xterm 256 bg color ??? case 108: // xterm 256 bg color ???
// now check if next arg is 5 // now check if next arg is 5
@ -576,16 +573,16 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
if (!b) ERR("Failed xterm 256 color bg esc val"); if (!b) ERR("Failed xterm 256 color bg esc val");
else else
{ {
ty->state.att.bg256 = 1; ty->termstate.att.bg256 = 1;
ty->state.att.bg = arg; ty->termstate.att.bg = arg;
} }
} }
ty->state.att.bgintense = 1; ty->termstate.att.bgintense = 1;
break; break;
case 109: // default bg color case 109: // default bg color
ty->state.att.bg256 = 0; ty->termstate.att.bg256 = 0;
ty->state.att.bg = COL_DEF; ty->termstate.att.bg = COL_DEF;
ty->state.att.bgintense = 1; ty->termstate.att.bgintense = 1;
break; break;
default: // not handled??? default: // not handled???
ERR("Unhandled color cmd [%i]", arg); ERR("Unhandled color cmd [%i]", arg);
@ -614,7 +611,7 @@ _handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
{ {
case 6: case 6:
len = snprintf(bf, sizeof(bf), "\033[?%d;%d;1R", len = snprintf(bf, sizeof(bf), "\033[?%d;%d;1R",
ty->state.cy + 1, ty->state.cx + 1); ty->cursor_state.cy + 1, ty->cursor_state.cx + 1);
termpty_write(ty, bf, len); termpty_write(ty, bf, len);
break; break;
default: default:
@ -629,7 +626,7 @@ _handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
{ {
case 6: case 6:
len = snprintf(bf, sizeof(bf), "\033[%d;%dR", len = snprintf(bf, sizeof(bf), "\033[%d;%dR",
ty->state.cy + 1, ty->state.cx + 1); ty->cursor_state.cy + 1, ty->cursor_state.cx + 1);
termpty_write(ty, bf, len); termpty_write(ty, bf, len);
break; break;
default: default:
@ -675,16 +672,16 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("insert %d blank chars", arg); DBG("insert %d blank chars", arg);
{ {
int pi = ty->state.insert; int pi = ty->termstate.insert;
Eina_Unicode blank[1] = { ' ' }; Eina_Unicode blank[1] = { ' ' };
int cx = ty->state.cx; int cx = ty->cursor_state.cx;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.insert = 1; ty->termstate.insert = 1;
for (i = 0; i < arg; i++) for (i = 0; i < arg; i++)
_termpty_text_append(ty, blank, 1); _termpty_text_append(ty, blank, 1);
ty->state.insert = pi; ty->termstate.insert = pi;
ty->state.cx = cx; ty->cursor_state.cx = cx;
} }
break; break;
case 'A': // cursor up N case 'A': // cursor up N
@ -692,25 +689,25 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("cursor up %d", arg); DBG("cursor up %d", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy = MAX(0, ty->state.cy - arg); ty->cursor_state.cy = MAX(0, ty->cursor_state.cy - arg);
break; break;
case 'B': // cursor down N case 'B': // cursor down N
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("cursor down %d", arg); DBG("cursor down %d", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy = MIN(ty->h - 1, ty->state.cy + arg); ty->cursor_state.cy = MIN(ty->h - 1, ty->cursor_state.cy + arg);
break; break;
case 'D': // cursor left N case 'D': // cursor left N
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("cursor left %d", arg); DBG("cursor left %d", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
for (i = 0; i < arg; i++) for (i = 0; i < arg; i++)
{ {
ty->state.cx--; ty->cursor_state.cx--;
if (ty->state.cx < 0) ty->state.cx = 0; if (ty->cursor_state.cx < 0) ty->cursor_state.cx = 0;
} }
break; break;
case 'C': // cursor right N case 'C': // cursor right N
@ -718,21 +715,21 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("cursor right %d", arg); DBG("cursor right %d", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
for (i = 0; i < arg; i++) for (i = 0; i < arg; i++)
{ {
ty->state.cx++; ty->cursor_state.cx++;
if (ty->state.cx >= ty->w) ty->state.cx = ty->w - 1; if (ty->cursor_state.cx >= ty->w) ty->cursor_state.cx = ty->w - 1;
} }
break; break;
case 'H': // cursor pos set case 'H': // cursor pos set
case 'f': // cursor pos set case 'f': // cursor pos set
DBG("cursor pos set"); DBG("cursor pos set");
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
if (!*b) if (!*b)
{ {
ty->state.cx = 0; ty->cursor_state.cx = 0;
ty->state.cy = 0; ty->cursor_state.cy = 0;
} }
else else
{ {
@ -742,7 +739,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (arg >= ty->h) arg = ty->h - 1; if (arg >= ty->h) arg = ty->h - 1;
if (b) if (b)
{ {
ty->state.cy = arg; ty->cursor_state.cy = arg;
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
arg--; arg--;
@ -750,47 +747,47 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
else arg = 0; else arg = 0;
if (arg >= ty->w) arg = ty->w - 1; if (arg >= ty->w) arg = ty->w - 1;
if (b) ty->state.cx = arg; if (b) ty->cursor_state.cx = arg;
} }
ty->state.cy += ty->state.margin_top; ty->cursor_state.cy += ty->termstate.margin_top;
break; break;
case 'G': // to column N case 'G': // to column N
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("to column %d", arg); DBG("to column %d", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cx = arg - 1; ty->cursor_state.cx = arg - 1;
if (ty->state.cx < 0) ty->state.cx = 0; if (ty->cursor_state.cx < 0) ty->cursor_state.cx = 0;
else if (ty->state.cx >= ty->w) ty->state.cx = ty->w - 1; else if (ty->cursor_state.cx >= ty->w) ty->cursor_state.cx = ty->w - 1;
break; break;
case 'd': // to row N case 'd': // to row N
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("to row %d", arg); DBG("to row %d", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy = arg - 1; ty->cursor_state.cy = arg - 1;
if (ty->state.cy < 0) ty->state.cy = 0; if (ty->cursor_state.cy < 0) ty->cursor_state.cy = 0;
else if (ty->state.cy >= ty->h) ty->state.cy = ty->h - 1; else if (ty->cursor_state.cy >= ty->h) ty->cursor_state.cy = ty->h - 1;
break; break;
case 'E': // down relative N rows, and to col 0 case 'E': // down relative N rows, and to col 0
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("down relative %d rows, and to col 0", arg); DBG("down relative %d rows, and to col 0", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy += arg; ty->cursor_state.cy += arg;
if (ty->state.cy < 0) ty->state.cy = 0; if (ty->cursor_state.cy < 0) ty->cursor_state.cy = 0;
else if (ty->state.cy >= ty->h) ty->state.cy = ty->h - 1; else if (ty->cursor_state.cy >= ty->h) ty->cursor_state.cy = ty->h - 1;
ty->state.cx = 0; ty->cursor_state.cx = 0;
break; break;
case 'F': // up relative N rows, and to col 0 case 'F': // up relative N rows, and to col 0
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
DBG("up relative %d rows, and to col 0", arg); DBG("up relative %d rows, and to col 0", arg);
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy -= arg; ty->cursor_state.cy -= arg;
if (ty->state.cy < 0) ty->state.cy = 0; if (ty->cursor_state.cy < 0) ty->cursor_state.cy = 0;
else if (ty->state.cy >= ty->h) ty->state.cy = ty->h - 1; else if (ty->cursor_state.cy >= ty->h) ty->cursor_state.cy = ty->h - 1;
ty->state.cx = 0; ty->cursor_state.cx = 0;
break; break;
case 'X': // erase N chars case 'X': // erase N chars
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
@ -818,26 +815,26 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
{ {
int sy1, sy2; int sy1, sy2;
sy1 = ty->state.scroll_y1; sy1 = ty->termstate.scroll_y1;
sy2 = ty->state.scroll_y2; sy2 = ty->termstate.scroll_y2;
if (ty->state.scroll_y2 == 0) if (ty->termstate.scroll_y2 == 0)
{ {
ty->state.scroll_y1 = ty->state.cy; ty->termstate.scroll_y1 = ty->cursor_state.cy;
ty->state.scroll_y2 = ty->h; ty->termstate.scroll_y2 = ty->h;
} }
else else
{ {
ty->state.scroll_y1 = ty->state.cy; ty->termstate.scroll_y1 = ty->cursor_state.cy;
if (ty->state.scroll_y2 <= ty->state.scroll_y1) if (ty->termstate.scroll_y2 <= ty->termstate.scroll_y1)
ty->state.scroll_y2 = ty->state.scroll_y1 + 1; ty->termstate.scroll_y2 = ty->termstate.scroll_y1 + 1;
} }
for (i = 0; i < arg; i++) for (i = 0; i < arg; i++)
{ {
if (*cc == 'M') _termpty_text_scroll(ty, EINA_TRUE); if (*cc == 'M') _termpty_text_scroll(ty, EINA_TRUE);
else _termpty_text_scroll_rev(ty, EINA_TRUE); else _termpty_text_scroll_rev(ty, EINA_TRUE);
} }
ty->state.scroll_y1 = sy1; ty->termstate.scroll_y1 = sy1;
ty->state.scroll_y2 = sy2; ty->termstate.scroll_y2 = sy2;
} }
break; break;
case 'P': // erase and scrollback N chars case 'P': // erase and scrollback N chars
@ -848,9 +845,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
Termcell *cells; Termcell *cells;
int x, lim; int x, lim;
cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy)); cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
lim = ty->w - arg; lim = ty->w - arg;
for (x = ty->state.cx; x < (ty->w); x++) for (x = ty->cursor_state.cx; x < (ty->w); x++)
{ {
if (x < lim) if (x < lim)
termpty_cell_copy(ty, &(cells[x + arg]), &(cells[x]), 1); termpty_cell_copy(ty, &(cells[x + arg]), &(cells[x]), 1);
@ -929,8 +926,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (!b) if (!b)
{ {
WRN("no region args reset region"); WRN("no region args reset region");
ty->state.scroll_y1 = 0; ty->termstate.scroll_y1 = 0;
ty->state.scroll_y2 = 0; ty->termstate.scroll_y2 = 0;
} }
else else
{ {
@ -940,16 +937,16 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (!b) if (!b)
{ {
WRN("failed to give 2 regions args reset region"); WRN("failed to give 2 regions args reset region");
ty->state.scroll_y1 = 0; ty->termstate.scroll_y1 = 0;
ty->state.scroll_y2 = 0; ty->termstate.scroll_y2 = 0;
} }
else else
{ {
if (arg > arg2) if (arg > arg2)
{ {
DBG("scroll region beginning > end [%i %i]", arg, arg2); DBG("scroll region beginning > end [%i %i]", arg, arg2);
ty->state.scroll_y1 = 0; ty->termstate.scroll_y1 = 0;
ty->state.scroll_y2 = 0; ty->termstate.scroll_y2 = 0;
} }
else else
{ {
@ -957,19 +954,19 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (arg >= ty->h) arg = ty->h - 1; if (arg >= ty->h) arg = ty->h - 1;
if (arg == 0) arg = 1; if (arg == 0) arg = 1;
if (arg2 > ty->h) arg2 = ty->h; if (arg2 > ty->h) arg2 = ty->h;
ty->state.scroll_y1 = arg - 1; ty->termstate.scroll_y1 = arg - 1;
ty->state.scroll_y2 = arg2; ty->termstate.scroll_y2 = arg2;
if ((arg == 1) && (arg2 == ty->h)) if ((arg == 1) && (arg2 == ty->h))
ty->state.scroll_y2 = 0; ty->termstate.scroll_y2 = 0;
} }
} }
} }
break; break;
case 's': // store cursor pos case 's': // store cursor pos
_termpty_cursor_copy(&(ty->state), &(ty->save)); _termpty_cursor_copy(ty, EINA_TRUE);
break; break;
case 'u': // restore cursor pos case 'u': // restore cursor pos
_termpty_cursor_copy(&(ty->save), &(ty->state)); _termpty_cursor_copy(ty, EINA_FALSE);
break; break;
case 'p': // define key assignments based on keycode case 'p': // define key assignments based on keycode
if (b && *b == '!') if (b && *b == '!')
@ -1007,7 +1004,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
break; break;
case 'Z': // Cursor Back Tab case 'Z': // Cursor Back Tab
{ {
int idx, size, cx = ty->state.cx, cy = ty->state.cy; int idx, size, cx = ty->cursor_state.cx, cy = ty->cursor_state.cy;
arg = _csi_arg_get(&b); arg = _csi_arg_get(&b);
if (arg < 1) arg = 1; if (arg < 1) arg = 1;
@ -1026,8 +1023,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
} }
if (!arg) if (!arg)
{ {
ty->state.cx = cx; ty->cursor_state.cx = cx;
ty->state.cy = cy; ty->cursor_state.cy = cy;
} }
} }
break; break;
@ -1559,25 +1556,25 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (len == 0) return 0; if (len == 0) return 0;
return 1 + len; return 1 + len;
case '=': // set alternate keypad mode case '=': // set alternate keypad mode
ty->state.alt_kp = 1; ty->termstate.alt_kp = 1;
return 1; return 1;
case '>': // set numeric keypad mode case '>': // set numeric keypad mode
ty->state.alt_kp = 0; ty->termstate.alt_kp = 0;
return 1; return 1;
case 'M': // move to prev line case 'M': // move to prev line
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy--; ty->cursor_state.cy--;
_termpty_text_scroll_rev_test(ty, EINA_TRUE); _termpty_text_scroll_rev_test(ty, EINA_TRUE);
return 1; return 1;
case 'D': // move to next line case 'D': // move to next line
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cy++; ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_FALSE); _termpty_text_scroll_test(ty, EINA_FALSE);
return 1; return 1;
case 'E': // add \n\r case 'E': // add \n\r
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cx = 0; ty->cursor_state.cx = 0;
ty->state.cy++; ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_FALSE); _termpty_text_scroll_test(ty, EINA_FALSE);
return 1; return 1;
case 'Z': // same a 'ESC [ Pn c' case 'Z': // same a 'ESC [ Pn c'
@ -1592,29 +1589,29 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
return 1; return 1;
case '(': // charset 0 case '(': // charset 0
if (len < 2) return 0; if (len < 2) return 0;
ty->state.chset[0] = c[1]; ty->termstate.chset[0] = c[1];
ty->state.multibyte = 0; ty->termstate.multibyte = 0;
ty->state.charsetch = c[1]; ty->termstate.charsetch = c[1];
return 2; return 2;
case ')': // charset 1 case ')': // charset 1
if (len < 2) return 0; if (len < 2) return 0;
ty->state.chset[1] = c[1]; ty->termstate.chset[1] = c[1];
ty->state.multibyte = 0; ty->termstate.multibyte = 0;
return 2; return 2;
case '*': // charset 2 case '*': // charset 2
if (len < 2) return 0; if (len < 2) return 0;
ty->state.chset[2] = c[1]; ty->termstate.chset[2] = c[1];
ty->state.multibyte = 0; ty->termstate.multibyte = 0;
return 2; return 2;
case '+': // charset 3 case '+': // charset 3
if (len < 2) return 0; if (len < 2) return 0;
ty->state.chset[3] = c[1]; ty->termstate.chset[3] = c[1];
ty->state.multibyte = 0; ty->termstate.multibyte = 0;
return 2; return 2;
case '$': // charset -2 case '$': // charset -2
if (len < 2) return 0; if (len < 2) return 0;
ty->state.chset[2] = c[1]; ty->termstate.chset[2] = c[1];
ty->state.multibyte = 1; ty->termstate.multibyte = 1;
return 2; return 2;
case '#': // #8 == test mode -> fill screen with "E"; case '#': // #8 == test mode -> fill screen with "E";
if (len < 2) return 0; if (len < 2) return 0;
@ -1625,8 +1622,6 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
DBG("reset to init mode and clear then fill with E"); DBG("reset to init mode and clear then fill with E");
_termpty_reset_state(ty); _termpty_reset_state(ty);
ty->save = ty->state;
ty->swap = ty->state;
_termpty_clear_screen(ty, TERMPTY_CLR_ALL); _termpty_clear_screen(ty, TERMPTY_CLR_ALL);
if (ty->cb.cancel_sel.func) if (ty->cb.cancel_sel.func)
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data); ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
@ -1635,7 +1630,7 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (cells) if (cells)
{ {
Termatt att; Termatt att;
memset((&att), 0, sizeof(att)); memset((&att), 0, sizeof(att));
termpty_cell_codepoint_att_fill(ty, 'E', att, cells, size); termpty_cell_codepoint_att_fill(ty, 'E', att, cells, size);
} }
@ -1645,10 +1640,10 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (len < 2) return 0; if (len < 2) return 0;
return 2; return 2;
case '7': // save cursor pos case '7': // save cursor pos
_termpty_cursor_copy(&(ty->state), &(ty->save)); _termpty_cursor_copy(ty, EINA_TRUE);
return 1; return 1;
case '8': // restore cursor pos case '8': // restore cursor pos
_termpty_cursor_copy(&(ty->save), &(ty->state)); _termpty_cursor_copy(ty, EINA_FALSE);
return 1; return 1;
case 'H': // set tab at current column case 'H': // set tab at current column
DBG("Character Tabulation Set (HTS)"); DBG("Character Tabulation Set (HTS)");
@ -1706,7 +1701,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
/* /*
case 0x05: // ENQ (enquiry) case 0x05: // ENQ (enquiry)
_term_txt_write(ty, "ABC\r\n"); _term_txt_write(ty, "ABC\r\n");
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
return 1; return 1;
*/ */
/* /*
@ -1724,14 +1719,14 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
return 1; return 1;
case 0x0e: // SO (shift out) // Maps G1 character set into GL. case 0x0e: // SO (shift out) // Maps G1 character set into GL.
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
ty->state.charset = 1; ty->termstate.charset = 1;
ty->state.charsetch = ty->state.chset[1]; ty->termstate.charsetch = ty->termstate.chset[1];
return 1; return 1;
case 0x0f: // SI (shift in) // Maps G0 character set into GL. case 0x0f: // SI (shift in) // Maps G0 character set into GL.
ty->state.charset = 0; ty->termstate.charset = 0;
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
ty->state.charsetch = ty->state.chset[0]; ty->termstate.charsetch = ty->termstate.chset[0];
return 1; return 1;
/* /*
case 0x10: // DLE (data link escape) case 0x10: // DLE (data link escape)
@ -1758,7 +1753,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
return 1; return 1;
*/ */
case 0x1b: // ESC (escape) case 0x1b: // ESC (escape)
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
len = _handle_esc(ty, c + 1, ce); len = _handle_esc(ty, c + 1, ce);
if (len == 0) return 0; if (len == 0) return 0;
return 1 + len; return 1 + len;
@ -1773,20 +1768,20 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
return 1; return 1;
*/ */
default: default:
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
//ERR("unhandled char 0x%02x", c[0]); //ERR("unhandled char 0x%02x", c[0]);
return 1; return 1;
} }
} }
else if (c[0] == 0x7f) // DEL else if (c[0] == 0x7f) // DEL
{ {
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
ERR("Unhandled char 0x%02x [DEL]", (unsigned int) c[0]); ERR("Unhandled char 0x%02x [DEL]", (unsigned int) c[0]);
return 1; return 1;
} }
else if (c[0] == 0x9b) // ANSI ESC!!! else if (c[0] == 0x9b) // ANSI ESC!!!
{ {
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
DBG("ANSI CSI!!!!!"); DBG("ANSI CSI!!!!!");
len = _handle_esc_csi(ty, c + 1, ce); len = _handle_esc_csi(ty, c + 1, ce);
if (len == 0) return 0; if (len == 0) return 0;
@ -1797,7 +1792,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
Termexp *ex; Termexp *ex;
Eina_List *l; Eina_List *l;
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
EINA_LIST_FOREACH(ty->block.expecting, l, ex) EINA_LIST_FOREACH(ty->block.expecting, l, ex)
{ {
if (c[0] == ex->ch) if (c[0] == ex->ch)
@ -1831,7 +1826,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
} }
else else
{ {
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
} }
cc = (Eina_Unicode *)c; cc = (Eina_Unicode *)c;
DBG("txt: ["); DBG("txt: [");
@ -1843,6 +1838,6 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
} }
DBG("]"); DBG("]");
_termpty_text_append(ty, c, len); _termpty_text_append(ty, c, len);
ty->state.had_cr = 0; ty->termstate.had_cr = 0;
return len; return len;
} }

View File

@ -34,9 +34,9 @@ static const unsigned short vt100_to_unicode[62] =
}; };
Eina_Unicode Eina_Unicode
_termpty_charset_trans(Eina_Unicode g, Termstate *state) _termpty_charset_trans(Eina_Unicode g, Termpty *ty)
{ {
switch (state->charsetch) switch (ty->termstate.charsetch)
{ {
case '0': /* DEC Special Character & Line Drawing Set */ case '0': /* DEC Special Character & Line Drawing Set */
if ((g >= 0x41) && (g <= 0x7e) && if ((g >= 0x41) && (g <= 0x7e) &&
@ -49,7 +49,7 @@ _termpty_charset_trans(Eina_Unicode g, Termstate *state)
default: default:
break; break;
} }
if (state->att.fraktur) if (ty->termstate.att.fraktur)
{ {
if (g >= 'a' && g <= 'z') if (g >= 'a' && g <= 'z')
{ {

View File

@ -3,6 +3,6 @@
#include "termpty.h" #include "termpty.h"
Eina_Unicode _termpty_charset_trans(Eina_Unicode g, Termstate *state); Eina_Unicode _termpty_charset_trans(Eina_Unicode g, Termpty *ty);
#endif #endif

View File

@ -27,7 +27,7 @@ _text_clear(Termpty *ty, Termcell *cells, int count, int val, Eina_Bool inherit_
memset(&src, 0, sizeof(src)); memset(&src, 0, sizeof(src));
src.codepoint = val; src.codepoint = val;
if (inherit_att) src.att = ty->state.att; if (inherit_att) src.att = ty->termstate.att;
termpty_cell_fill(ty, &src, cells, count); termpty_cell_fill(ty, &src, cells, count);
} }
@ -65,10 +65,10 @@ _termpty_text_scroll(Termpty *ty, Eina_Bool clear)
Termcell *cells = NULL, *cells2; Termcell *cells = NULL, *cells2;
int y, start_y = 0, end_y = ty->h - 1; int y, start_y = 0, end_y = ty->h - 1;
if (ty->state.scroll_y2 != 0) if (ty->termstate.scroll_y2 != 0)
{ {
start_y = ty->state.scroll_y1; start_y = ty->termstate.scroll_y1;
end_y = ty->state.scroll_y2 - 1; end_y = ty->termstate.scroll_y2 - 1;
} }
else else
if (!ty->altbuf) if (!ty->altbuf)
@ -108,10 +108,10 @@ _termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
Termcell *cells, *cells2 = NULL; Termcell *cells, *cells2 = NULL;
int y, start_y = 0, end_y = ty->h - 1; int y, start_y = 0, end_y = ty->h - 1;
if (ty->state.scroll_y2 != 0) if (ty->termstate.scroll_y2 != 0)
{ {
start_y = ty->state.scroll_y1; start_y = ty->termstate.scroll_y1;
end_y = ty->state.scroll_y2 - 1; end_y = ty->termstate.scroll_y2 - 1;
} }
DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y); DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y);
termio_scroll(ty->obj, 1, start_y, end_y); termio_scroll(ty->obj, 1, start_y, end_y);
@ -146,11 +146,11 @@ _termpty_text_scroll_test(Termpty *ty, Eina_Bool clear)
{ {
int e = ty->h; int e = ty->h;
if (ty->state.scroll_y2 != 0) e = ty->state.scroll_y2; if (ty->termstate.scroll_y2 != 0) e = ty->termstate.scroll_y2;
if (ty->state.cy >= e) if (ty->cursor_state.cy >= e)
{ {
_termpty_text_scroll(ty, clear); _termpty_text_scroll(ty, clear);
ty->state.cy = e - 1; ty->cursor_state.cy = e - 1;
} }
} }
@ -159,11 +159,11 @@ _termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear)
{ {
int b = 0; int b = 0;
if (ty->state.scroll_y1 != 0) b = ty->state.scroll_y1; if (ty->termstate.scroll_y1 != 0) b = ty->termstate.scroll_y1;
if (ty->state.cy < b) if (ty->cursor_state.cy < b)
{ {
_termpty_text_scroll_rev(ty, clear); _termpty_text_scroll_rev(ty, clear);
ty->state.cy = b; ty->cursor_state.cy = b;
} }
} }
@ -173,66 +173,68 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
Termcell *cells; Termcell *cells;
int i, j; int i, j;
termio_content_change(ty->obj, ty->state.cx, ty->state.cy, len); termio_content_change(ty->obj, ty->cursor_state.cx, ty->cursor_state.cy, len);
cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy)); cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
Eina_Unicode g; Eina_Unicode g;
if (ty->state.wrapnext) if (ty->termstate.wrapnext)
{ {
cells[ty->w - 1].att.autowrapped = 1; cells[ty->w - 1].att.autowrapped = 1;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.cx = 0; ty->cursor_state.cx = 0;
ty->state.cy++; ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_TRUE); _termpty_text_scroll_test(ty, EINA_TRUE);
cells = &(TERMPTY_SCREEN(ty, 0, ty->state.cy)); cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
} }
if (ty->state.insert) if (ty->termstate.insert)
{ {
for (j = ty->w - 1; j > ty->state.cx; j--) for (j = ty->w - 1; j > ty->cursor_state.cx; j--)
termpty_cell_copy(ty, &(cells[j - 1]), &(cells[j]), 1); termpty_cell_copy(ty, &(cells[j - 1]), &(cells[j]), 1);
} }
g = _termpty_charset_trans(codepoints[i], &ty->state); g = _termpty_charset_trans(codepoints[i], ty);
termpty_cell_codepoint_att_fill(ty, g, ty->state.att, termpty_cell_codepoint_att_fill(ty, g, ty->termstate.att,
&(cells[ty->state.cx]), 1); &(cells[ty->cursor_state.cx]), 1);
#if defined(SUPPORT_DBLWIDTH) #if defined(SUPPORT_DBLWIDTH)
cells[ty->state.cx].att.dblwidth = _termpty_is_dblwidth_get(ty, g); cells[ty->cursor_state.cx].att.dblwidth = _termpty_is_dblwidth_get(ty, g);
if (EINA_UNLIKELY((cells[ty->state.cx].att.dblwidth) && (ty->state.cx < (ty->w - 1)))) if (EINA_UNLIKELY((cells[ty->cursor_state.cx].att.dblwidth) && (ty->cursor_state.cx < (ty->w - 1))))
{ {
TERMPTY_FMTCLR(cells[ty->state.cx].att); TERMPTY_FMTCLR(cells[ty->cursor_state.cx].att);
termpty_cell_codepoint_att_fill(ty, 0, cells[ty->state.cx].att, termpty_cell_codepoint_att_fill(ty, 0, cells[ty->cursor_state.cx].att,
&(cells[ty->state.cx + 1]), 1); &(cells[ty->cursor_state.cx + 1]), 1);
} }
#endif #endif
if (ty->state.wrap) if (ty->termstate.wrap)
{ {
unsigned char offset = 1; unsigned char offset = 1;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
#if defined(SUPPORT_DBLWIDTH) #if defined(SUPPORT_DBLWIDTH)
if (EINA_UNLIKELY(cells[ty->state.cx].att.dblwidth)) if (EINA_UNLIKELY(cells[ty->cursor_state.cx].att.dblwidth))
offset = 2; offset = 2;
#endif #endif
if (EINA_UNLIKELY(ty->state.cx >= (ty->w - offset))) ty->state.wrapnext = 1; if (EINA_UNLIKELY(ty->cursor_state.cx >= (ty->w - offset)))
else ty->state.cx += offset; ty->termstate.wrapnext = 1;
else
ty->cursor_state.cx += offset;
} }
else else
{ {
unsigned char offset = 1; unsigned char offset = 1;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
#if defined(SUPPORT_DBLWIDTH) #if defined(SUPPORT_DBLWIDTH)
if (EINA_UNLIKELY(cells[ty->state.cx].att.dblwidth)) if (EINA_UNLIKELY(cells[ty->cursor_state.cx].att.dblwidth))
offset = 2; offset = 2;
#endif #endif
ty->state.cx += offset; ty->cursor_state.cx += offset;
if (ty->state.cx > (ty->w - offset)) if (ty->cursor_state.cx > (ty->w - offset))
{ {
ty->state.cx = ty->w - offset; ty->cursor_state.cx = ty->w - offset;
return; return;
} }
} }
@ -244,16 +246,16 @@ _termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit)
{ {
Termcell *cells; Termcell *cells;
int n = 0; int n = 0;
Evas_Coord x = 0, y = ty->state.cy; Evas_Coord x = 0, y = ty->cursor_state.cy;
switch (mode) switch (mode)
{ {
case TERMPTY_CLR_END: case TERMPTY_CLR_END:
n = ty->w - ty->state.cx; n = ty->w - ty->cursor_state.cx;
x = ty->state.cx; x = ty->cursor_state.cx;
break; break;
case TERMPTY_CLR_BEGIN: case TERMPTY_CLR_BEGIN:
n = ty->state.cx + 1; n = ty->cursor_state.cx + 1;
break; break;
case TERMPTY_CLR_ALL: case TERMPTY_CLR_ALL:
n = ty->w; n = ty->w;
@ -276,33 +278,33 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
{ {
case TERMPTY_CLR_END: case TERMPTY_CLR_END:
_termpty_clear_line(ty, mode, ty->w); _termpty_clear_line(ty, mode, ty->w);
if (ty->state.cy < (ty->h - 1)) if (ty->cursor_state.cy < (ty->h - 1))
{ {
int l = ty->h - (ty->state.cy + 1); int l = ty->h - (ty->cursor_state.cy + 1);
termio_content_change(ty->obj, 0, ty->state.cy, l * ty->w); termio_content_change(ty->obj, 0, ty->cursor_state.cy, l * ty->w);
while (l) while (l)
{ {
cells = &(TERMPTY_SCREEN(ty, 0, (ty->state.cy + l))); cells = &(TERMPTY_SCREEN(ty, 0, (ty->cursor_state.cy + l)));
_text_clear(ty, cells, ty->w, 0, EINA_TRUE); _text_clear(ty, cells, ty->w, 0, EINA_TRUE);
l--; l--;
} }
} }
break; break;
case TERMPTY_CLR_BEGIN: case TERMPTY_CLR_BEGIN:
if (ty->state.cy > 0) if (ty->cursor_state.cy > 0)
{ {
// First clear from circular > height, then from 0 to circular // First clear from circular > height, then from 0 to circular
int y = ty->state.cy + ty->circular_offset; int y = ty->cursor_state.cy + ty->circular_offset;
termio_content_change(ty->obj, 0, 0, ty->state.cy * ty->w); termio_content_change(ty->obj, 0, 0, ty->cursor_state.cy * ty->w);
cells = &(TERMPTY_SCREEN(ty, 0, 0)); cells = &(TERMPTY_SCREEN(ty, 0, 0));
if (y < ty->h) if (y < ty->h)
{ {
_text_clear(ty, cells, ty->w * ty->state.cy, 0, EINA_TRUE); _text_clear(ty, cells, ty->w * ty->cursor_state.cy, 0, EINA_TRUE);
} }
else else
{ {
@ -318,7 +320,7 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
case TERMPTY_CLR_ALL: case TERMPTY_CLR_ALL:
ty->circular_offset = 0; ty->circular_offset = 0;
_text_clear(ty, ty->screen, ty->w * ty->h, 0, EINA_TRUE); _text_clear(ty, ty->screen, ty->w * ty->h, 0, EINA_TRUE);
ty->state.scroll_y2 = 0; ty->termstate.scroll_y2 = 0;
if (ty->cb.cancel_sel.func) if (ty->cb.cancel_sel.func)
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data); ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
break; break;
@ -365,28 +367,32 @@ _termpty_reset_att(Termatt *att)
void void
_termpty_reset_state(Termpty *ty) _termpty_reset_state(Termpty *ty)
{ {
ty->state.cx = 0; ty->cursor_state.cx = 0;
ty->state.cy = 0; ty->cursor_state.cy = 0;
ty->state.scroll_y1 = 0; ty->termstate.scroll_y1 = 0;
ty->state.scroll_y2 = 0; ty->termstate.scroll_y2 = 0;
ty->state.had_cr_x = 0; ty->termstate.had_cr_x = 0;
ty->state.had_cr_y = 0; ty->termstate.had_cr_y = 0;
_termpty_reset_att(&(ty->state.att)); _termpty_reset_att(&(ty->termstate.att));
ty->state.charset = 0; ty->termstate.charset = 0;
ty->state.charsetch = 'B'; ty->termstate.charsetch = 'B';
ty->state.chset[0] = 'B'; ty->termstate.chset[0] = 'B';
ty->state.chset[1] = 'B'; ty->termstate.chset[1] = 'B';
ty->state.chset[2] = 'B'; ty->termstate.chset[2] = 'B';
ty->state.chset[3] = 'B'; ty->termstate.chset[3] = 'B';
ty->state.multibyte = 0; ty->termstate.multibyte = 0;
ty->state.alt_kp = 0; ty->termstate.alt_kp = 0;
ty->state.insert = 0; ty->termstate.insert = 0;
ty->state.appcursor = 0; ty->termstate.appcursor = 0;
ty->state.wrap = 1; ty->termstate.wrap = 1;
ty->state.wrapnext = 0; ty->termstate.wrapnext = 0;
ty->state.hidecursor = 0; ty->termstate.crlf = 0;
ty->state.crlf = 0; ty->termstate.had_cr = 0;
ty->state.had_cr = 0; ty->termstate.send_bs = 0;
ty->termstate.reverse = 0;
ty->termstate.no_autorepeat = 0;
ty->termstate.cjk_ambiguous_wide = 0;
ty->termstate.hide_cursor = 0;
ty->mouse_mode = MOUSE_OFF; ty->mouse_mode = MOUSE_OFF;
ty->mouse_ext = MOUSE_EXT_NONE; ty->mouse_ext = MOUSE_EXT_NONE;
ty->bracketed_paste = 0; ty->bracketed_paste = 0;
@ -410,9 +416,16 @@ _termpty_reset_state(Termpty *ty)
} }
void void
_termpty_cursor_copy(Termstate *state, Termstate *dest) _termpty_cursor_copy(Termpty *ty, Eina_Bool save)
{ {
dest->cx = state->cx; if (save)
dest->cy = state->cy; {
dest->wrapnext = state->wrapnext; ty->cursor_save.cx = ty->cursor_state.cx;
ty->cursor_save.cy = ty->cursor_state.cy;
}
else
{
ty->cursor_state.cx = ty->cursor_save.cx;
ty->cursor_state.cy = ty->cursor_save.cy;
}
} }

View File

@ -20,7 +20,7 @@ void _termpty_clear_screen(Termpty *ty, Termpty_Clear mode);
void _termpty_clear_all(Termpty *ty); void _termpty_clear_all(Termpty *ty);
void _termpty_reset_att(Termatt *att); void _termpty_reset_att(Termatt *att);
void _termpty_reset_state(Termpty *ty); void _termpty_reset_state(Termpty *ty);
void _termpty_cursor_copy(Termstate *state, Termstate *dest); void _termpty_cursor_copy(Termpty *ty, Eina_Bool save);
#define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1) #define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1)