Hi Code looks mostly fine, a few style nits below.
I think we should make this a flag to resize-pane (I suggest -R or -L) rather than a new command. Could you do that? Thanks diff --git a/grid.c b/grid.c index 71a3679..4f07bf8 100644 --- a/grid.c +++ b/grid.c @@ -541,3 +541,58 @@ 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) +{ + GRID_DEBUG(src, "(src) sx=%u", sx); + GRID_DEBUG(dst, "(dst)"); I'm not sure we need the GRID_DEBUG now if you are happy it works? + + u_int px = 0; + u_int py = 0; + u_int prev_line_wrapped = 1; In any case these declarations need to go before the GRID_DEBUG lines or it will fail when built with gcc2. Same in several places below. I'm going to add -Wdeclaration-after-statement to CFLAGS I think... + + for (u_int line = 0; line < src->sy + src->hsize; line++) { + GRID_DEBUG(src, "Working line %u", line); + struct grid_line *gl = src->linedata + line; + if (!prev_line_wrapped) { + GRID_DEBUG(src, "(src) Last line didn't wrap."); + px = 0; + py++; + if (py >= dst->hsize + dst->sy) { + GRID_DEBUG(dst, "(dst) Having to scroll (py=%u).", py); + grid_scroll_history(dst); + } + } + for (u_int cell = 0; cell < gl->cellsize; cell++) { + if (px == sx) { + GRID_DEBUG(src, "(src) Width %u exceeded, wrapping.", sx); + dst->linedata[py].flags |= GRID_LINE_WRAPPED; + px = 0; + py++; + if (py >= dst->hsize + dst->sy) { + GRID_DEBUG(dst, "(dst) Having to scroll (py=%u).", py); + grid_scroll_history(dst); + } + } + grid_set_cell(dst, px, py, gl->celldata + cell); + if (gl->celldata[cell].flags & GRID_FLAG_UTF8) { + grid_set_utf8(dst, px, py, gl->utf8data + cell); + } + px++; + } + prev_line_wrapped = gl->flags & GRID_LINE_WRAPPED; + } + + /* Account for final line, which never wraps. */ + py++; + + if (py > src->sy) + return 0; + else + return src->sy - py; +} ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users