diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-09 14:53:51 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-09 14:53:51 +0000 |
commit | 648ce2f56adc071f93516887cf4a4c32f631d54e (patch) | |
tree | c0d2438bd54d426e6dab3fbcd833ce3408adc215 /grid.c | |
parent | 0648c587162da4eae0805e35805454c46be70321 (diff) | |
parent | 01da28efb112ef2096a80da616ca190d59ba9b52 (diff) | |
download | rtmux-648ce2f56adc071f93516887cf4a4c32f631d54e.tar.gz rtmux-648ce2f56adc071f93516887cf4a4c32f631d54e.tar.bz2 rtmux-648ce2f56adc071f93516887cf4a4c32f631d54e.zip |
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -460,3 +460,44 @@ grid_duplicate_lines( dy++; } } + +/* + * Reflow lines from src grid into dst grid based on width sx. Returns number + * of lines fewer in the visible area, or zero. + */ +u_int +grid_reflow(struct grid *dst, const struct grid *src, u_int sx) +{ + u_int px, py, line, cell; + int previous_wrapped; + struct grid_line *gl; + + px = py = 0; + previous_wrapped = 1; + for (line = 0; line < src->sy + src->hsize; line++) { + gl = src->linedata + line; + if (!previous_wrapped) { + px = 0; + py++; + if (py >= dst->hsize + dst->sy) + grid_scroll_history(dst); + } + for (cell = 0; cell < gl->cellsize; cell++) { + if (px == sx) { + dst->linedata[py].flags |= GRID_LINE_WRAPPED; + px = 0; + py++; + if (py >= dst->hsize + dst->sy) + grid_scroll_history(dst); + } + grid_set_cell(dst, px, py, gl->celldata + cell); + px++; + } + previous_wrapped = gl->flags & GRID_LINE_WRAPPED; + } + py++; /* account for final line, which never wraps */ + + if (py > src->sy) + return (0); + return (src->sy - py); +} |