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: Would True Colour to ANSI 8-bit palette conversion be useful Date: Fri, 14 Jun 2024 14:14:19 +0300 Message-ID: <86le37ydx0.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39970"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?Q?Micha=C5=82?= Nazarewicz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 14 13:15:30 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 1sI4u2-000ABg-F5 for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Jun 2024 13:15:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sI4tB-0000nD-Uv; Fri, 14 Jun 2024 07:14:39 -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 1sI4t1-0000jH-Ul for emacs-devel@gnu.org; Fri, 14 Jun 2024 07:14:28 -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 1sI4t0-0001Jx-BO; Fri, 14 Jun 2024 07:14:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=wy/hf5/XtRGiW4o5jpygiusJHk0lDDCewSdz19wSVO0=; b=L1/BtCuHjpgJWky+vvDq gcGOSXnnc3NGcCxIkJGEH2fXBZIsQPRfBgC4vlI/paeRB8kBnyk0BxmRVxj+vs59U9XQTMT1N8bTw voPT01DVxaSaQn3iseQQDInFqNM5C3Y8Y5/u2uuLZG5P1++XBUkVI72wH+1dY6YeSz/aXIddBneFV Ha2UljUz17zno5AB5kyS8lXOIh+uEHdBlp650PQ21KphlJ3kdjd7cIRczO3+l4KY623+8d6v6Poq7 Q8GBuYvlXx7zBNuPaIf0IA6tLZ6a7DJcOaUjRzDoDa4QLYsXccvNPGMnXVokMP5L/Uyi9ngRFsZs+ 65Uz4dCF18q8uw==; In-Reply-To: (message from =?utf-8?Q?Micha=C5=82?= Nazarewicz on Fri, 14 Jun 2024 06:01:19 -0400) 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:320062 Archived-At: > From: Michał Nazarewicz > Date: Fri, 14 Jun 2024 06:01:19 -0400 > > A while back I wrote https://github.com/mina86/ansi_colours which > takes 24-bit RGB colour and spits out the best matching entry from > ANSI 8-bit palette. I’ve recently looked through NEWS and noticed > changes related to the true colour support on the terminal. > > This got me wondering whether a feature to do True Colour -> ANSI > conversion would be useful somewhere in Emacs. The typical usage is > where the user specifies 24-bit colour but the terminal supports the > 8-bit palette only. Maybe I misunderstand what you mean by that, but Emacs already attempts to find the best color of the N colors the terminal actually supports that approximates the color specified by a face. That includes the case of only 8 supported colors. See tty-colors.el. This transparent color approximation exists in Emacs since v21.1, and it was necessary to let Lisp programs specify X colors without worrying too much about what will happen on TTY frames. If the approximation implemented in tty-color-approximate is not what you have in mind, please tell more about your ideas. Thanks.