rename a bunch of _termpty_*() to termpty_*()

terminology-0.9
Boris Faure 8 years ago
parent 9ecda225b8
commit c86b35309c
  1. 2
      src/bin/termpty.c
  2. 69
      src/bin/termptyesc.c
  3. 62
      src/bin/termptyops.c
  4. 25
      src/bin/termptyops.h

@ -307,7 +307,7 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
ty->h = h;
ty->backmax = backscroll;
_termpty_reset_state(ty);
termpty_reset_state(ty);
ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h);
if (!ty->screen)

@ -91,7 +91,7 @@ _handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
ty->termstate.wrapnext = 0;
if (ty->termstate.crlf) ty->cursor_state.cx = 0;
ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_TRUE);
termpty_text_scroll_test(ty, EINA_TRUE);
return;
case 0x0d: // CR '\r' (carriage ret)
DBG("->CR");
@ -119,7 +119,7 @@ _switch_to_alternative_screen(Termpty *ty, int mode)
// clear main buf before we swap it back
// into the screen2 save (so save is
// clear)
_termpty_clear_all(ty);
termpty_clear_all(ty);
}
// swap screen content now
if (mode != ty->altbuf)
@ -170,8 +170,8 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
4 + ty->h * h);
termpty_resize(ty, mode ? 132 : 80,
ty->h);
_termpty_reset_state(ty);
_termpty_clear_screen(ty,
termpty_reset_state(ty);
termpty_clear_screen(ty,
TERMPTY_CLR_ALL);
}
#endif
@ -312,7 +312,7 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b)
break;
case 1048:
case 1049:
_termpty_cursor_copy(ty, mode);
termpty_cursor_copy(ty, mode);
if (arg == 1049)
_switch_to_alternative_screen(ty, mode);
break;
@ -378,14 +378,14 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
{
int arg = _csi_arg_get(&b);
if ((first) && (!b))
_termpty_reset_att(&(ty->termstate.att));
termpty_reset_att(&(ty->termstate.att));
else if (b)
{
first = 0;
switch (arg)
{
case 0: // reset to normal
_termpty_reset_att(&(ty->termstate.att));
termpty_reset_att(&(ty->termstate.att));
break;
case 1: // bold/bright
ty->termstate.att.bold = 1;
@ -679,7 +679,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
ty->termstate.wrapnext = 0;
ty->termstate.insert = 1;
for (i = 0; i < arg; i++)
_termpty_text_append(ty, blank, 1);
termpty_text_append(ty, blank, 1);
ty->termstate.insert = pi;
ty->cursor_state.cx = cx;
}
@ -793,19 +793,21 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
arg = _csi_arg_get(&b);
if (arg < 1) arg = 1;
DBG("erase %d chars", arg);
_termpty_clear_line(ty, TERMPTY_CLR_END, arg);
termpty_clear_line(ty, TERMPTY_CLR_END, arg);
break;
case 'S': // scroll up N lines
arg = _csi_arg_get(&b);
if (arg < 1) arg = 1;
DBG("scroll up %d lines", arg);
for (i = 0; i < arg; i++) _termpty_text_scroll(ty, EINA_TRUE);
for (i = 0; i < arg; i++)
termpty_text_scroll(ty, EINA_TRUE);
break;
case 'T': // scroll down N lines
arg = _csi_arg_get(&b);
if (arg < 1) arg = 1;
DBG("scroll down %d lines", arg);
for (i = 0; i < arg; i++) _termpty_text_scroll_rev(ty, EINA_TRUE);
for (i = 0; i < arg; i++)
termpty_text_scroll_rev(ty, EINA_TRUE);
break;
case 'M': // delete N lines - cy
case 'L': // insert N lines - cy
@ -830,8 +832,10 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
}
for (i = 0; i < arg; i++)
{
if (*cc == 'M') _termpty_text_scroll(ty, EINA_TRUE);
else _termpty_text_scroll_rev(ty, EINA_TRUE);
if (*cc == 'M')
termpty_text_scroll(ty, EINA_TRUE);
else
termpty_text_scroll_rev(ty, EINA_TRUE);
}
ty->termstate.scroll_y1 = sy1;
ty->termstate.scroll_y2 = sy2;
@ -899,11 +903,12 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (b)
{
if ((arg >= TERMPTY_CLR_END) && (arg <= TERMPTY_CLR_ALL))
_termpty_clear_screen(ty, arg);
termpty_clear_screen(ty, arg);
else
ERR("invalid clr scr %i", arg);
}
else _termpty_clear_screen(ty, TERMPTY_CLR_END);
else
termpty_clear_screen(ty, TERMPTY_CLR_END);
break;
case 'K': // 0K erase to end of line, 1K erase from screen start to cursor, 2K erase all of line
arg = _csi_arg_get(&b);
@ -911,11 +916,11 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (b)
{
if ((arg >= TERMPTY_CLR_END) && (arg <= TERMPTY_CLR_ALL))
_termpty_clear_line(ty, arg, ty->w);
termpty_clear_line(ty, arg, ty->w);
else
ERR("invalid clr lin %i", arg);
}
else _termpty_clear_line(ty, TERMPTY_CLR_END, ty->w);
else termpty_clear_line(ty, TERMPTY_CLR_END, ty->w);
break;
case 'h':
case 'l':
@ -963,16 +968,16 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
}
break;
case 's': // store cursor pos
_termpty_cursor_copy(ty, EINA_TRUE);
termpty_cursor_copy(ty, EINA_TRUE);
break;
case 'u': // restore cursor pos
_termpty_cursor_copy(ty, EINA_FALSE);
termpty_cursor_copy(ty, EINA_FALSE);
break;
case 'p': // define key assignments based on keycode
if (b && *b == '!')
{
DBG("soft reset (DECSTR)");
_termpty_reset_state(ty);
termpty_reset_state(ty);
}
else
{
@ -1564,26 +1569,26 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
case 'M': // move to prev line
ty->termstate.wrapnext = 0;
ty->cursor_state.cy--;
_termpty_text_scroll_rev_test(ty, EINA_TRUE);
termpty_text_scroll_rev_test(ty, EINA_TRUE);
return 1;
case 'D': // move to next line
ty->termstate.wrapnext = 0;
ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_FALSE);
termpty_text_scroll_test(ty, EINA_FALSE);
return 1;
case 'E': // add \n\r
ty->termstate.wrapnext = 0;
ty->cursor_state.cx = 0;
ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_FALSE);
termpty_text_scroll_test(ty, EINA_FALSE);
return 1;
case 'Z': // same a 'ESC [ Pn c'
_term_txt_write(ty, "\033[?1;2C");
return 1;
case 'c': // reset terminal to initial state
DBG("reset to init mode and clear");
_termpty_reset_state(ty);
_termpty_clear_screen(ty, TERMPTY_CLR_ALL);
termpty_reset_state(ty);
termpty_clear_screen(ty, TERMPTY_CLR_ALL);
if (ty->cb.cancel_sel.func)
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
return 1;
@ -1621,8 +1626,8 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
Termcell *cells;
DBG("reset to init mode and clear then fill with E");
_termpty_reset_state(ty);
_termpty_clear_screen(ty, TERMPTY_CLR_ALL);
termpty_reset_state(ty);
termpty_clear_screen(ty, TERMPTY_CLR_ALL);
if (ty->cb.cancel_sel.func)
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
cells = ty->screen;
@ -1640,10 +1645,10 @@ _handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if (len < 2) return 0;
return 2;
case '7': // save cursor pos
_termpty_cursor_copy(ty, EINA_TRUE);
termpty_cursor_copy(ty, EINA_TRUE);
return 1;
case '8': // restore cursor pos
_termpty_cursor_copy(ty, EINA_FALSE);
termpty_cursor_copy(ty, EINA_FALSE);
return 1;
case 'H': // set tab at current column
DBG("Character Tabulation Set (HTS)");
@ -1808,7 +1813,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
ex->y++;
}
ex->left--;
_termpty_text_append(ty, &cp, 1);
termpty_text_append(ty, &cp, 1);
if (ex->left <= 0)
{
ty->block.expecting =
@ -1821,7 +1826,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
return 1;
}
}
_termpty_text_append(ty, c, 1);
termpty_text_append(ty, c, 1);
return 1;
}
else
@ -1837,7 +1842,7 @@ termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
len++;
}
DBG("]");
_termpty_text_append(ty, c, len);
termpty_text_append(ty, c, len);
ty->termstate.had_cr = 0;
return len;
}

