From: NeilBrown Date: Wed, 16 Aug 2023 09:20:09 +0000 (+1000) Subject: lib-renderlines: clean up left_margin handling. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=1a2f62436af8d1e384ea0139934678f572e9fe9a;p=edlib.git lib-renderlines: clean up left_margin handling. In particular the wrap_margin must initially be based on the left margin. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 1644c25c..b830f219 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -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 diff --git a/lib-renderline.c b/lib-renderline.c index dcd4559c..14a98365 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -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))