unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Vladimir Kazanov <vekazanov@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] User-defined fringe tooltips (a request for review)
Date: Thu, 21 Dec 2023 19:37:07 +0200	[thread overview]
Message-ID: <83plyzfoe4.fsf@gnu.org> (raw)
In-Reply-To: <CAAs=0-1bHkfPtqLS-99SvAbtW+Q-NmaEBR3r8kPDz_soqPNiBA@mail.gmail.com> (message from Vladimir Kazanov on Thu, 21 Dec 2023 16:51:15 +0000)

> From: Vladimir Kazanov <vekazanov@gmail.com>
> Date: Thu, 21 Dec 2023 16:51:15 +0000
> Cc: emacs-devel@gnu.org
> 
> > The code in note_mouse_highlight examines
> > the buffer text and overlays for text properties whose meaning is to
> > display a help-echo string, so why cannot you do the same to look for
> > a 'display' property of this specific structure, and extract the
> > help-echo directly from there at mouse-highlight time instead of at
> > glyph-generation time?
> 
> Yes, having Lispy stuff in the glyph_row struct doesn't make sense,
> and this is why I was in doubt.
> 
> Anyway, a new patch is attached with the approach you suggested (the
> way I understood it). I use "struct it" to iterate over the line for
> which the fringe indicator is defined, in note_mouse_highlight. The
> iterator then pulls out the display spec and saves the last left/right
> fringe captions it walked over.
> 
> Does that feel right?

No, there's no need to use the iterator.  Just look at the positions
recorded in the glyphs of the relevant glyph_row, and then look up
text properties at those positions using Fget_char_property etc., like
we already do to look for the 'help-echo' property in the same
function.  Here's a typical fragment:

	    Lisp_Object obj = glyph->object;
	    ptrdiff_t charpos = glyph->charpos;

	    /* Try text properties.  */
	    if (STRINGP (obj)
		&& charpos >= 0
		&& charpos < SCHARS (obj))
	      {
		help = Fget_text_property (make_fixnum (charpos),
					   Qhelp_echo, obj);

Since the 'display' property that shows a fringe bitmap can be on any
character of a screen line, you will need to loop over all the glyphs
of the glyph_row where the mouse pointer is, testing the 'display'
property as above.  Something like this:

  for (glyph = row->glyphs[TEXT_AREA];
       glyph < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
       glyph++)

where 'row' is

   row = MATRIX_ROW (w->current_matrix, vpos);

and 'vpos' is returned by this call which we already have in
note_mouse_highlight:

      /* Find the glyph under X/Y.  */
      glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area);

If Fget_text_property returns non-nil for the 'display' property, you
will then need to look at the value and see whether it specifies a
help-echo for the fringe; if it does, extract the string and assign it
to 'help_echo_string'.

Then you won't need to use 'struct it', and won't need any new caption
members in 'struct it'.

Thanks.



  reply	other threads:[~2023-12-21 17:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-19 19:38 [PATCH] User-defined fringe tooltips (a request for review) Vladimir Kazanov
2023-12-20 12:31 ` Eli Zaretskii
2023-12-21 16:51   ` Vladimir Kazanov
2023-12-21 17:37     ` Eli Zaretskii [this message]
2023-12-23 13:28       ` Vladimir Kazanov
2023-12-23 13:40         ` Eli Zaretskii
2023-12-24 11:31           ` Vladimir Kazanov
2023-12-24 16:54             ` Eli Zaretskii
2024-03-25 15:55               ` Vladimir Kazanov
2024-03-25 17:11                 ` Eli Zaretskii
2024-03-26 22:16                   ` Vladimir Kazanov
2024-03-27 10:59                     ` Vladimir Kazanov
2024-03-27 11:25                       ` Po Lu
2024-03-27 12:48                         ` Vladimir Kazanov
2024-03-27 11:25                       ` Po Lu
2024-03-31  8:36                       ` Eli Zaretskii
2024-04-07 11:14                         ` Vladimir Kazanov
2024-04-07 12:44                           ` Eli Zaretskii
2024-04-07 17:07                             ` Vladimir Kazanov
2024-04-07 18:40                               ` Eli Zaretskii
2024-04-08 14:41                                 ` Vladimir Kazanov
2024-04-13  9:14                                   ` Eli Zaretskii
2024-04-13  9:32                                     ` Vladimir Kazanov
2024-04-13 11:21                                       ` Eli Zaretskii
2024-04-13 14:53                                         ` Vladimir Kazanov
2024-04-13 15:47                                           ` Eli Zaretskii
2024-03-27 12:14                     ` Eli Zaretskii
2024-03-27 12:48                       ` Vladimir Kazanov

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=83plyzfoe4.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=vekazanov@gmail.com \
    /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).