From: NeilBrown Date: Fri, 21 Jul 2023 00:24:16 +0000 (+1000) Subject: render-lines: ensure cursor doesn't fall off end of line. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=14e140525a8b2b6c94f376c35554d1a0f0fa42a2;p=edlib.git render-lines: ensure cursor doesn't fall off end of line. 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 --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 9b0cd7de..01f28ff1 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -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 diff --git a/render-lines.c b/render-lines.c index 95b23140..711d7cbc 100644 --- a/render-lines.c +++ b/render-lines.c @@ -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); } diff --git a/tests.d/01-c-mode b/tests.d/01-c-mode index 6f5791e7..d8bb4d8a 100644 --- a/tests.d/01-c-mode +++ b/tests.d/01-c-mode @@ -449,4 +449,4 @@ Display 80,30 9668618AF877EA4CD97E4F8D2C729215 1,22 Key ":Up" Display 80,30 F6BF3A75AC3B026DCFAC496EECDD4E0A 1,21 Key ":Tab" -Close 823 +Close 825 diff --git a/tests.d/01-python b/tests.d/01-python index 07e0d87d..c76e16be 100644 --- a/tests.d/01-python +++ b/tests.d/01-python @@ -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