]> git.neil.brown.name Git - edlib.git/commitdiff
Move-CursorXY - only perform action on direct hit.
authorNeilBrown <neil@brown.name>
Tue, 18 Jul 2023 11:32:48 +0000 (21:32 +1000)
committerNeilBrown <neil@brown.name>
Tue, 18 Jul 2023 11:51:36 +0000 (21:51 +1000)
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 <neil@brown.name>
DOC/Developer/06-rendering.md
render-lines.c

index a27fb95b26814361ab96adaaf32b38bf082f43e6..c7fda0e782219d88ea626db0bfd4c71b50f2b6eb 100644 (file)
@@ -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
index ab1c6fa47e8ae8fc6050a9e6fd3d9a8a16fc727d..95b23140b143c521a79d512322dbe1a321fd45a4 100644 (file)
@@ -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;