unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Highlighting discontinuous spans of text on mouseover
@ 2024-04-11  8:21 hugo
  2024-04-11 10:56 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: hugo @ 2024-04-11  8:21 UTC (permalink / raw)
  To: emacs-devel

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>



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Highlighting discontinuous spans of text on mouseover
  2024-04-11  8:21 Highlighting discontinuous spans of text on mouseover hugo
@ 2024-04-11 10:56 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2024-04-11 10:56 UTC (permalink / raw)
  To: hugo; +Cc: emacs-devel

> Date: Thu, 11 Apr 2024 09:21:02 +0100
> From: hugo@heagren.com
> 
> 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?*

The Emacs display engine supports mouse-highlight only of a single
contiguous portion of buffer text or string.  (The highlighted portion
can be non-contiguous on display due to bidi reordering, but it must
be contiguous in the order of the buffer or string positions.)
Supporting more than one highlighted portion would require changes of
the display code on the C level.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-11 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11  8:21 Highlighting discontinuous spans of text on mouseover hugo
2024-04-11 10:56 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).