]> git.neil.brown.name Git - edlib.git/commitdiff
render-lines: improvements to left shift.
authorNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 01:27:17 +0000 (11:27 +1000)
committerNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 01:29:27 +0000 (11:29 +1000)
If there is lots of space on the right, only shift left if the cursor
requires it.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
render-lines.c
tests.d/02-grep

index 01f28ff1e1637872eb73f8b8641a32bbe2d11892..c301280662cab2b33e75accbcff3b74aebdd857c 100644 (file)
@@ -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
index 855f2ffffb23a09a766cbf2cb37205eb63f3246a..2e11e02f0f1696914ab747ea582617a8f6ced1e3 100644 (file)
@@ -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;
                        }
                }
index da8de42db07195b623ff59ff3f8f76a0b6760f11..7d4f691b84c4c4bbdd675cfc2b754cdf91264ddc 100644 (file)
@@ -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"