diff options
author | Thomas Adam <thomas@xteddy.org> | 2018-07-11 09:02:25 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2018-07-11 09:02:25 +0100 |
commit | a4a7c3c68ddd1040c292c3ad3abfbd37c2a5153c (patch) | |
tree | b657f7fdab99ca2ff8a2dff2da99f3f803a1794c /grid.c | |
parent | 6f2698004ead7bfc4bd235535642dfeccb381d89 (diff) | |
parent | e7d53020b44c33dfee9080db142e973c434ba8a5 (diff) | |
download | rtmux-a4a7c3c68ddd1040c292c3ad3abfbd37c2a5153c.tar.gz rtmux-a4a7c3c68ddd1040c292c3ad3abfbd37c2a5153c.tar.bz2 rtmux-a4a7c3c68ddd1040c292c3ad3abfbd37c2a5153c.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -145,12 +145,14 @@ grid_extended_cell(struct grid_line *gl, struct grid_cell_entry *gce, return (gcp); } +/* Get line data. */ struct grid_line * grid_get_line(struct grid *gd, u_int line) { return (&gd->linedata[line]); } +/* Adjust number of lines. */ void grid_adjust_lines(struct grid *gd, u_int lines) { @@ -284,6 +286,15 @@ grid_compare(struct grid *ga, struct grid *gb) return (0); } +/* Trim lines from the history. */ +static void +grid_trim_history(struct grid *gd, u_int ny) +{ + grid_free_lines(gd, 0, ny); + memmove(&gd->linedata[0], &gd->linedata[ny], + (gd->hsize + gd->sy - ny) * (sizeof *gd->linedata)); +} + /* * Collect lines from the history if at the limit. Free the top (oldest) 10% * and shift up. @@ -306,9 +317,7 @@ grid_collect_history(struct grid *gd) * Free the lines from 0 to ny then move the remaining lines over * them. */ - grid_free_lines(gd, 0, ny); - memmove(&gd->linedata[0], &gd->linedata[ny], - (gd->hsize + gd->sy - ny) * (sizeof *gd->linedata)); + grid_trim_history(gd, ny); gd->hsize -= ny; if (gd->hscrolled > gd->hsize) @@ -338,9 +347,7 @@ grid_scroll_history(struct grid *gd, u_int bg) void grid_clear_history(struct grid *gd) { - grid_free_lines(gd, 0, gd->hsize); - memmove(&gd->linedata[0], &gd->linedata[gd->hsize], - gd->sy * (sizeof *gd->linedata)); + grid_trim_history(gd, gd->hsize); gd->hscrolled = 0; gd->hsize = 0; |