]> git.neil.brown.name Git - edlib.git/commitdiff
lib-renderlines: clean up left_margin handling.
authorNeilBrown <neil@brown.name>
Wed, 16 Aug 2023 09:20:09 +0000 (19:20 +1000)
committerNeilBrown <neil@brown.name>
Wed, 16 Aug 2023 09:20:09 +0000 (19:20 +1000)
In particular the wrap_margin must initially be based on the left margin.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
lib-renderline.c

index 1644c25ce4005e3f84f4b4db278275145f1900b7..b830f219b56c6fc1c712839c94d55f100abb6169 100644 (file)
@@ -10,6 +10,13 @@ the file.
 ### Triage
 
 
+- [ ] favourites...  I want some favourite documents that are easy to
+      find, favourite directories, favourite make or shell commands.
+      Maybe that are found by moving "down" in history?  Maybe alt-*
+      flags them?
+- [ ] merge command 9-A-m could work as one command.  If there is an
+      active selection, the patch is moved to that selection.
+- [ ] merge command 9 must ensure selection is full lines.
 - [ ] if cursor position causes pane size to change, this doesn't
       propagate.
 - [X] check formatting in x11 display.  Wrap causes problems 474/476 of
@@ -96,7 +103,7 @@ the file.
 
 - [X] Change times_up() to use pane_too_long()
 - [X] change :A-x menu to use doc-list - add sorting
-- [ ] Change render-lines to handle centring and right-align in flush_line
+- [X] Change render-lines to handle centring and right-align in flush_line
 - [ ] Teach render-lines to pad spaces to left/right align text
 - [ ] revise *Welcome* page
 
index dcd4559c4b0259315710e8999cc9da1b24bcc099..14a983654cba1794ad30e4dbc0233972c67fa30f 100644 (file)
@@ -604,6 +604,7 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse
        bool wrap = shift_left < 0;
        int wrap_margin;
        int right_margin = p->w - (rd->right_margin * rd->scale / 1000);
+       int left_margin = rd->left_margin * rd->scale / 1000;
        int xdiff, ydiff;
        struct call_return cr;
        int x, y;
@@ -666,7 +667,7 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse
        /* Set 'x' position honouring tab stops, and set length
         * of "\t" characters.  Also handle \n and \f.
         */
-       x = (rd->left_margin * rd->scale / 1000) - (shift_left > 0 ? shift_left : 0);
+       x = left_margin - (shift_left > 0 ? shift_left : 0);
        y = rd->space_above * rd->scale / 1000;
        rd->width = 0;
        for (ri = rd->content; ri; ri = ri->next) {
@@ -674,7 +675,8 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse
                struct render_item *ri2;
                ri->y = y;
                if (ri->tab != TAB_UNSET)
-                       x =  (rd->left_margin * rd->scale / 1000) + calc_tab(ri->tab, right_margin, rd->scale);
+                       x =  left_margin + calc_tab(ri->tab, right_margin,
+                                                   rd->scale);
                if (ri->eol) {
                        /* EOL */
                        if (x > rd->width)
@@ -707,7 +709,8 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse
                        ri2 = ri2->next;
                margin = right_margin;
                if (ri2)
-                       margin =  (rd->left_margin * rd->scale / 1000) + calc_tab(ri2->tab, right_margin, rd->scale);
+                       margin =  left_margin + calc_tab(ri2->tab, right_margin,
+                                                        rd->scale);
                if (ri->tab_align == TAB_RIGHT)
                        x = x + margin - x - w;
                else
@@ -727,7 +730,7 @@ static bool measure_line(struct pane *p safe, struct pane *focus safe, int offse
         */
        xdiff = 0; ydiff = 0; y = 0;
        wraprl = NULL;
-       wrap_margin = rd->head_length;
+       wrap_margin = left_margin + rd->head_length;
        for (ri = rd->content ; wrap && ri ; ri = ri->next) {
                int splitpos;
                if (ri->wrap && (wraprl == NULL || ri->wrap != wraprl->wrap))