2012-07-13 01:46:33 -07:00
|
|
|
#include "private.h"
|
|
|
|
#include <Elementary.h>
|
2013-11-10 13:13:19 -08:00
|
|
|
#include "termio.h"
|
2012-07-13 01:46:33 -07:00
|
|
|
#include "termpty.h"
|
|
|
|
#include "termptydbl.h"
|
|
|
|
#include "termptyops.h"
|
|
|
|
#include "termptygfx.h"
|
2019-11-23 09:31:23 -08:00
|
|
|
#include "backlog.h"
|
2014-05-03 13:16:27 -07:00
|
|
|
#include "miniview.h"
|
2015-06-02 13:48:50 -07:00
|
|
|
#include <assert.h>
|
2012-07-13 01:46:33 -07:00
|
|
|
|
|
|
|
#undef CRITICAL
|
|
|
|
#undef ERR
|
|
|
|
#undef WRN
|
|
|
|
#undef INF
|
|
|
|
#undef DBG
|
|
|
|
|
|
|
|
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_termpty_log_dom, __VA_ARGS__)
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_termpty_log_dom, __VA_ARGS__)
|
|
|
|
#define WRN(...) EINA_LOG_DOM_WARN(_termpty_log_dom, __VA_ARGS__)
|
|
|
|
#define INF(...) EINA_LOG_DOM_INFO(_termpty_log_dom, __VA_ARGS__)
|
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
|
|
|
|
|
2015-06-01 13:52:07 -07:00
|
|
|
void
|
2019-01-03 13:46:07 -08:00
|
|
|
termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2013-01-22 21:11:29 -08:00
|
|
|
Termcell src;
|
2012-07-13 01:46:33 -07:00
|
|
|
|
2013-01-29 07:54:47 -08:00
|
|
|
memset(&src, 0, sizeof(src));
|
2019-01-03 13:46:07 -08:00
|
|
|
src.codepoint = 0;
|
2015-06-01 13:52:07 -07:00
|
|
|
src.att = ty->termstate.att;
|
2019-01-03 13:46:07 -08:00
|
|
|
src.att.link_id = 0;
|
2012-07-13 01:46:33 -07:00
|
|
|
|
2019-01-03 13:46:07 -08:00
|
|
|
termpty_cell_fill(ty, &src, cells, count);
|
2017-06-05 11:47:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-13 01:46:33 -07:00
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll(Termpty *ty, Eina_Bool clear)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
Termcell *cells = NULL;
|
|
|
|
int start_y = 0, end_y = ty->h - 1;
|
2012-07-13 01:46:33 -07:00
|
|
|
|
2017-06-05 08:43:23 -07:00
|
|
|
start_y = ty->termstate.top_margin;
|
2017-05-29 14:26:32 -07:00
|
|
|
if (ty->termstate.bottom_margin != 0)
|
2017-06-05 08:43:23 -07:00
|
|
|
end_y = ty->termstate.bottom_margin - 1;
|
|
|
|
if (!(ty->termstate.top_margin || ty->termstate.bottom_margin ||
|
|
|
|
ty->termstate.left_margin || ty->termstate.right_margin) &&
|
|
|
|
(!ty->altbuf))
|
|
|
|
termpty_text_save_top(ty, &(TERMPTY_SCREEN(ty, 0, 0)), ty->w);
|
2013-11-10 13:13:19 -08:00
|
|
|
|
2013-11-18 13:30:26 -08:00
|
|
|
termio_scroll(ty->obj, -1, start_y, end_y);
|
2012-07-13 01:46:33 -07:00
|
|
|
DBG("... scroll!!!!! [%i->%i]", start_y, end_y);
|
2013-01-21 06:02:32 -08:00
|
|
|
|
2017-06-05 08:43:23 -07:00
|
|
|
if ((start_y == 0 && end_y == ty->h - 1) &&
|
|
|
|
(ty->termstate.left_margin == 0) &&
|
|
|
|
(ty->termstate.right_margin == 0))
|
2013-01-21 06:02:32 -08:00
|
|
|
{
|
2017-06-05 08:43:23 -07:00
|
|
|
// screen is a circular buffer now
|
|
|
|
cells = &(ty->screen[ty->circular_offset * ty->w]);
|
|
|
|
if (clear)
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, cells, ty->w);
|
2013-01-21 06:02:32 -08:00
|
|
|
|
2017-06-05 08:43:23 -07:00
|
|
|
ty->circular_offset++;
|
|
|
|
if (ty->circular_offset >= ty->h)
|
|
|
|
ty->circular_offset = 0;
|
2013-01-21 06:02:32 -08:00
|
|
|
}
|
|
|
|
else
|
2013-01-20 02:48:17 -08:00
|
|
|
{
|
2017-06-05 08:43:23 -07:00
|
|
|
int x = ty->termstate.left_margin;
|
2017-06-05 15:19:48 -07:00
|
|
|
int w = ty->w - x;
|
2020-04-17 14:09:07 -07:00
|
|
|
int y;
|
2017-06-05 08:43:23 -07:00
|
|
|
|
|
|
|
if (ty->termstate.right_margin)
|
|
|
|
w = ty->termstate.right_margin - x;
|
|
|
|
|
|
|
|
cells = &(TERMPTY_SCREEN(ty, x, end_y));
|
|
|
|
for (y = start_y; y < end_y; y++)
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
Termcell *cells2;
|
|
|
|
|
2017-06-05 08:43:23 -07:00
|
|
|
cells = &(TERMPTY_SCREEN(ty, x, (y + 1)));
|
|
|
|
cells2 = &(TERMPTY_SCREEN(ty, x, y));
|
2017-09-08 15:18:02 -07:00
|
|
|
TERMPTY_CELL_COPY(ty, cells, cells2, w);
|
2017-06-05 08:43:23 -07:00
|
|
|
}
|
|
|
|
if (clear)
|
2017-06-06 14:49:24 -07:00
|
|
|
termpty_cells_clear(ty, cells, w);
|
2013-01-20 02:48:17 -08:00
|
|
|
}
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
Termcell *cells;
|
|
|
|
int start_y = 0, end_y = ty->h - 1;
|
2012-07-13 01:46:33 -07:00
|
|
|
|
2017-05-29 14:26:32 -07:00
|
|
|
if (ty->termstate.bottom_margin != 0)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2017-05-29 14:26:32 -07:00
|
|
|
start_y = ty->termstate.top_margin;
|
|
|
|
end_y = ty->termstate.bottom_margin - 1;
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
DBG("... scroll rev!!!!! [%i->%i]", start_y, end_y);
|
2013-11-18 13:30:26 -08:00
|
|
|
termio_scroll(ty->obj, 1, start_y, end_y);
|
2013-01-21 06:02:32 -08:00
|
|
|
|
2019-01-05 10:25:37 -08:00
|
|
|
if ((start_y == 0 && end_y == (ty->h - 1)) &&
|
|
|
|
(ty->termstate.left_margin == 0) &&
|
|
|
|
(ty->termstate.right_margin == 0))
|
2013-01-20 02:48:17 -08:00
|
|
|
{
|
2019-01-05 10:25:37 -08:00
|
|
|
// screen is a circular buffer now
|
|
|
|
ty->circular_offset--;
|
|
|
|
if (ty->circular_offset < 0)
|
|
|
|
ty->circular_offset = ty->h - 1;
|
2013-01-21 06:02:32 -08:00
|
|
|
|
2019-01-05 10:25:37 -08:00
|
|
|
cells = &(ty->screen[ty->circular_offset * ty->w]);
|
|
|
|
if (clear)
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, cells, ty->w);
|
2013-01-21 06:02:32 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-05 10:25:37 -08:00
|
|
|
int x = ty->termstate.left_margin;
|
|
|
|
int w = ty->w - x;
|
2020-04-17 14:09:07 -07:00
|
|
|
int y;
|
2019-01-05 10:25:37 -08:00
|
|
|
|
|
|
|
if (ty->termstate.right_margin)
|
|
|
|
w = ty->termstate.right_margin - x;
|
|
|
|
|
|
|
|
cells = &(TERMPTY_SCREEN(ty, x, end_y));
|
|
|
|
for (y = end_y; y > start_y; y--)
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
Termcell *cells2;
|
|
|
|
|
2019-01-05 10:25:37 -08:00
|
|
|
cells = &(TERMPTY_SCREEN(ty, x, (y - 1)));
|
|
|
|
cells2 = &(TERMPTY_SCREEN(ty, x, y));
|
|
|
|
TERMPTY_CELL_COPY(ty, cells, cells2, w);
|
|
|
|
}
|
|
|
|
if (clear)
|
|
|
|
termpty_cells_clear(ty, cells, w);
|
2013-01-20 02:48:17 -08:00
|
|
|
}
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll_test(Termpty *ty, Eina_Bool clear)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
int e = ty->h;
|
|
|
|
|
2017-08-22 13:08:11 -07:00
|
|
|
if (ty->termstate.bottom_margin != 0)
|
|
|
|
{
|
|
|
|
e = ty->termstate.bottom_margin;
|
|
|
|
if (ty->cursor_state.cy == e)
|
|
|
|
{
|
|
|
|
termpty_text_scroll(ty, clear);
|
|
|
|
ty->cursor_state.cy = e - 1;
|
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
|
2017-09-08 14:06:19 -07:00
|
|
|
return;
|
2017-08-22 13:08:11 -07:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 14:06:19 -07:00
|
|
|
if (ty->cursor_state.cy >= ty->h)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll(ty, clear);
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->cursor_state.cy = e - 1;
|
2015-06-02 13:48:50 -07:00
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
int b = 0;
|
|
|
|
|
2018-12-30 09:36:02 -08:00
|
|
|
if (ty->termstate.top_margin != 0)
|
|
|
|
b = ty->termstate.top_margin;
|
2015-04-19 10:59:29 -07:00
|
|
|
if (ty->cursor_state.cy < b)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll_rev(ty, clear);
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->cursor_state.cy = b;
|
2015-06-02 13:48:50 -07:00
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_append(Termpty *ty, const Eina_Unicode *codepoints, int len)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
Termcell *cells;
|
|
|
|
int i, j;
|
2017-06-05 08:43:23 -07:00
|
|
|
int origin = ty->termstate.left_margin;
|
|
|
|
|
2015-04-19 10:59:29 -07:00
|
|
|
cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
|
2012-07-13 01:46:33 -07:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
2019-01-12 07:12:04 -08:00
|
|
|
int max_right = ty->w;
|
2012-07-13 01:46:33 -07:00
|
|
|
Eina_Unicode g;
|
|
|
|
|
2019-01-12 07:12:04 -08:00
|
|
|
if (ty->termstate.right_margin &&
|
|
|
|
(ty->cursor_state.cx < ty->termstate.right_margin))
|
|
|
|
{
|
|
|
|
max_right = ty->termstate.right_margin;
|
|
|
|
}
|
|
|
|
|
2022-03-04 03:42:57 -08:00
|
|
|
if (ty->cursor_state.wrapnext)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2017-06-05 08:43:23 -07:00
|
|
|
cells[max_right-1].att.autowrapped = 1;
|
2022-03-04 03:42:57 -08:00
|
|
|
ty->cursor_state.wrapnext = 0;
|
2017-06-05 08:43:23 -07:00
|
|
|
ty->cursor_state.cx = origin;
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->cursor_state.cy++;
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_text_scroll_test(ty, EINA_TRUE);
|
2015-04-19 10:59:29 -07:00
|
|
|
cells = &(TERMPTY_SCREEN(ty, 0, ty->cursor_state.cy));
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
2015-04-19 10:59:29 -07:00
|
|
|
if (ty->termstate.insert)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2017-06-05 08:43:23 -07:00
|
|
|
for (j = max_right-1; j > ty->cursor_state.cx; j--)
|
2017-09-08 15:18:02 -07:00
|
|
|
TERMPTY_CELL_COPY(ty, &(cells[j - 1]), &(cells[j]), 1);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
2017-07-06 11:55:02 -07:00
|
|
|
g = _termpty_charset_trans(ty, codepoints[i]);
|
2020-02-16 09:51:36 -08:00
|
|
|
/* Skip 0-width space or RTL/LTR marks */
|
|
|
|
if (EINA_UNLIKELY(g >= 0x200b && g <= 0x200f))
|
2016-05-31 13:03:58 -07:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2019-06-23 10:18:46 -07:00
|
|
|
/* Skip variation selectors */
|
|
|
|
if (EINA_UNLIKELY(g >= 0xfe00 && g <= 0xfe0f))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-26 09:42:26 -08:00
|
|
|
if (EINA_UNLIKELY(g >= 0x300 && g <=0x36f))
|
|
|
|
{
|
|
|
|
/* combining chars */
|
|
|
|
if (EINA_UNLIKELY(g == 0x336))
|
|
|
|
{
|
|
|
|
ty->termstate.combining_strike = 1;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2014-04-06 05:42:38 -07:00
|
|
|
|
2015-04-19 10:59:29 -07:00
|
|
|
termpty_cell_codepoint_att_fill(ty, g, ty->termstate.att,
|
|
|
|
&(cells[ty->cursor_state.cx]), 1);
|
2016-11-26 09:42:26 -08:00
|
|
|
if (EINA_UNLIKELY(ty->termstate.combining_strike))
|
|
|
|
{
|
|
|
|
ty->termstate.combining_strike = 0;
|
|
|
|
cells[ty->cursor_state.cx].att.strike = 1;
|
|
|
|
}
|
2019-01-12 07:12:04 -08:00
|
|
|
|
2015-04-19 10:59:29 -07:00
|
|
|
cells[ty->cursor_state.cx].att.dblwidth = _termpty_is_dblwidth_get(ty, g);
|
2017-06-05 08:43:23 -07:00
|
|
|
if (EINA_UNLIKELY((cells[ty->cursor_state.cx].att.dblwidth) && (ty->cursor_state.cx < (max_right - 1))))
|
2013-04-15 07:53:28 -07:00
|
|
|
{
|
2017-08-26 09:51:22 -07:00
|
|
|
cells[ty->cursor_state.cx].att.newline = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
termpty_cell_codepoint_att_fill(ty, 0, cells[ty->cursor_state.cx].att,
|
|
|
|
&(cells[ty->cursor_state.cx + 1]), 1);
|
2013-04-15 07:53:28 -07:00
|
|
|
}
|
2019-01-12 07:12:04 -08:00
|
|
|
|
2015-04-19 10:59:29 -07:00
|
|
|
if (ty->termstate.wrap)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2013-10-28 02:55:53 -07:00
|
|
|
unsigned char offset = 1;
|
|
|
|
|
2022-03-04 03:42:57 -08:00
|
|
|
ty->cursor_state.wrapnext = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
if (EINA_UNLIKELY(cells[ty->cursor_state.cx].att.dblwidth))
|
2013-10-28 02:55:53 -07:00
|
|
|
offset = 2;
|
2017-06-05 08:43:23 -07:00
|
|
|
if (EINA_UNLIKELY(ty->cursor_state.cx >= (max_right - offset)))
|
2022-03-04 03:42:57 -08:00
|
|
|
ty->cursor_state.wrapnext = 1;
|
2015-04-19 10:59:29 -07:00
|
|
|
else
|
2015-06-02 13:48:50 -07:00
|
|
|
{
|
|
|
|
ty->cursor_state.cx += offset;
|
2017-06-05 08:43:23 -07:00
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, max_right);
|
2015-06-02 13:48:50 -07:00
|
|
|
}
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-28 02:55:53 -07:00
|
|
|
unsigned char offset = 1;
|
|
|
|
|
2022-03-04 03:42:57 -08:00
|
|
|
ty->cursor_state.wrapnext = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
if (EINA_UNLIKELY(cells[ty->cursor_state.cx].att.dblwidth))
|
2013-12-25 03:03:01 -08:00
|
|
|
offset = 2;
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->cursor_state.cx += offset;
|
2017-06-05 08:43:23 -07:00
|
|
|
if (ty->cursor_state.cx > (max_right - offset))
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2017-06-05 08:43:23 -07:00
|
|
|
ty->cursor_state.cx = max_right - offset;
|
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, max_right);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
2017-06-05 08:43:23 -07:00
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, max_right);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_clear_line(Termpty *ty, Termpty_Clear mode, int limit)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
Termcell *cells;
|
|
|
|
int n = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
Evas_Coord x = 0, y = ty->cursor_state.cy;
|
2012-07-13 01:46:33 -07:00
|
|
|
|
2015-06-02 13:48:50 -07:00
|
|
|
assert (y >= 0 && y < ty->h);
|
|
|
|
|
2012-07-13 01:46:33 -07:00
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case TERMPTY_CLR_END:
|
2015-04-19 10:59:29 -07:00
|
|
|
n = ty->w - ty->cursor_state.cx;
|
|
|
|
x = ty->cursor_state.cx;
|
2012-07-13 01:46:33 -07:00
|
|
|
break;
|
|
|
|
case TERMPTY_CLR_BEGIN:
|
2015-04-19 10:59:29 -07:00
|
|
|
n = ty->cursor_state.cx + 1;
|
2012-07-13 01:46:33 -07:00
|
|
|
break;
|
|
|
|
case TERMPTY_CLR_ALL:
|
|
|
|
n = ty->w;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2013-11-11 09:08:02 -08:00
|
|
|
cells = &(TERMPTY_SCREEN(ty, x, y));
|
2019-01-27 10:49:00 -08:00
|
|
|
if (n > limit)
|
|
|
|
n = limit;
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, cells, n);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
2016-12-18 09:48:03 -08:00
|
|
|
void
|
|
|
|
termpty_clear_tabs_on_screen(Termpty *ty)
|
|
|
|
{
|
2016-12-19 14:38:32 -08:00
|
|
|
if (ty->tabs)
|
|
|
|
{
|
|
|
|
memset(ty->tabs, 0,
|
|
|
|
DIV_ROUND_UP(ty->w, sizeof(unsigned int) * 8u)
|
|
|
|
* sizeof(unsigned int));
|
|
|
|
}
|
2016-12-18 09:48:03 -08:00
|
|
|
}
|
|
|
|
|
2012-07-13 01:46:33 -07:00
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_clear_screen(Termpty *ty, Termpty_Clear mode)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
Termcell *cells;
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case TERMPTY_CLR_END:
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_clear_line(ty, mode, ty->w);
|
2015-04-19 10:59:29 -07:00
|
|
|
if (ty->cursor_state.cy < (ty->h - 1))
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2015-04-19 10:59:29 -07:00
|
|
|
int l = ty->h - (ty->cursor_state.cy + 1);
|
2013-02-16 10:16:25 -08:00
|
|
|
|
2013-04-06 13:13:12 -07:00
|
|
|
while (l)
|
2013-02-16 10:16:25 -08:00
|
|
|
{
|
2015-04-19 10:59:29 -07:00
|
|
|
cells = &(TERMPTY_SCREEN(ty, 0, (ty->cursor_state.cy + l)));
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, cells, ty->w);
|
2013-04-06 13:13:12 -07:00
|
|
|
l--;
|
2013-02-16 10:16:25 -08:00
|
|
|
}
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TERMPTY_CLR_BEGIN:
|
2015-04-19 10:59:29 -07:00
|
|
|
if (ty->cursor_state.cy > 0)
|
2013-11-10 13:13:19 -08:00
|
|
|
{
|
|
|
|
// First clear from circular > height, then from 0 to circular
|
2015-04-19 10:59:29 -07:00
|
|
|
int y = ty->cursor_state.cy + ty->circular_offset;
|
2013-11-10 13:13:19 -08:00
|
|
|
|
|
|
|
cells = &(TERMPTY_SCREEN(ty, 0, 0));
|
|
|
|
|
|
|
|
if (y < ty->h)
|
|
|
|
{
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, cells, ty->w * ty->cursor_state.cy);
|
2013-11-10 13:13:19 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-05 15:23:56 -08:00
|
|
|
int yt = y % ty->h;
|
2013-11-10 13:13:19 -08:00
|
|
|
int yb = ty->h - ty->circular_offset;
|
|
|
|
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, cells, ty->w * yb);
|
|
|
|
termpty_cells_clear(ty, ty->screen, ty->w * yt);
|
2013-11-10 13:13:19 -08:00
|
|
|
}
|
|
|
|
}
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_clear_line(ty, mode, ty->w);
|
2012-07-13 01:46:33 -07:00
|
|
|
break;
|
|
|
|
case TERMPTY_CLR_ALL:
|
2013-11-10 13:13:19 -08:00
|
|
|
ty->circular_offset = 0;
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cells_clear(ty, ty->screen, ty->w * ty->h);
|
2013-11-11 09:08:02 -08:00
|
|
|
if (ty->cb.cancel_sel.func)
|
|
|
|
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
|
2012-07-13 01:46:33 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_clear_all(Termpty *ty)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
if (!ty->screen) return;
|
2013-01-29 07:54:47 -08:00
|
|
|
termpty_cell_fill(ty, NULL, ty->screen, ty->w * ty->h);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_reset_att(Termatt *att)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
|
|
|
att->fg = COL_DEF;
|
|
|
|
att->bg = COL_DEF;
|
|
|
|
att->bold = 0;
|
|
|
|
att->faint = 0;
|
|
|
|
att->italic = 0;
|
|
|
|
att->dblwidth = 0;
|
|
|
|
att->underline = 0;
|
|
|
|
att->blink = 0;
|
|
|
|
att->blink2 = 0;
|
|
|
|
att->inverse = 0;
|
|
|
|
att->invisible = 0;
|
|
|
|
att->strike = 0;
|
|
|
|
att->fg256 = 0;
|
|
|
|
att->bg256 = 0;
|
|
|
|
att->fgintense = 0;
|
|
|
|
att->bgintense = 0;
|
|
|
|
att->autowrapped = 0;
|
|
|
|
att->newline = 0;
|
2014-04-06 05:42:38 -07:00
|
|
|
att->fraktur = 0;
|
2018-03-13 01:15:32 -07:00
|
|
|
att->framed = 0;
|
|
|
|
att->encircled = 0;
|
|
|
|
att->overlined = 0;
|
2019-10-27 08:04:43 -07:00
|
|
|
att->tab_inserted = 0;
|
|
|
|
att->tab_last = 0;
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-10-12 11:17:50 -07:00
|
|
|
termpty_soft_reset_state(Termpty *ty)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2016-12-18 09:48:03 -08:00
|
|
|
int i;
|
2018-03-15 11:20:09 -07:00
|
|
|
Config *config = NULL;
|
|
|
|
|
|
|
|
if (ty->obj)
|
|
|
|
config = termio_config_get(ty->obj);
|
2015-04-06 09:08:23 -07:00
|
|
|
|
2017-05-29 14:26:32 -07:00
|
|
|
ty->termstate.top_margin = 0;
|
|
|
|
ty->termstate.bottom_margin = 0;
|
2017-06-03 14:17:33 -07:00
|
|
|
ty->termstate.left_margin = 0;
|
|
|
|
ty->termstate.right_margin = 0;
|
|
|
|
ty->termstate.lr_margins = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->termstate.had_cr_x = 0;
|
|
|
|
ty->termstate.had_cr_y = 0;
|
2017-06-01 12:34:01 -07:00
|
|
|
ty->termstate.restrict_cursor = 0;
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_reset_att(&(ty->termstate.att));
|
2018-10-13 10:15:57 -07:00
|
|
|
ty->termstate.att.link_id = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->termstate.charset = 0;
|
|
|
|
ty->termstate.charsetch = 'B';
|
|
|
|
ty->termstate.chset[0] = 'B';
|
|
|
|
ty->termstate.chset[1] = 'B';
|
|
|
|
ty->termstate.chset[2] = 'B';
|
|
|
|
ty->termstate.chset[3] = 'B';
|
|
|
|
ty->termstate.multibyte = 0;
|
|
|
|
ty->termstate.alt_kp = 0;
|
|
|
|
ty->termstate.insert = 0;
|
|
|
|
ty->termstate.appcursor = 0;
|
|
|
|
ty->termstate.wrap = 1;
|
2022-03-04 03:42:57 -08:00
|
|
|
ty->cursor_state.wrapnext = 0;
|
2015-04-19 10:59:29 -07:00
|
|
|
ty->termstate.crlf = 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;
|
2018-12-29 08:18:39 -08:00
|
|
|
ty->termstate.sace_rectangular = 0;
|
2014-03-05 13:43:31 -08:00
|
|
|
ty->mouse_mode = MOUSE_OFF;
|
|
|
|
ty->mouse_ext = MOUSE_EXT_NONE;
|
2014-05-07 11:40:03 -07:00
|
|
|
ty->bracketed_paste = 0;
|
2014-12-08 11:32:27 -08:00
|
|
|
|
2020-06-22 14:41:27 -07:00
|
|
|
termio_reset_main_colors(ty->obj);
|
2016-12-18 09:48:03 -08:00
|
|
|
termpty_clear_tabs_on_screen(ty);
|
|
|
|
for (i = 0; i < ty->w; i += TAB_WIDTH)
|
|
|
|
{
|
|
|
|
TAB_SET(ty, i);
|
|
|
|
}
|
2018-03-15 11:20:09 -07:00
|
|
|
if (config && ty->obj)
|
|
|
|
termio_set_cursor_shape(ty->obj, config->cursor_shape);
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 11:17:50 -07:00
|
|
|
void
|
|
|
|
termpty_reset_state(Termpty *ty)
|
|
|
|
{
|
|
|
|
termpty_soft_reset_state(ty);
|
|
|
|
ty->cursor_state.cx = 0;
|
|
|
|
ty->cursor_state.cy = 0;
|
|
|
|
termpty_clear_backlog(ty);
|
|
|
|
}
|
|
|
|
|
2012-07-13 01:46:33 -07:00
|
|
|
void
|
2015-06-01 13:52:07 -07:00
|
|
|
termpty_cursor_copy(Termpty *ty, Eina_Bool save)
|
2012-07-13 01:46:33 -07:00
|
|
|
{
|
2015-04-19 10:59:29 -07:00
|
|
|
if (save)
|
|
|
|
{
|
2022-03-04 03:46:11 -08:00
|
|
|
ty->cursor_save[ty->altbuf] = ty->cursor_state;
|
2015-04-19 10:59:29 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-04 03:46:11 -08:00
|
|
|
ty->cursor_state = ty->cursor_save[ty->altbuf];
|
2017-09-08 14:06:19 -07:00
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
|
|
|
|
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
|
2015-04-19 10:59:29 -07:00
|
|
|
}
|
2012-07-13 01:46:33 -07:00
|
|
|
}
|
2017-06-29 14:45:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
termpty_move_cursor(Termpty *ty, int cx, int cy)
|
|
|
|
{
|
2017-07-06 11:17:47 -07:00
|
|
|
int cur_cx = ty->cursor_state.cx;
|
|
|
|
int cur_cy = ty->cursor_state.cy;
|
|
|
|
Termcell *cells;
|
|
|
|
ssize_t wlen;
|
|
|
|
int n_to_down = 0;
|
|
|
|
int n_to_right = 0;
|
|
|
|
|
|
|
|
/* move Up or Down */
|
|
|
|
while (cur_cy != cy)
|
|
|
|
{
|
|
|
|
if (cur_cy < cy)
|
|
|
|
{
|
|
|
|
/* go down */
|
|
|
|
cells = termpty_cellrow_get(ty, cur_cy, &wlen);
|
|
|
|
assert(cells);
|
|
|
|
if (cells[wlen-1].att.autowrapped)
|
|
|
|
{
|
|
|
|
n_to_right += ty->w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n_to_down++;
|
|
|
|
}
|
|
|
|
cur_cy++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* go up */
|
|
|
|
cells = termpty_cellrow_get(ty, cur_cy - 1, &wlen);
|
|
|
|
assert(cells);
|
|
|
|
if (cells[wlen-1].att.autowrapped)
|
|
|
|
{
|
|
|
|
n_to_right -= ty->w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n_to_down--;
|
|
|
|
}
|
|
|
|
cur_cy--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
n_to_right += cx - cur_cx;
|
2017-06-29 14:45:05 -07:00
|
|
|
|
|
|
|
/* right */
|
2017-07-06 11:17:47 -07:00
|
|
|
for (; n_to_right > 0; n_to_right--)
|
2017-06-29 14:45:05 -07:00
|
|
|
termpty_write(ty, "\033[C", strlen("\033[C"));
|
2017-07-06 11:17:47 -07:00
|
|
|
/* left */
|
|
|
|
for (; n_to_right < 0; n_to_right++)
|
|
|
|
termpty_write(ty, "\033[D", strlen("\033[D"));
|
2017-06-29 14:45:05 -07:00
|
|
|
|
|
|
|
/* down*/
|
2017-07-06 11:17:47 -07:00
|
|
|
for (; n_to_down > 0; n_to_down--)
|
2017-06-29 14:45:05 -07:00
|
|
|
termpty_write(ty, "\033[B", strlen("\033[B"));
|
2017-07-06 11:17:47 -07:00
|
|
|
/* up */
|
|
|
|
for (; n_to_down < 0; n_to_down++)
|
|
|
|
termpty_write(ty, "\033[A", strlen("\033[A"));
|
2017-06-29 14:45:05 -07:00
|
|
|
|
|
|
|
}
|