@ -20,14 +20,14 @@
#define INF(...) EINA_LOG_DOM_INFO(_termpty_log_dom, __VA_ARGS__)
#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
static void
_text_clear(Termpty *ty, Termcell *cells, int count, int val, Eina_Bool inherit_att)
void
termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
{
Termcell src;
memset(&src, 0, sizeof(src));
src.codepoint = val;
if (inherit_att) src.att = ty->termstate.att;
src.codepoint = 0;
src.att = ty->termstate.att;
termpty_cell_fill(ty, &src, cells, count);
}
@ -60,7 +60,7 @@ termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max)
}
void
_termpty_text_scroll(Termpty *ty, Eina_Bool clear)
termpty_text_scroll(Termpty *ty, Eina_Bool clear)
{
Termcell *cells = NULL, *cells2;
int y, start_y = 0, end_y = ty->h - 1;
@ -82,7 +82,7 @@ _termpty_text_scroll(Termpty *ty, Eina_Bool clear)
// screen is a circular buffer now
cells = &(ty->screen[ty->circular_offset * ty->w]);
if (clear)
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w);
ty->circular_offset++;
if (ty->circular_offset >= ty->h)
@ -98,12 +98,12 @@ _termpty_text_scroll(Termpty *ty, Eina_Bool clear)
termpty_cell_copy(ty, cells, cells2, ty->w);
}
if (clear)
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w);
}
}
void
_termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
{
Termcell *cells, *cells2 = NULL;
int y, start_y = 0, end_y = ty->h - 1;
@ -125,7 +125,7 @@ _termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
cells = &(ty->screen[ty->circular_offset * ty->w]);
if (clear)
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w);
}
else
{
@ -137,38 +137,38 @@ _termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
termpty_cell_copy(ty, cells, cells2, ty->w);
}
if (clear)
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w);
}
}
void
_termpty_text_scroll_test(Termpty *ty, Eina_Bool clear)
termpty_text_scroll_test(Termpty *ty, Eina_Bool clear)
{
int e = ty->h;
if (ty->termstate.scroll_y2 != 0) e = ty->termstate.scroll_y2;
if (ty->cursor_state.cy >= e)
{
_termpty_text_scroll(ty, clear);
termpty_text_scroll(ty, clear);
ty->cursor_state.cy = e - 1;
}
}
void
_termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear)
termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear)
{
int b = 0;
if (ty->termstate.scroll_y1 != 0) b = ty->termstate.scroll_y1;
if (ty->cursor_state.cy < b)
{
_termpty_text_scroll_rev(ty, clear);
termpty_text_scroll_rev(ty, clear);
ty->cursor_state.cy = b;
}
}
void
_termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
{
Termcell *cells;
int i, j;
@ -186,7 +186,7 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
ty->termstate.wrapnext = 0;
ty->cursor_state.cx = 0;
ty->cursor_state.cy++;
_termpty_text_scroll_test(ty, EINA_TRUE);
termpty_text_scroll_test(ty, EINA_TRUE);
cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
}
if (ty->termstate.insert)
@ -242,7 +242,7 @@ _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
}
void
_termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit)
termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit)
{
Termcell *cells;
int n = 0;
@ -266,18 +266,18 @@ _termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit)
cells = &(TERMPTY_SCREEN(ty, x, y));
if (n > limit) n = limit;
termio_content_change(ty->obj, x, y, n);
_text_clear(ty, cells, n, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, n);
}
void
_termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
{
Termcell *cells;
switch (mode)
{
case TERMPTY_CLR_END:
_termpty_clear_line(ty, mode, ty->w);
termpty_clear_line(ty, mode, ty->w);
if (ty->cursor_state.cy < (ty->h - 1))
{
int l = ty->h - (ty->cursor_state.cy + 1);
@ -287,7 +287,7 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
while (l)
{
cells = &(TERMPTY_SCREEN(ty, 0, (ty->cursor_state.cy + l)));
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w);
l--;
}
}
@ -304,22 +304,22 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
if (y < ty->h)
{
_text_clear(ty, cells, ty->w * ty->cursor_state.cy, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w * ty->cursor_state.cy);
}
else
{
int yt = y % ty->w;
int yb = ty->h - ty->circular_offset;
_text_clear(ty, cells, ty->w * yb, 0, EINA_TRUE);
_text_clear(ty, ty->screen, ty->w * yt, 0, EINA_TRUE);
termpty_cells_clear(ty, cells, ty->w * yb);
termpty_cells_clear(ty, ty->screen, ty->w * yt);
}
}
_termpty_clear_line(ty, mode, ty->w);
termpty_clear_line(ty, mode, ty->w);
break;
case TERMPTY_CLR_ALL:
ty->circular_offset = 0;
_text_clear(ty, ty->screen, ty->w * ty->h, 0, EINA_TRUE);
termpty_cells_clear(ty, ty->screen, ty->w * ty->h);
ty->termstate.scroll_y2 = 0;
if (ty->cb.cancel_sel.func)
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
@ -330,14 +330,14 @@ _termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
}
void
_termpty_clear_all(Termpty *ty)
termpty_clear_all(Termpty *ty)
{
if (!ty->screen) return;
termpty_cell_fill(ty, NULL, ty->screen, ty->w * ty->h);
}
void
_termpty_reset_att(Termatt *att)
termpty_reset_att(Termatt *att)
{
att->fg = COL_DEF;
att->bg = COL_DEF;
@ -365,7 +365,7 @@ _termpty_reset_att(Termatt *att)
}
void
_termpty_reset_state(Termpty *ty)
termpty_reset_state(Termpty *ty)
{
ty->cursor_state.cx = 0;
ty->cursor_state.cy = 0;
@ -373,7 +373,7 @@ _termpty_reset_state(Termpty *ty)
ty->termstate.scroll_y2 = 0;
ty->termstate.had_cr_x = 0;
ty->termstate.had_cr_y = 0;
_termpty_reset_att(&(ty->termstate.att));
termpty_reset_att(&(ty->termstate.att));
ty->termstate.charset = 0;
ty->termstate.charsetch = 'B';
ty->termstate.chset[0] = 'B';
@ -416,7 +416,7 @@ _termpty_reset_state(Termpty *ty)
}
void
_termpty_cursor_copy(Termpty *ty, Eina_Bool save)
termpty_cursor_copy(Termpty *ty, Eina_Bool save)
{
if (save)
{

@ -9,18 +9,19 @@ typedef enum _Termpty_Clear
} Termpty_Clear;
void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max);
void _termpty_text_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count);
void _termpty_text_scroll(Termpty *ty, Eina_Bool clear);
void _termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear);
void _termpty_text_scroll_test(Termpty *ty, Eina_Bool clear);
void _termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear);
void _termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len);
void _termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit);
void _termpty_clear_screen(Termpty *ty, Termpty_Clear mode);
void _termpty_clear_all(Termpty *ty);
void _termpty_reset_att(Termatt *att);
void _termpty_reset_state(Termpty *ty);
void _termpty_cursor_copy(Termpty *ty, Eina_Bool save);
void termpty_cells_copy(Termpty *ty, Termcell *cells, Termcell *dest, 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);
void termpty_text_scroll_test(Termpty *ty, Eina_Bool clear);
void termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear);
void termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len);
void termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit);
void termpty_clear_screen(Termpty *ty, Termpty_Clear mode);
void termpty_clear_all(Termpty *ty);
void termpty_reset_att(Termatt *att);
void termpty_reset_state(Termpty *ty);
void termpty_cursor_copy(Termpty *ty, Eina_Bool save);
#define _term_txt_write(ty, txt) termpty_write(ty, txt, sizeof(txt) - 1)

Loading…
Cancel
Save