reflow: use termpty_cell_copy() instead of memcpy()
Also get rid of _termpty_text_copy().
This commit is contained in:
parent
ea60fdf9a4
commit
b749acfc3c
|
@ -544,9 +544,8 @@ _termpty_horizontally_expand(Termpty *ty, int old_w, int old_h,
|
||||||
}
|
}
|
||||||
if (ts->w >= remaining_width)
|
if (ts->w >= remaining_width)
|
||||||
{
|
{
|
||||||
memcpy(new_ts->cell + new_ts->w,
|
termpty_cell_copy(ty, cells, new_ts->cell + new_ts->w,
|
||||||
cells,
|
remaining_width);
|
||||||
remaining_width * sizeof(Termcell));
|
|
||||||
new_ts->w = ty->w;
|
new_ts->w = ty->w;
|
||||||
new_ts->cell[new_ts->w - 1].att.autowrapped = 1;
|
new_ts->cell[new_ts->w - 1].att.autowrapped = 1;
|
||||||
len -= remaining_width;
|
len -= remaining_width;
|
||||||
|
@ -559,9 +558,7 @@ _termpty_horizontally_expand(Termpty *ty, int old_w, int old_h,
|
||||||
}
|
}
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
memcpy(new_ts->cell + new_ts->w,
|
termpty_cell_copy(ty, cells, new_ts->cell + new_ts->w, len);
|
||||||
cells,
|
|
||||||
len * sizeof(Termcell));
|
|
||||||
new_ts->w += len;
|
new_ts->w += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +578,7 @@ _termpty_horizontally_expand(Termpty *ty, int old_w, int old_h,
|
||||||
new_ts = calloc(1, sizeof(Termsave) +
|
new_ts = calloc(1, sizeof(Termsave) +
|
||||||
(ty->w - 1) * sizeof(Termcell));
|
(ty->w - 1) * sizeof(Termcell));
|
||||||
new_ts->w = ts->w;
|
new_ts->w = ts->w;
|
||||||
memcpy(new_ts->cell, ts->cell, ts->w * sizeof(Termcell));
|
termpty_cell_copy(ty, ts->cell, new_ts->cell, ts->w);
|
||||||
new_ts->cell[ts->w - 1].att.autowrapped = 0;
|
new_ts->cell[ts->w - 1].att.autowrapped = 0;
|
||||||
|
|
||||||
new_back[new_back_pos++] = new_ts;
|
new_back[new_back_pos++] = new_ts;
|
||||||
|
@ -630,9 +627,7 @@ expand_screen:
|
||||||
ssize_t len = MIN(cur_line_length, remaining_width);
|
ssize_t len = MIN(cur_line_length, remaining_width);
|
||||||
Termcell *cells = &OLD_SCREEN(0, old_y);
|
Termcell *cells = &OLD_SCREEN(0, old_y);
|
||||||
|
|
||||||
memcpy(new_ts->cell + new_ts->w,
|
termpty_cell_copy(ty, cells, new_ts->cell + new_ts->w, len);
|
||||||
cells,
|
|
||||||
len * sizeof(Termcell));
|
|
||||||
new_ts->w += len;
|
new_ts->w += len;
|
||||||
cells += len;
|
cells += len;
|
||||||
if (cur_line_length > remaining_width)
|
if (cur_line_length > remaining_width)
|
||||||
|
@ -640,9 +635,8 @@ expand_screen:
|
||||||
new_ts->cell[new_ts->w - 1].att.autowrapped = 1;
|
new_ts->cell[new_ts->w - 1].att.autowrapped = 1;
|
||||||
new_ts = NULL;
|
new_ts = NULL;
|
||||||
len = cur_line_length - remaining_width;
|
len = cur_line_length - remaining_width;
|
||||||
memcpy(ty->screen + (y * ty->w),
|
termpty_cell_copy(ty, cells, ty->screen + (y * ty->w),
|
||||||
cells,
|
len);
|
||||||
len * sizeof(Termcell));
|
|
||||||
x += len;
|
x += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,10 +656,10 @@ expand_screen:
|
||||||
|
|
||||||
if (cur_line_length >= remaining_width)
|
if (cur_line_length >= remaining_width)
|
||||||
{
|
{
|
||||||
/* TODO: use termpty_cell_copy */
|
termpty_cell_copy(ty,
|
||||||
memcpy(ty->screen + (y * ty->w) + x,
|
&OLD_SCREEN(0, old_y),
|
||||||
&OLD_SCREEN(0, old_y),
|
ty->screen + (y * ty->w) + x,
|
||||||
remaining_width * sizeof(Termcell));
|
remaining_width);
|
||||||
TERMPTY_SCREEN(ty, ty->w - 1, y).att.autowrapped = 1;
|
TERMPTY_SCREEN(ty, ty->w - 1, y).att.autowrapped = 1;
|
||||||
y++;
|
y++;
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -674,10 +668,10 @@ expand_screen:
|
||||||
}
|
}
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
/* TODO: use termpty_cell_copy */
|
termpty_cell_copy(ty,
|
||||||
memcpy(ty->screen + (y * ty->w) + x,
|
&OLD_SCREEN(old_x, old_y),
|
||||||
&OLD_SCREEN(old_x, old_y),
|
ty->screen + (y * ty->w) + x,
|
||||||
len * sizeof(Termcell));
|
len);
|
||||||
x += len;
|
x += len;
|
||||||
TERMPTY_SCREEN(ty, x - 1, y).att.autowrapped = 0;
|
TERMPTY_SCREEN(ty, x - 1, y).att.autowrapped = 0;
|
||||||
}
|
}
|
||||||
|
@ -688,10 +682,10 @@ expand_screen:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TODO: use termpty_cell_copy */
|
termpty_cell_copy(ty,
|
||||||
memcpy(ty->screen + (y * ty->w),
|
&OLD_SCREEN(0, old_y),
|
||||||
&OLD_SCREEN(0, old_y),
|
ty->screen + (y * ty->w),
|
||||||
cur_line_length * sizeof(Termcell));
|
cur_line_length);
|
||||||
if (OLD_SCREEN(old_w - 1, old_y).att.autowrapped)
|
if (OLD_SCREEN(old_w - 1, old_y).att.autowrapped)
|
||||||
{
|
{
|
||||||
rewrapping = EINA_TRUE;
|
rewrapping = EINA_TRUE;
|
||||||
|
@ -734,7 +728,7 @@ _termpty_vertically_expand(Termpty *ty, int old_w, int old_h,
|
||||||
|
|
||||||
c1 = &(OLD_SCREEN(0, y));
|
c1 = &(OLD_SCREEN(0, y));
|
||||||
c2 = &(TERMPTY_SCREEN(ty, 0, y + from_history));
|
c2 = &(TERMPTY_SCREEN(ty, 0, y + from_history));
|
||||||
_termpty_text_copy(ty, c1, c2, old_w);
|
termpty_cell_copy(ty, c1, c2, old_w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +748,7 @@ _termpty_vertically_expand(Termpty *ty, int old_w, int old_h,
|
||||||
|
|
||||||
src = ts->cell;
|
src = ts->cell;
|
||||||
dst = &(TERMPTY_SCREEN(ty, 0, y));
|
dst = &(TERMPTY_SCREEN(ty, 0, y));
|
||||||
_termpty_text_copy(ty, src, dst, ts->w);
|
termpty_cell_copy(ty, src, dst, ts->w);
|
||||||
|
|
||||||
free(ts);
|
free(ts);
|
||||||
ty->back[ty->backpos] = NULL;
|
ty->back[ty->backpos] = NULL;
|
||||||
|
@ -808,7 +802,7 @@ _termpty_vertically_shrink(Termpty *ty, int old_w, int old_h,
|
||||||
{
|
{
|
||||||
src = &(OLD_SCREEN(0, y + to_history));
|
src = &(OLD_SCREEN(0, y + to_history));
|
||||||
dst = &(TERMPTY_SCREEN(ty, 0, y));
|
dst = &(TERMPTY_SCREEN(ty, 0, y));
|
||||||
_termpty_text_copy(ty, src, dst, old_w);
|
termpty_cell_copy(ty, src, dst, old_w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -826,13 +820,13 @@ _termpty_vertically_shrink(Termpty *ty, int old_w, int old_h,
|
||||||
{
|
{
|
||||||
src = &(old_screen[y * old_w]);
|
src = &(old_screen[y * old_w]);
|
||||||
dst = &(OLD_SCREEN(0, y));
|
dst = &(OLD_SCREEN(0, y));
|
||||||
_termpty_text_copy(ty, src, dst, old_w);
|
termpty_cell_copy(ty, src, dst, old_w);
|
||||||
}
|
}
|
||||||
for (y = 0; y < ty->circular_offset; y++)
|
for (y = 0; y < ty->circular_offset; y++)
|
||||||
{
|
{
|
||||||
src = &(OLD_SCREEN(0, y));
|
src = &(OLD_SCREEN(0, y));
|
||||||
dst = &(old_screen[y * old_w]);
|
dst = &(old_screen[y * old_w]);
|
||||||
_termpty_text_copy(ty, src, dst, old_w);
|
termpty_cell_copy(ty, src, dst, old_w);
|
||||||
}
|
}
|
||||||
ty->circular_offset = 0;
|
ty->circular_offset = 0;
|
||||||
}
|
}
|
||||||
|
@ -895,7 +889,7 @@ _termpty_horizontally_shrink(Termpty *ty, int old_w, int old_h,
|
||||||
new_ts = calloc(1, sizeof(Termsave) +
|
new_ts = calloc(1, sizeof(Termsave) +
|
||||||
(old_ts->w - 1) * sizeof(Termcell));
|
(old_ts->w - 1) * sizeof(Termcell));
|
||||||
new_ts->w = old_ts->w;
|
new_ts->w = old_ts->w;
|
||||||
memcpy(new_ts->cell, old_cells, old_ts->w * sizeof(Termcell));
|
termpty_cell_copy(ty, old_cells, new_ts->cell, old_ts->w);
|
||||||
|
|
||||||
PUSH_BACK_TS(new_ts);
|
PUSH_BACK_TS(new_ts);
|
||||||
|
|
||||||
|
@ -923,13 +917,12 @@ _termpty_horizontally_shrink(Termpty *ty, int old_w, int old_h,
|
||||||
new_ts = calloc(1, sizeof(Termsave) +
|
new_ts = calloc(1, sizeof(Termsave) +
|
||||||
(len - 1) * sizeof(Termcell));
|
(len - 1) * sizeof(Termcell));
|
||||||
new_ts->w = len;
|
new_ts->w = len;
|
||||||
memcpy(new_ts->cell, old_cells,
|
termpty_cell_copy(ty, old_cells, new_ts->cell, old_ts->w);
|
||||||
old_ts->w * sizeof(Termcell));
|
|
||||||
|
|
||||||
remaining_width = len - old_ts->w;
|
remaining_width = len - old_ts->w;
|
||||||
|
|
||||||
memcpy(new_ts->cell + old_ts->w,
|
termpty_cell_copy(ty, cells, new_ts->cell + old_ts->w,
|
||||||
cells, remaining_width * sizeof(Termcell));
|
remaining_width);
|
||||||
|
|
||||||
rewrapping = ts->cell[ts->w - 1].att.autowrapped;
|
rewrapping = ts->cell[ts->w - 1].att.autowrapped;
|
||||||
cells += remaining_width;
|
cells += remaining_width;
|
||||||
|
@ -949,7 +942,7 @@ _termpty_horizontally_shrink(Termpty *ty, int old_w, int old_h,
|
||||||
new_ts = calloc(1, sizeof(Termsave) +
|
new_ts = calloc(1, sizeof(Termsave) +
|
||||||
(ty->w - 1) * sizeof(Termcell));
|
(ty->w - 1) * sizeof(Termcell));
|
||||||
new_ts->w = ty->w;
|
new_ts->w = ty->w;
|
||||||
memcpy(new_ts->cell, cells, ty->w * sizeof(Termcell));
|
termpty_cell_copy(ty, cells, new_ts->cell, ty->w);
|
||||||
rewrapping = ts->cell[ts->w - 1].att.autowrapped;
|
rewrapping = ts->cell[ts->w - 1].att.autowrapped;
|
||||||
|
|
||||||
new_ts->cell[new_ts->w - 1].att.autowrapped = 1;
|
new_ts->cell[new_ts->w - 1].att.autowrapped = 1;
|
||||||
|
@ -981,7 +974,7 @@ _termpty_horizontally_shrink(Termpty *ty, int old_w, int old_h,
|
||||||
new_ts = calloc(1, sizeof(Termsave) +
|
new_ts = calloc(1, sizeof(Termsave) +
|
||||||
(ts->w - 1) * sizeof(Termcell));
|
(ts->w - 1) * sizeof(Termcell));
|
||||||
new_ts->w = ts->w;
|
new_ts->w = ts->w;
|
||||||
memcpy(new_ts->cell, cells, ts->w * sizeof(Termcell));
|
termpty_cell_copy(ty, cells, new_ts->cell, ts->w);
|
||||||
|
|
||||||
PUSH_BACK_TS(new_ts);
|
PUSH_BACK_TS(new_ts);
|
||||||
free(ts);
|
free(ts);
|
||||||
|
@ -1010,9 +1003,7 @@ shrink_screen:
|
||||||
|
|
||||||
if (old_ts)
|
if (old_ts)
|
||||||
{
|
{
|
||||||
memcpy(ty->screen,
|
termpty_cell_copy(ty, old_cells, ty->screen, old_ts->w);
|
||||||
old_cells,
|
|
||||||
old_ts->w * sizeof(Termcell));
|
|
||||||
x = old_ts->w;
|
x = old_ts->w;
|
||||||
if (!rewrapping)
|
if (!rewrapping)
|
||||||
y++;
|
y++;
|
||||||
|
@ -1050,9 +1041,10 @@ shrink_screen:
|
||||||
|
|
||||||
remaining_width = ty->w - x;
|
remaining_width = ty->w - x;
|
||||||
len = MIN(remaining_width, cur_line_length);
|
len = MIN(remaining_width, cur_line_length);
|
||||||
memcpy(&TERMPTY_SCREEN(ty, x, y),
|
termpty_cell_copy(ty,
|
||||||
&OLD_SCREEN(old_x, old_y),
|
&OLD_SCREEN(old_x, old_y),
|
||||||
len * sizeof(Termcell));
|
&TERMPTY_SCREEN(ty, x, y),
|
||||||
|
len);
|
||||||
x += len;
|
x += len;
|
||||||
old_x += len;
|
old_x += len;
|
||||||
cur_line_length -= len;
|
cur_line_length -= len;
|
||||||
|
|
|
@ -39,7 +39,7 @@ termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max)
|
||||||
w = termpty_line_length(cells, w_max);
|
w = termpty_line_length(cells, w_max);
|
||||||
ts = calloc(1, sizeof(Termsave) + ((w - 1) * sizeof(Termcell)));
|
ts = calloc(1, sizeof(Termsave) + ((w - 1) * sizeof(Termcell)));
|
||||||
ts->w = w;
|
ts->w = w;
|
||||||
_termpty_text_copy(ty, cells, ts->cell, w);
|
termpty_cell_copy(ty, cells, ts->cell, w);
|
||||||
if (!ty->back) ty->back = calloc(1, sizeof(Termsave *) * ty->backmax);
|
if (!ty->back) ty->back = calloc(1, sizeof(Termsave *) * ty->backmax);
|
||||||
if (ty->back[ty->backpos])
|
if (ty->back[ty->backpos])
|
||||||
{
|
{
|
||||||
|
@ -54,12 +54,6 @@ termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max)
|
||||||
if (ty->backscroll_num >= ty->backmax) ty->backscroll_num = ty->backmax - 1;
|
if (ty->backscroll_num >= ty->backmax) ty->backscroll_num = ty->backmax - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
_termpty_text_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count)
|
|
||||||
{
|
|
||||||
termpty_cell_copy(ty, cells, dest, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_termpty_text_scroll(Termpty *ty)
|
_termpty_text_scroll(Termpty *ty)
|
||||||
{
|
{
|
||||||
|
@ -98,11 +92,11 @@ _termpty_text_scroll(Termpty *ty)
|
||||||
{
|
{
|
||||||
cells2 = &(ty->screen[end_y * ty->w]);
|
cells2 = &(ty->screen[end_y * ty->w]);
|
||||||
for (y = start_y; y < end_y; y++)
|
for (y = start_y; y < end_y; y++)
|
||||||
{
|
{
|
||||||
cells = &(ty->screen[y * ty->w]);
|
cells = &(ty->screen[y * ty->w]);
|
||||||
cells2 = &(ty->screen[(y + 1) * ty->w]);
|
cells2 = &(ty->screen[(y + 1) * ty->w]);
|
||||||
_termpty_text_copy(ty, cells2, cells, ty->w);
|
termpty_cell_copy(ty, cells2, cells, ty->w);
|
||||||
}
|
}
|
||||||
_text_clear(ty, cells2, ty->w, 0, EINA_TRUE);
|
_text_clear(ty, cells2, ty->w, 0, EINA_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,11 +128,11 @@ _termpty_text_scroll_rev(Termpty *ty)
|
||||||
{
|
{
|
||||||
cells = &(TERMPTY_SCREEN(ty, 0, end_y));
|
cells = &(TERMPTY_SCREEN(ty, 0, end_y));
|
||||||
for (y = end_y; y > start_y; y--)
|
for (y = end_y; y > start_y; y--)
|
||||||
{
|
{
|
||||||
cells = &(TERMPTY_SCREEN(ty, 0, (y - 1)));
|
cells = &(TERMPTY_SCREEN(ty, 0, (y - 1)));
|
||||||
cells2 = &(TERMPTY_SCREEN(ty, 0, y));
|
cells2 = &(TERMPTY_SCREEN(ty, 0, y));
|
||||||
_termpty_text_copy(ty, cells, cells2, ty->w);
|
termpty_cell_copy(ty, cells, cells2, ty->w);
|
||||||
}
|
}
|
||||||
y = start_y;
|
y = start_y;
|
||||||
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
|
_text_clear(ty, cells, ty->w, 0, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue