]> git.neil.brown.name Git - edlib.git/commitdiff
render-lines: ensure cursor doesn't fall off end of line.
authorNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 00:24:16 +0000 (10:24 +1000)
committerNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 01:07:02 +0000 (11:07 +1000)
If the line is not allowed to left-shift and doesn't wrap, cursor might
be off the right edge.
In that case, do think that the cursor is drawn.

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

index 9b0cd7de74e53c3409296bfcb0a86bc24167398c..01f28ff1e1637872eb73f8b8641a32bbe2d11892 100644 (file)
@@ -9,7 +9,7 @@ the file.
 
 ### Triage
 
-- [ ] If a pane with shift-disabled has cursor past the right edge, the
+- [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
       cursor is v.close to left, even when the rest of the line is blank
index 95b23140b143c521a79d512322dbe1a321fd45a4..711d7cbcb23ea8db31bdea40dbc318a755ae7135 100644 (file)
@@ -830,14 +830,14 @@ static int render(struct mark *pm, struct pane *p safe,
        struct mark *m, *m2;
        struct xy scale = pane_scale(focus);
        char *s;
-       int hide_cursor = 0;
-       int cursor_drawn = 0;
+       bool hide_cursor = False;
+       bool cursor_drawn = False;
        bool refresh_all = rl->shift_left != rl->shift_left_last_refresh;
 
        rl->shift_left_last_refresh = rl->shift_left;
        s = pane_attr_get(focus, "hide-cursor");
        if (s && strcmp(s, "yes") == 0)
-               hide_cursor = 1;
+               hide_cursor = True;
 
        rl->cols = 0;
        m = vmark_first(focus, rl->typenum, p);
@@ -893,14 +893,14 @@ static int render(struct mark *pm, struct pane *p safe,
                        draw_line(p, focus, m, len, True);
                        rl->cursor_line = hp->y + hp->cy;
                        curs = pane_mapxy(hp, p, hp->cx, hp->cy, False);
-                       if (hp->cx < 0) {
+                       if (hp->cx < 0 || hp->cx >= hp->w) {
                                p->cx = -1;
                                p->cy = -1;
                        } else {
                                p->cx = curs.x;
                                p->cy = curs.y;
+                               cursor_drawn = True;
                        }
-                       cursor_drawn = 1;
                } else {
                        draw_line(p, focus, m, -1, refresh_all);
                }
index 6f5791e73c7c0b8bb82a5808a7b71d7d05a87f7b..d8bb4d8a5c9a884685bbef20e6ce811bf06c1833 100644 (file)
@@ -449,4 +449,4 @@ Display 80,30 9668618AF877EA4CD97E4F8D2C729215 1,22
 Key ":Up"
 Display 80,30 F6BF3A75AC3B026DCFAC496EECDD4E0A 1,21
 Key ":Tab"
-Close 823
+Close 825
index 07e0d87d242c633c4439a057201acc4ddc843af1..c76e16bea7e597fb5d65c314af45bb9ccae3f47d 100644 (file)
@@ -498,4 +498,4 @@ Key ":C-X"
 Display 80,30 662292DCAF96B09B7F39A91DB348091A 61,16
 Key ":C-C"
 Display 80,30 03A8C2118CA808DFC0F0AB2107FC9EF3 61,16
-Close 864
+Close 871