From 9d3c8758e365c2e4e6399908c3c5bdf613753e08 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 19 Oct 2023 08:56:03 +1100 Subject: [PATCH] Add a "prepare" action on mouse-down. 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 --- mode-basic.c | 3 ++- python/lib-url.py | 7 ++++--- render-lines.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mode-basic.c b/mode-basic.c index e8974ea4..5e0e3dbf 100644 --- a/mode-basic.c +++ b/mode-basic.c @@ -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); diff --git a/python/lib-url.py b/python/lib-url.py index d368ee07..e0176dbc 100644 --- a/python/lib-url.py +++ b/python/lib-url.py @@ -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: diff --git a/render-lines.c b/render-lines.c index 89b60d14..74abef49 100644 --- a/render-lines.c +++ b/render-lines.c @@ -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; } -- 2.39.5