unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: hugo@heagren.com
To: emacs-devel@gnu.org
Subject: Highlighting discontinuous spans of text on mouseover
Date: Thu, 11 Apr 2024 09:21:02 +0100	[thread overview]
Message-ID: <d51f3bf89f7943ab83936c5a636f74d9@heagren.com> (raw)

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	other threads:[~2024-04-11  8:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  8:21 hugo [this message]
2024-04-11 10:56 ` Highlighting discontinuous spans of text on mouseover Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d51f3bf89f7943ab83936c5a636f74d9@heagren.com \
    --to=hugo@heagren.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).