]> git.neil.brown.name Git - edlib.git/commitdiff
Add a "prepare" action on mouse-down.
authorNeilBrown <neil@brown.name>
Wed, 18 Oct 2023 21:56:03 +0000 (08:56 +1100)
committerNeilBrown <neil@brown.name>
Thu, 19 Oct 2023 08:53:45 +0000 (19:53 +1100)
mouse-down sends "prepare"
mouse-up sends "activate"

lib-url uses this to show the url on down, and follow it on up.
The follow can be aborted by moving the mouse.

Signed-off-by: NeilBrown <neil@brown.name>
mode-basic.c
python/lib-url.py
render-lines.c

index e8974ea4864a56b802a569200cbf6406ebf7874c..5e0e3dbf2ead0f27a57d124f607af97a41dd535b 100644 (file)
@@ -183,7 +183,8 @@ DEF_CMD(basic_press)
                return Efallthrough;
        }
        /* NOTE must find new location before view changes. */
-       call("Move-CursorXY", ci->focus, 0, m, NULL, 0, NULL, NULL, ci->x, ci->y);
+       call("Move-CursorXY", ci->focus, 0, m, "prepare",
+            0, NULL, NULL, ci->x, ci->y);
 
        clear_selection(ci->focus, pt, mk, 0);
        call("Move-to", ci->focus, 0, m);
index d368ee07b7e5bc6deab10c4024c6d09996c4336c..e0176dbce98f83da2edc4037d8f43f081a0c04ec 100644 (file)
@@ -70,10 +70,11 @@ class url_view(edlib.Pane):
             if str1 == "render:url-end":
                 leng = -1
             comm2("attr:callback", focus, leng, mark,
-                  "fg:cyan-60,underline,action-activate:Activate:url,url-tag="+tg, 120)
+                  "fg:cyan-60,underline,action-prepare:Activate:url,"
+                  "action-activate:Activate:url,url-tag="+tg, 120)
             return 1
 
-    def handle_click(self, key, focus, mark, str1, **a):
+    def handle_click(self, key, focus, mark, str1, str2, **a):
         "handle:Activate:url"
         a = str1.split(',')
         tag=""
@@ -91,7 +92,7 @@ class url_view(edlib.Pane):
             url = focus["url:" + tag]
         if url:
             focus.call("Message", "Url: <%s>" % url)
-            if self.displayed_tag == tag:
+            if self.displayed_tag == tag and str2 != "prepare":
                 focus.call("Window:external-viewer", url)
             self.displayed_tag = tag
         else:
index 89b60d14af0f2b1c273341d5dd1fe3df0f9ca316..74abef49a2b647a937d71b345ff71401dd9ffd1f 100644 (file)
@@ -1594,7 +1594,7 @@ DEF_CMD(render_lines_set_cursor)
                                        ;
                                }
                                call(tag, focus, 0, m2, xyattr,
-                                    0, ci->mark, NULL,
+                                    0, ci->mark, action,
                                     cih.x, cih.y);
                        }
                        m = m2;
@@ -1639,7 +1639,7 @@ DEF_CMD(render_lines_action)
        tag = get_action_tag(ci->str, attr);
        if (!tag)
                return Efallthrough;
-       call(tag, focus, 0, m, attr);
+       call(tag, focus, 0, m, attr, 0, NULL, ci->str);
        return 1;
 }