]> git.neil.brown.name Git - edlib.git/commitdiff
lib-renderline allow rtab to avoid line wraps.
authorNeilBrown <neil@brown.name>
Tue, 15 Aug 2023 11:47:22 +0000 (21:47 +1000)
committerNeilBrown <neil@brown.name>
Tue, 15 Aug 2023 11:47:22 +0000 (21:47 +1000)
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 <neil@brown.name>
DOC/TODO.md
lib-messageline.c
lib-renderline.c

index f96f025bec1623f9da2f0b5d5a22e657e9a27e4b..0f5f91a44e96e215689274d30b507fb0db0e4fda 100644 (file)
@@ -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
index 6cc0fe1a20fa9e01f57023ca74aba619cd471622..1981059fd9aca00847499a7cde7d6c7a2161c5f2 100644 (file)
@@ -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;
 }
index 95d4464e1dca83a14e7cafdd70b79a658a7da507..dcd4559c4b0259315710e8999cc9da1b24bcc099 100644 (file)
@@ -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 */