From: NeilBrown Date: Wed, 7 Jun 2023 22:36:45 +0000 (+1000) Subject: lib-url: only follow link one it has been shown in message-line X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=7df5f2470fa7f09f8864f9f85a7036f4fbb29ceb;p=edlib.git lib-url: only follow link one it has been shown in message-line The first time a url is activated, only display it and don't follow it. The second time it can be followed. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 03c3ec9b..94ae699f 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -23,7 +23,7 @@ the file. don't catch it... - [X] notmuch reply should interpolate the first *visible* text part - [X] ncurses - don't block in nc_external_viewer - at least abort after - 30 seconds, but preferrably switch to a mode which leaves + 30 seconds, but preferably switch to a mode which leaves everything else running. - [X] lang-python should put each module in a separate module Maybe PyImport_ExecCodeModuleEx() after reading and compile()ing @@ -33,7 +33,7 @@ the file. - [ ] add event:on-idle with 3 priority levels - [X] Always do word-count async. -- [ ] lib-url +- [X] lib-url - [ ] lib-mergeview improvements - [ ] lib-diff slowness with large diff - [ ] linecount :when used in 'view' mode, stack the counting pane with all the @@ -738,7 +738,7 @@ Module features - [X] handlers for that markup. xdg-open for links, maybe signal register email client for mailto: links. - [X] easy way for K:Enter on a link to do just like mouse-click -- [ ] email: urls should not be followed unless they are visible. +- [X] email: urls should not be followed unless they are visible. Maybe display in the message window, which might be made larger just for this purpose. Maybe "Message-button" diff --git a/python/lib-url.py b/python/lib-url.py index 46ff789f..bc313cff 100644 --- a/python/lib-url.py +++ b/python/lib-url.py @@ -55,6 +55,7 @@ def attach_url(key, focus, comm2, **a): class url_view(edlib.Pane): def __init__(self, focus): edlib.Pane.__init__(self, focus) + self.displayed_tag = None def handle_map_attr(self, key, focus, mark, str1, str2, comm2, **a): "handle:map-attr" @@ -89,8 +90,10 @@ class url_view(edlib.Pane): # or might be in main document url = focus["url:" + tag] if url: - focus.call("Message", "Opening url [%s] <%s>" % (tag,url)) - focus.call("Display:external-viewer", url) + focus.call("Message", "Url: <%s>" % url) + if self.displayed_tag == tag: + focus.call("Display:external-viewer", url) + self.displayed_tag = tag else: focus.call("Message", "URL tag %s not found" % tag) return 1