From: NeilBrown Date: Tue, 18 Jul 2023 11:32:48 +0000 (+1000) Subject: Move-CursorXY - only perform action on direct hit. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=0739977061eae2e81cc6a42b2626850334962190;p=edlib.git Move-CursorXY - only perform action on direct hit. If Move-CursoyXY don't find a character under the cursor, don't perform the action. Still move the mark though. Signed-off-by: NeilBrown --- diff --git a/DOC/Developer/06-rendering.md b/DOC/Developer/06-rendering.md index a27fb95b..c7fda0e7 100644 --- a/DOC/Developer/06-rendering.md +++ b/DOC/Developer/06-rendering.md @@ -215,6 +215,11 @@ document, rather than on its content. location that the cursor is about to move to, and "mark2" will be the mark that will be moved. + Note that while Move-CursorXY will move the mark to a "near by" + location if the is no character at that exact locate, the action will + only be performed if there is a suitable character exactly where the + x,y co-ords are. + - "Move-Line" moves the cursor (point) forward or backward some number of lines based on the num1 argument. "render-lines" attempts to keep the cursor in the same column as it started in. This column number is diff --git a/render-lines.c b/render-lines.c index ab1c6fa4..95b23140 100644 --- a/render-lines.c +++ b/render-lines.c @@ -1507,11 +1507,21 @@ DEF_CMD(render_lines_set_cursor) * of that content (possible EOF) so move there */ } else { - if (cih.y < m->mdata->y) + if (cih.y < m->mdata->y) { + /* action only permitted in precise match */ + action = NULL; cih.y = m->mdata->y; + } xypos = find_xy_line(p, focus, m, cih.x, cih.y); - if (xypos >= 0) + if (xypos >= 0) { m2 = call_render_line_offset(focus, m, xypos); + if (m2) { + wint_t c = doc_following(focus, m2); + if (c == WEOF || is_eol(c)) + /* after last char on line - no action. */ + action = NULL; + } + } } if (m2) { char *tag, *xyattr;