summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-09-10 23:38:21 +0200
committerBoris Faure <billiob@gmail.com>2015-09-16 19:20:34 +0200
commit35813be3ca8a8983c20df9d61092985a96ece71d (patch)
tree092d09c43cd00b9e8ad7cbcfc38b78bcfb8140e3
parent444cc9d8b43468d7ab23a954713b061f4f976514 (diff)
fix line length computation
-rw-r--r--src/bin/termpty.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 66752da..5ff680b 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -579,16 +579,27 @@ termpty_free(Termpty *ty)
579} 579}
580 580
581static Eina_Bool 581static Eina_Bool
582termpty_line_is_empty(const Termcell *cells, ssize_t nb_cells) 582_termpty_cell_is_empty(const Termcell *cell)
583{ 583{
584 ssize_t len = nb_cells; 584 if ((cell->codepoint != 0) &&
585 (!cell->att.invisible) &&
586 (cell->att.fg != COL_INVIS))
587 {
588 return EINA_FALSE;
589 }
590 return EINA_TRUE;
591}
592
593static Eina_Bool
594_termpty_line_is_empty(const Termcell *cells, ssize_t nb_cells)
595{
596 ssize_t len;
585 597
586 for (len = nb_cells - 1; len >= 0; len--) 598 for (len = nb_cells - 1; len >= 0; len--)
587 { 599 {
588 const Termcell *cell = cells + len; 600 const Termcell *cell = cells + len;
589 601
590 if ((cell->codepoint != 0) && 602 if (!_termpty_cell_is_empty(cell))
591 (cell->att.bg != COL_INVIS))
592 return EINA_FALSE; 603 return EINA_FALSE;
593 } 604 }
594 605
@@ -605,8 +616,7 @@ termpty_line_length(const Termcell *cells, ssize_t nb_cells)
605 { 616 {
606 const Termcell *cell = cells + len; 617 const Termcell *cell = cells + len;
607 618
608 if ((cell->codepoint != 0) && 619 if (!_termpty_cell_is_empty(cell))
609 (cell->att.bg != COL_INVIS))
610 return len + 1; 620 return len + 1;
611 } 621 }
612 622
@@ -988,22 +998,24 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
988 new_si.h = new_h; 998 new_si.h = new_h;
989 999
990 /* compute the effective height on the old screen */ 1000 /* compute the effective height on the old screen */
991 effective_old_h = old_h; 1001 effective_old_h = 0;
992 for (old_y = old_h -1; old_y >= 0; old_y--) 1002 for (old_y = old_h -1; old_y >= 0; old_y--)
993 { 1003 {
994 Termcell *cells = &TERMPTY_SCREEN(ty, 0, old_y); 1004 Termcell *cells = &(TERMPTY_SCREEN(ty, 0, old_y));
995 if (!termpty_line_is_empty(cells, old_w) && 1005 if (!_termpty_line_is_empty(cells, old_w))
996 ty->cursor_state.cy < old_y)
997 { 1006 {
998 effective_old_h = old_y + 1; 1007 effective_old_h = old_y + 1;
999 break; 1008 break;
1000 } 1009 }
1001 } 1010 }
1002 1011
1012 if (effective_old_h <= ty->cursor_state.cy)
1013 effective_old_h = ty->cursor_state.cy + 1;
1014
1003 for (old_y = 0; old_y < effective_old_h; old_y++) 1015 for (old_y = 0; old_y < effective_old_h; old_y++)
1004 { 1016 {
1005 /* for each line in the old screen, append it to the new screen */ 1017 /* for each line in the old screen, append it to the new screen */
1006 Termcell *cells = &TERMPTY_SCREEN(ty, 0, old_y); 1018 Termcell *cells = &(TERMPTY_SCREEN(ty, 0, old_y));
1007 int len; 1019 int len;
1008 1020
1009 len = termpty_line_length(cells, old_w); 1021 len = termpty_line_length(cells, old_w);