]> git.neil.brown.name Git - edlib.git/commitdiff
lib-url: only follow link one it has been shown in message-line
authorNeilBrown <neil@brown.name>
Wed, 7 Jun 2023 22:36:45 +0000 (08:36 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 05:40:21 +0000 (15:40 +1000)
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 <neil@brown.name>
DOC/TODO.md
python/lib-url.py

index 03c3ec9b8deab580db47ed385efd09bbedb54ab5..94ae699fb95e88b41181c8b409499c1a406b1a26 100644 (file)
@@ -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"
index 46ff789f65bc8144f1cd4791e1d1a74e02610145..bc313cff3ac1121cd508cf7dfa2b4b84dedb4394 100644 (file)
@@ -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