From: NeilBrown Date: Tue, 15 Aug 2023 11:47:22 +0000 (+1000) Subject: lib-renderline allow rtab to avoid line wraps. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=0ea07d89b561b85e306a3a3c33a6b96974eb1177;p=edlib.git lib-renderline allow rtab to avoid line wraps. If rtab is used, don't wrap if last char is at right edge. If no rtab, continue to wrap so there is somewhere for cursor to be. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index f96f025b..0f5f91a4 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -10,12 +10,14 @@ the file. ### Triage +- [ ] if cursor position causes pane size to change, this doesn't + propagate. - [X] check formatting in x11 display. Wrap causes problems 474/476 of render-present.py and elsewhere - [X] check notmuch formatting. wrap-margin isn't right! - [X] email display: image positioning is wrong. Maybe they don't get erased when moved. -- [ ] remove tab_right hack by not requiring tail_length after +- [X] remove tab_right hack by not requiring tail_length after final non-eol item - [X] resolve fixme around wrap_margin when splitting - [X] resolve fixme reguarding margin in find_curs diff --git a/lib-messageline.c b/lib-messageline.c index 6cc0fe1a..1981059f 100644 --- a/lib-messageline.c +++ b/lib-messageline.c @@ -233,7 +233,7 @@ DEF_CMD(messageline_refresh) else buf[0] = 0; /* justify 10pt (1 char) from right to avoid triggering a wrap */ - pane_str(mli->line, buf, "bold,fg:blue,rtab"); + pane_str(mli->line, buf, "bold,fg:blue,right:10,rtab"); } return 1; } diff --git a/lib-renderline.c b/lib-renderline.c index 95d4464e..dcd4559c 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -608,6 +608,7 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse struct call_return cr; int x, y; bool eop = False; + bool seen_rtab = False; if (!rd->content) return eop; @@ -695,6 +696,8 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse x += ri->width; continue; } + if (ri->tab_align == TAB_RIGHT) + seen_rtab = True; w = ri->width; for (ri2 = ri->next; ri2 && ri2->tab_align == TAB_LEFT && ri2->tab == TAB_UNSET; @@ -705,10 +708,9 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse margin = right_margin; if (ri2) margin = (rd->left_margin * rd->scale / 1000) + calc_tab(ri2->tab, right_margin, rd->scale); - if (ri->tab_align == TAB_RIGHT) { - margin -= rd->tail_length;// FIXME don't want this HACK + if (ri->tab_align == TAB_RIGHT) x = x + margin - x - w; - } else + else x = x + (margin - x - w) / 2; ri->x = x; while (ri->next && ri->next->next && ri->next->tab_align == TAB_LEFT) { @@ -742,6 +744,15 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse } if (ri->x + ri->width <= right_margin - rd->tail_length) continue; + if ((ri->next == NULL || ri->next->eol) && + ri->x + ri->width <= right_margin && + seen_rtab) + /* Don't need any tail space for last item. + * This allows rtab to fully right-justify, + * but leaves no-where for the cursor. So + * only do it if rtab is present. + */ + continue; /* This doesn't fit here */ if (wraprl) { /* Move wraprl to next line and hide it unless it contains cursor */