static int flush_line(struct pane *p safe, struct pane *focus safe, int dodraw,
struct render_list **rlp safe,
int y, int scale, int wrap_pos, int *wrap_margin safe,
+ int *wrap_prefix_sizep,
const char **xypos, const char **xyattr)
{
/* Flush a render_list returning x-space used.
struct render_list *last_wrap = NULL, *end_wrap = NULL, *last_rl = NULL;
int in_wrap = 0;
int wrap_len = 0; /* length of text in final <wrap> section */
+ int wrap_prefix_size = 0; /* wrap margin plus prefix */
struct render_list *rl, *tofree;
int x = 0;
char *head;
* Don't want to shift them over the wrap-head
*/
x -= cr.x;
+ wrap_prefix_size += cr.x;
}
x -= *wrap_margin;
+ wrap_prefix_size += *wrap_margin;
}
+ if (wrap_prefix_sizep)
+ *wrap_prefix_sizep = wrap_prefix_size;
for (rl = tofree; rl && rl != end_wrap; rl = tofree) {
tofree = rl->next;
const char *start;
struct buf attr;
unsigned char ch;
- int wrap_offset = 0; /*number of columns displayed in earlier lines */
- int wrap_margin = 0; /* left margin for wrap */
+ int wrap_offset = 0; /*number of columns displayed in earlier lines,
+ * use for calculating TAB size. */
+ int wrap_margin = 0; /* left margin for wrap - carried forward from
+ * line to line. */
int in_tab = 0;
int shift_left = atoi(pane_attr_get(focus, "shift_left") ?:"0");
int wrap = shift_left < 0;
(line[0] != '<' || line[1] == '<')) {
/* No room for more text */
if (wrap && *line && *line != '\n') {
+ int wrap_prefix_size;
int len = flush_line(p, focus, dodraw, &rlst,
y+ascent, scale,
p->w - mwidth, &wrap_margin,
+ &wrap_prefix_size,
&xypos, &xyattr);
+ if (len + wrap_prefix_size <= cx && cy == y) {
+ cx -= len;
+ cy += line_height;
+ }
wrap_offset += len;
x -= len;
if (x < 0)
if (ch == '\n') {
xypos = line-1;
flush_line(p, focus, dodraw, &rlst, y+ascent, scale, 0,
- &wrap_margin, &xypos, &xyattr);
+ &wrap_margin, NULL, &xypos, &xyattr);
y += line_height;
x = 0;
wrap_offset = 0;
}
flush_line(p, focus, dodraw, &rlst, y+ascent, scale, 0,
- &wrap_margin, &xypos, &xyattr);
+ &wrap_margin, NULL, &xypos, &xyattr);
if (want_xypos == 1) {
rd->xyattr = xyattr ? strdup(xyattr) : NULL;