From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Need `truncate-string-to-pixel-width` and `glyph-pixel-width` functions in C Date: Thu, 24 Oct 2024 19:02:48 +0300 Message-ID: <86h691cwuv.fsf@gnu.org> References: <86sesndz8v.fsf@gnu.org> <86ed46en1q.fsf@gnu.org> <86seslddvs.fsf@gnu.org> <86msitd0oy.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1797"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jimmy Yuen Ho Wong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 24 18:03:43 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 1t40JK-0000Iq-3x for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Oct 2024 18:03:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t40If-00043r-8t; Thu, 24 Oct 2024 12:03:01 -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 1t40IZ-0003sk-Jl for emacs-devel@gnu.org; Thu, 24 Oct 2024 12:02:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t40IZ-0004iE-38; Thu, 24 Oct 2024 12:02:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ba57JKJ/i7900AXmyoj8v9xoRVVKfBsoBUnkwNMTTIs=; b=As+CnWE3+4bE 1MiWi1DzjR2/ZpcCA+Np/5q4NoaOcY6u2SdqwRCMPVxq9Lf88KtQYwOO+4FDs15Gai95AGDgFd/FD fA3QHDWNdQVR1TADxhGNrB744gHHd6YTAGK4guP2OCIG1b9c5ySUtHl9X1HqXCjCiBCrnWIkcLcRz TrFA1pYwLsIvsJBCsrgNW34NJMUrVvpHiL+jSY5ZiTMSvL96KjH5Hue98LBenwq07SGY5sFAdikUJ DpOLihgPkwV5Rdiu41IO+NhP/bmxKamKruQGHs6VvHQHmzWQZzFBD79O+4dGZlKdhfFAOLYdddYOi wcq4+Wzh7vxsKhxpwjDXOA==; In-Reply-To: (message from Jimmy Yuen Ho Wong on Thu, 24 Oct 2024 16:33:14 +0100) 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:324823 Archived-At: > From: Jimmy Yuen Ho Wong > 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.