From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jimmy Yuen Ho Wong Newsgroups: gmane.emacs.devel Subject: Re: Need `truncate-string-to-pixel-width` and `glyph-pixel-width` functions in C Date: Thu, 24 Oct 2024 15:26:46 +0100 Message-ID: References: <86sesndz8v.fsf@gnu.org> <86ed46en1q.fsf@gnu.org> <86seslddvs.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f924a8062539cc01" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32471"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 24 16:28:14 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t3yov-0008KG-PL for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Oct 2024 16:28:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3yoC-0002eh-OH; Thu, 24 Oct 2024 10:27:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3yoA-0002eY-8s for emacs-devel@gnu.org; Thu, 24 Oct 2024 10:27:26 -0400 Original-Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3yo8-000799-Q2; Thu, 24 Oct 2024 10:27:26 -0400 Original-Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-6cbceb321b3so6443626d6.3; Thu, 24 Oct 2024 07:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729780042; x=1730384842; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1b2hudO78DFKgIKVw2Pdle5ca8ZeTl7jd9Opz+x6cI0=; b=KRWm+3pux/9Uytz3SnAlKDrA9410caqaBiwqoNy/FmnFSWJCMSg03hpV/GGIjZwzY2 a43dQT2LXaPurgslbgfTfrknPiehL3L6elg/+oBlz4zNvRyrcolwIWEiYQVS5duuzsm4 qclcF7rvS6kd7RDk4euZcHWFjbujdvWLGYdShWHL1Z+SqjALXcBEAnqKhRmFmtfeDP7L NFjJEvwR9aPELkFoJSo+qhEKDiRtfK+eAtZ2YClYUnDAW749soHzDopgPOUzDjlXiCsw PQyJgIOpeOl4x+NDXmg54Hx4w1gnibMP69rH7cweANFzVvG3cvl7Poo+6h32MvDoOYVC tyPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729780042; x=1730384842; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1b2hudO78DFKgIKVw2Pdle5ca8ZeTl7jd9Opz+x6cI0=; b=kBep7dFkjR+X3js9menOLSnMrzkiWMTNTIwX2pLBUXhAQ8cZ+zI4UyfcatiHl44Z6F Iv51xZL5xKHpbTAgQ3+V0NHhdnsgOEEd7GsoIVla7oMloSOSpY6iGY0HItm5mD+9CRC0 KFt9zM+nUyV8IsG+yTOXomsrER2r2Zz7OYFJqOldD6uz1Xm8wlSfHxjTR5f01JoDKDf+ FBFwUueiFNbkOKrELnwmojZYaNJkVCSmKBfbAffmmf6XXIHzsFlbNzD0PZgf04yPENJQ Ss1yl0axTmJ6pG1G0kYTohn5wgdV3AB9zl89m4gbglFecp/ny2MHBzYvbF0mFHkbV+T3 QDyg== X-Gm-Message-State: AOJu0YxpXa61lgpRqwCmysUdj2LR1zyyZB+SKiCKbQA0xcfMSNOOh9JC C7V07Zk5pdfnIMAOY2iyFQhJ7jMi6N62GPNmPPVALL/Ep6X0KbaPm6hMenR9RqaM5TFXKB0weA8 1HQtKkfJUQm/HweuFswpXWNaO+8NEk6c9 X-Google-Smtp-Source: AGHT+IGId2V7Sb47CdtghRVGfgRRWcolyVBdVCWL0koWmrPTx6IEJ3KFyYeArbnkz/51aBilLwd1zKUc1UNLuejp1oY= X-Received: by 2002:a05:6214:5a13:b0:6cb:fa32:6ac4 with SMTP id 6a1803df08f44-6d091363e29mr18909716d6.30.1729780042503; Thu, 24 Oct 2024 07:27:22 -0700 (PDT) In-Reply-To: <86seslddvs.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=wyuenho@gmail.com; helo=mail-qv1-xf34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324818 Archived-At: --000000000000f924a8062539cc01 Content-Type: text/plain; charset="UTF-8" > > So let me see if I understand the issue. You want to create in a > child frame a display such as below: > > > > ... > > And you want to do it in a way that all the "Type"s are aligned to the > right (i.e. end at the right edge of the frame), no matter what is > shown in the s and in the s, which could be of > different width and could include characters of different fonts and > even images/emoji. Is that correct, or is there something else? > > If the above is what you want, and since the popup is actually a > frame, my first suggestion would be to use :align-to display property > on the whitespace between the s and the s. Did you > try that? > > The advantage of :align-to is that you don't have to measure the > pixel-width of the candidate names, only the pixel-width of each > string (to correctly set up the offset from the right edge of > the text area) -- the rest will be done by the display engine. And > the display engine always does everything in pixel resolution. > The current implementation wraps every line with some additional margin and a custom thin scrollbar after formatting, both are propertized strings with a display space property, before giving the final result to a buffer and then the child frame. Letting the windowing system to do truncation will truncate off the custom scrollbar and margin first, in addition to breaking an existing API that downstream extension packages rely on and being a much larger refactoring that will bring forth the much thicker and intrusive default Emacs scroll bars. Otherwise, this will work. --000000000000f924a8062539cc01 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
So let me see if I understand the issue.=C2=A0 You want = to create in a
child frame a display such as below:

=C2=A0 <icon1><candidate1>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Type1>
=C2=A0 <icon2><longer-name-candidate>=C2=A0 =C2=A0 =C2=A0<An= otherType>
=C2=A0 ...

And you want to do it in a way that all the "Type"s are aligned t= o the
right (i.e. end at the right edge of the frame), no matter what is
shown in the <icon>s and in the <candidate>s, which could be of=
different width and could include characters of different fonts and
even images/emoji.=C2=A0 Is that correct, or is there something else?

If the above is what you want, and since the popup is actually a
frame, my first suggestion would be to use :align-to display property
on the whitespace between the <candidate>s and the <Type>s.=C2= =A0 Did you
try that?

The advantage of :align-to is that you don't have to measure the
pixel-width of the candidate names, only the pixel-width of each
<Type> string (to correctly set up the offset from the right edge of<= br> the text area) -- the rest will be done by the display engine.=C2=A0 And the display engine always does everything in pixel resolution.

The current implementation wraps every line with some addition= al margin and a custom thin scrollbar after formatting, both are propertize= d strings with a display space property, before giving the final result to = a buffer and then the child frame. Letting the windowing system to do trunc= ation will truncate off the custom scrollbar and margin first, in addition = to breaking an existing API that downstream extension packages rely on and = being a much larger refactoring that will bring forth the much thicker and = intrusive default Emacs scroll bars. Otherwise, this will work.
--000000000000f924a8062539cc01--