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 17:39:57 +0300 Message-ID: <86msitd0oy.fsf@gnu.org> References: <86sesndz8v.fsf@gnu.org> <86ed46en1q.fsf@gnu.org> <86seslddvs.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9613"; 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 16:41:11 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 1t3z1T-0002KC-9H for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Oct 2024 16:41:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3z0m-0004jk-Oh; Thu, 24 Oct 2024 10:40: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 1t3z0k-0004jZ-Tj for emacs-devel@gnu.org; Thu, 24 Oct 2024 10:40:27 -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 1t3z0k-0001hI-Ku; Thu, 24 Oct 2024 10:40:26 -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=H+Dlztn2lr1q8kHVHNL/2jA9tWFmLulwNRCdlaJsgYo=; b=bRTvrOq16ze7 wwSSLcxIYEGkE71MniDOBHCb0AzhNCrKq7ALtOH9GPD9WY4VW71K9KHcCb2if08/kLx4Zj+rWfr+0 3bjlciF3h+Zf1tP02wnQKRXl0s/10JlK6vU1IXtAaTpqvCfdqDREa8krOoWH3Y/7zpYuEZTNFLIA4 m5bt1odJ68ahMFApsqZeJ9sZWVKOukcoK7Rx+DR+WL7PV/rCG6DVj+boB0TOlcsYW8gs4gby5ng1s hyvkqou1/d6WWsM4AjOsVApvu7Efw2A7k29SPrYpH0WiJp/X6W8s77aJ+Dio16e+Ca6o8yWhokbzg bqcX5J4jcva2uwFdnzfXgw==; In-Reply-To: (message from Jimmy Yuen Ho Wong on Thu, 24 Oct 2024 15:26:46 +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:324819 Archived-At: > From: Jimmy Yuen Ho Wong > Date: Thu, 24 Oct 2024 15:26:46 +0100 > Cc: emacs-devel@gnu.org > > 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. 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. (Assuming I understood what you were describing.)