billiob pushed a commit to branch master.
commit 852400f03992c9cb316b3c08e9a6f2d474b45a03
Author: Boris Faure <[email protected]>
Date: Sun Mar 17 19:27:20 2013 +0100
reflow: correctly set line length when pushing to backscroll
---
src/bin/termpty.c | 4 ++--
src/bin/termpty.h | 2 ++
src/bin/termptyops.c | 11 ++++++++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index a297e3f..68406d1 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -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)
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 9510d61..b6840f1 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -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) \
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index 1115113..140767f 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -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])
{
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter