emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Highlighting discontinuous spans of text on mouseover


From: hugo
Subject: Highlighting discontinuous spans of text on mouseover
Date: Thu, 11 Apr 2024 09:21:02 +0100
User-agent: Roundcube Webmail/1.6.0

I'm implementing [OSC8 hyperlinks] in [Eat]. My work so far is in this
[PR]. The OSC8 spec defines terminal escape codes for marking up
hyperlinks. These /must/ include a uri (which the link points to) and
can optionally include other parameters, like an id. Links should be
highlighted in some way (e.g. by a certain colour or font or effect)
on mouseover.

At the moment, I'm printing links as buttons, by manually setting the
relevant text properties as we write into the buffer. This handles the
highlighting nicely: I just set the `mouse-face' property to the
relevant face. See the PR for the details.

Now my problem: For reasons made clear in the spec, any two links in
the same terminal buffer with the same id param /and/ uri must be
highlighted together, regardless of whether the text of the two links
is continuous. So if there are two, discontinuous links with the same
uri and id, and I mouseover one, both should be highlighted. When I
mouse off, neither should be highlighted. Thus they should appear to
the user as one link (though discontinuous on the screen). Just using
buttons and mouse-face doesn't handle this. *Is there a
standard/expected way to do this?*

I ask mostly because my current rough plan for an implementation
involves manually tracking mouse events over a button and running a
function to manually highlight/unhighlight any other relevant regions
in the buffer. This seems very complicated, I thought there might be a
simpler solution.

Any help appreciated -- full solutions or rough thoughts.

Best,

Hugo


[OSC8 hyperlinks]
<https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>

[Eat] <https://codeberg.org/akib/emacs-eat>

[PR] <https://codeberg.org/akib/emacs-eat/pulls/147>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]