unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
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 17:49:27 +0100	[thread overview]
Message-ID: <CAKDRQS4Jo70qUoqj-SGOTs+fZuoe2XzxtMRW5U0WEwLq0RAmcQ@mail.gmail.com> (raw)
In-Reply-To: <86h691cwuv.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]

>
> 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"?
>

That thin white bar on the right of the box from the third screenshot
onwards is actually a string with a display space property in pixels, not a
real scroll bar.

Using :align-to in the padding between the candidate and annotation is not
a problem, the problem is if the concatenated line is too long, I'll need
to truncate. There are 2 options - `truncate-string-to-width`, which is
bugged, or set the `truncate-line` buffer local to t and let Emacs' window
system do its magic, which will be performant and correct, and I can even
replace the arrow in an ellipsis, but truncation will start to truncate off
the emulated scroll bar.


> 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.
>

As I described in my first email, this can almost be achieved from the
existing Elisp functions and C functions exposed Elisp. The performance
problem associated with resolving a font WRT the anonymous face and face
list craziness can be done in C, and already exists. The width of the
display space and string replacement text properties can be calculated by
`check_display_width` in `indent.c`, and rest is surely somewhere in
`image.c`. I hope you are not telling me that Emacs devs still refuse to
give people the ability to align text in pixel precisions programmatically
at the end of 2024. Browsers have had this ability for almost 30 years.

[-- Attachment #2: Type: text/html, Size: 2432 bytes --]

  reply	other threads:[~2024-10-24 16:49 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
2024-10-24 16:49                   ` Jimmy Yuen Ho Wong [this message]
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=CAKDRQS4Jo70qUoqj-SGOTs+fZuoe2XzxtMRW5U0WEwLq0RAmcQ@mail.gmail.com \
    --to=wyuenho@gmail.com \
    --cc=eliz@gnu.org \
    --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).