From: NeilBrown Date: Fri, 21 Jul 2023 01:27:17 +0000 (+1000) Subject: render-lines: improvements to left shift. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=de056a2e1d2c2d48f00c1e1ba091118edfb58c86;p=edlib.git render-lines: improvements to left shift. If there is lots of space on the right, only shift left if the cursor requires it. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 01f28ff1..c3012806 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -11,7 +11,7 @@ the file. - [X] If a pane with shift-disabled has cursor past the right edge, the cursor gets positioned outside the window -- [ ] when find-file dialog shifts left, it doesn't shift back until +- [X] when find-file dialog shifts left, it doesn't shift back until cursor is v.close to left, even when the rest of the line is blank - [ ] line-count in make output is weird. Second line can be thousands - [ ] Make sometimes doesn't follow output, though usually it does diff --git a/render-lines.c b/render-lines.c index 855f2fff..2e11e02f 100644 --- a/render-lines.c +++ b/render-lines.c @@ -1035,6 +1035,7 @@ static int revalidate_start(struct rl_data *rl safe, } if (m && m->mdata) { struct pane *hp = m->mdata; + int cols; int offset = call_render_line_to_point(focus, pm, m); measure_line(p, focus, m, offset); @@ -1043,7 +1044,7 @@ static int revalidate_start(struct rl_data *rl safe, curs_width = pane_attr_get_int( m->mdata, "curs_width", 1); - while (hp->cx + curs_width >= p->w && shifts++ < 1000) { + while (hp->cx + curs_width > p->w && shifts++ < 1000) { int shift = 8 * curs_width; if (shift > hp->cx) shift = hp->cx; @@ -1051,7 +1052,12 @@ static int revalidate_start(struct rl_data *rl safe, measure_line(p, focus, m, offset); refresh_all = 1; } - while (hp->cx < prefix_len && + /* We shift right is cursor is off the left end, or if + * doing so wouldn't hide anything on the right end + */ + cols = pane_attr_get_int(hp, "width", 0); + while ((hp->cx < prefix_len + || cols + curs_width * 8 + curs_width < p->w) && rl->shift_left > 0 && shifts++ < 1000 && hp->cx + curs_width * 8 < p->w) { @@ -1060,6 +1066,7 @@ static int revalidate_start(struct rl_data *rl safe, shift = rl->shift_left; rl->shift_left -= shift; measure_line(p, focus, m, offset); + cols = pane_attr_get_int(hp, "width", 0); refresh_all = 1; } } diff --git a/tests.d/02-grep b/tests.d/02-grep index da8de42d..7d4f691b 100644 --- a/tests.d/02-grep +++ b/tests.d/02-grep @@ -18,7 +18,7 @@ Display 80,30 C6FBFB848F2D7592ECB9B40BFC8E1C46 55,13 Key "-l" Display 80,30 84B4B4327EE9B820531DCFEBD1FCD5C1 56,13 Key "-l" -Display 80,30 64C0896B3CEBB0A1AD76140579FB823F 49,13 +Display 80,30 5E0D84660745B71B819E3107C39BCCCC 57,13 Key "-s" Display 80,30 0BCDBE7601C6CAAE1F9AEA767CB96003 50,13 Key ":Enter"