unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Need `truncate-string-to-pixel-width` and `glyph-pixel-width` functions in C
Date: Thu, 24 Oct 2024 19:02:48 +0300	[thread overview]
Message-ID: <86h691cwuv.fsf@gnu.org> (raw)
In-Reply-To: <CAKDRQS6LxTMxmni8CeVhCkES_7AAWC4+EFav4K1v=92xnJ1wMQ@mail.gmail.com> (message from Jimmy Yuen Ho Wong on Thu, 24 Oct 2024 16:33:14 +0100)

> From: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
> Date: Thu, 24 Oct 2024 16:33:14 +0100
> Cc: emacs-devel@gnu.org
> 
>  If the scroll bar and the margin are generated programmatically, then
>  presumably the program which creates them knows their width, or can
>  calculate that?  If so, the :align-to value should take that into
>  consideration.
> 
> As I said, the problem is letting the window system do the truncation rather than in code. There's no way to
> tell Emacs to start truncating from the actual content rather than UI elements that Emacs thinks are content.

I guess I don't understand the issue you are describing.  Where does
window system come into play here?  What are "UI elements that Emacs
thinks are content", and where are they in the screenshots shown in
https://github.com/minad/corfu/pull/508 ?  And where in my suggestion
did I propose anything that would cause "truncation by window system"?

> Hence, the original ask. Correct and performant custom truncation that respects pixel width is much much
> harder than it should be in Emacs.

Lisp programs are not supposed to do layout calculations, plain and
simple.  The reason is that layout calculations are impossible without
having a window with lots of stuff that determines how text is
displayed.  So doing that on strings is meaningless.

Therefore, I'm trying to help you do the job using the existing
display facilities, because the kind of solution you have in mind is
unlikely to emerge.  If you want me to keep coming up with ideas,
please help me understand better the issues you are describing.  I
hope you do realize that to suggest viable solutions, I need to have a
good understanding of the problem.

But if my suggestions and questions annoy you, I can easily stop.



  reply	other threads:[~2024-10-24 16:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  5:01 Need `truncate-string-to-pixel-width` and `glyph-pixel-width` functions in C Jimmy Yuen Ho Wong
2024-10-23  8:01 ` Eli Zaretskii
2024-10-23 13:52   ` Jimmy Yuen Ho Wong
2024-10-23 17:39     ` Eli Zaretskii
2024-10-23 20:03       ` Jimmy Yuen Ho Wong
2024-10-24  9:55         ` Eli Zaretskii
2024-10-24 14:26           ` Jimmy Yuen Ho Wong
2024-10-24 14:39             ` Eli Zaretskii
2024-10-24 15:33               ` Jimmy Yuen Ho Wong
2024-10-24 16:02                 ` Eli Zaretskii [this message]
2024-10-24 16:49                   ` Jimmy Yuen Ho Wong
2024-10-24 17:56                     ` Eli Zaretskii
2024-10-24 21:11                       ` Jimmy Yuen Ho Wong
2024-10-25  7:21                         ` Eli Zaretskii
2024-10-25 13:35                           ` Jimmy Yuen Ho Wong
2024-10-25 15:11                             ` Eli Zaretskii
2024-10-28 20:21                               ` Jimmy Yuen Ho Wong

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=86h691cwuv.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=wyuenho@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).