reflow: correctly set line length when pushing to backscroll

This commit is contained in:
Boris Faure 2013-03-17 19:27:20 +01:00
parent 050892a04c
commit 852400f039
3 changed files with 12 additions and 5 deletions

View File

@ -469,7 +469,7 @@ termpty_write(Termpty *ty, const char *input, int len)
if (write(ty->fd, input, len) < 0) ERR("write %s", strerror(errno));
}
ssize_t _line_length(const Termcell *cells, ssize_t nb_cells)
ssize_t termpty_line_length(const Termcell *cells, ssize_t nb_cells)
{
ssize_t len = nb_cells;
@ -616,7 +616,7 @@ expand_screen:
{
ssize_t cur_line_length;
cur_line_length = _line_length(&OLD_SCREEN(0, old_y), old_w);
cur_line_length = termpty_line_length(&OLD_SCREEN(0, old_y), old_w);
if (rewrapping)
{
if (new_ts)

View File

@ -184,6 +184,8 @@ void termpty_cell_swap(Termpty *ty, Termcell *src, Termcell *dst, int n);
void termpty_cell_fill(Termpty *ty, Termcell *src, Termcell *dst, int n);
void termpty_cell_codepoint_att_fill(Termpty *ty, int codepoint, Termatt att, Termcell *dst, int n);
ssize_t termpty_line_length(const Termcell *cells, ssize_t nb_cells);
extern int _termpty_log_dom;
#define TERMPTY_SCREEN(Tpty, X, Y) \

View File

@ -32,11 +32,16 @@ static void
_text_save_top(Termpty *ty)
{
Termsave *ts;
Termcell *cells;
ssize_t w;
if (ty->backmax <= 0) return;
ts = calloc(1, sizeof(Termsave) + ((ty->w - 1) * sizeof(Termcell)));
ts->w = ty->w;
_termpty_text_copy(ty, &(TERMPTY_SCREEN(ty, 0, 0)), ts->cell, ty->w);
cells = &(TERMPTY_SCREEN(ty, 0, 0));
w = termpty_line_length(cells, ty->w);
ts = calloc(1, sizeof(Termsave) + ((w - 1) * sizeof(Termcell)));
ts->w = w;
_termpty_text_copy(ty, cells, ts->cell, w);
if (!ty->back) ty->back = calloc(1, sizeof(Termsave *) * ty->backmax);
if (ty->back[ty->backpos])
{