From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 31 11:21:23 2018 Received: (at submit) by debbugs.gnu.org; 31 Jan 2018 16:21:23 +0000 Received: from localhost ([127.0.0.1]:51416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egv8U-0007F5-3l for submit@debbugs.gnu.org; Wed, 31 Jan 2018 11:21:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egow7-0005wX-EH for submit@debbugs.gnu.org; Wed, 31 Jan 2018 04:44:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egow1-0003tC-AX for submit@debbugs.gnu.org; Wed, 31 Jan 2018 04:44:06 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:38539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1egow1-0003t4-6Y for submit@debbugs.gnu.org; Wed, 31 Jan 2018 04:44:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egovz-0000wT-Sg for bug-gnu-emacs@gnu.org; Wed, 31 Jan 2018 04:44:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egovv-0003qn-T5 for bug-gnu-emacs@gnu.org; Wed, 31 Jan 2018 04:44:03 -0500 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:44782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egovv-0003q6-KC for bug-gnu-emacs@gnu.org; Wed, 31 Jan 2018 04:43:59 -0500 Received: by mail-lf0-x22d.google.com with SMTP id v188so19686418lfa.11 for ; Wed, 31 Jan 2018 01:43:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vincit.fi; s=ticniv; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E5pjBO58YEZ2/K/oGRWVHfN0kLLk/aHMusg11hNp5wc=; b=RDDRhjD8OBNRKZD10TAbIpgX56y/Y3CGv5G2nRvo46Pi9BOg4WXx5dAyUouhQWtBC4 n1GeGOZcc2yS9Nej6wOUclY+ZD99cTcTVnmCDXlrsJH36aFEqHFrCwBLZJUQ3cGZP/M4 nSRlqXqj7SpFfpHU4B3wTZTJdzFkJ0FTmAbOU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E5pjBO58YEZ2/K/oGRWVHfN0kLLk/aHMusg11hNp5wc=; b=NBMXd6VTgInpU5s7QDl6WuJ2H9nEJJd3LFj41b6FvfRyMmMWC47hH5NjmHeRJGjwSr iIKw8+nU4qMHBJVOzQM+7nWLafwOTrFYFt7sm2wjIHu5RmCac0fVvQlLhTtE1At0O0tk hKtth8BFYUpQWLR+gkmRS30lMQRlzAfnT2SJraZNCOt8mqG8h0Ex07pFALTJejtrnKmi Cp83tUGTcD9KYy/RZ521QbPGez/CnCjH05YrjNLpqtfRBLlQzpFhmXXdC/xEOLR7zm36 gzj1OAhtsb6SNcunDZQyx7fyUjUq3077McehvKUIEqh0lijrDcxNOeMrql3CJaoVEs7f Jcag== X-Gm-Message-State: AKwxytf70IhkZwEHLwUUDAaNLNA41sPVf5n7RjM28kpsBozPEqEyjD6G rgqDzTCs/P/dR9WG/sBzybF3XOysnHE= X-Google-Smtp-Source: AH8x224IpiGGjb9d+F46wEwfcwQS66C0DNep4/VlNBLr5AMhIGpPUEU06jwVwO3looSD9wojD2JyEA== X-Received: by 10.25.31.200 with SMTP id f191mr19052057lff.68.1517391837421; Wed, 31 Jan 2018 01:43:57 -0800 (PST) Received: from localhost.localdomain (gw.vincit.cloud. [195.60.252.249]) by smtp.gmail.com with ESMTPSA id e11sm1540882ljf.44.2018.01.31.01.43.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 01:43:56 -0800 (PST) From: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= To: bug-gnu-emacs@gnu.org Subject: 27.0.50; Support direct mode terminal definitions from latest Terminfo. Date: Wed, 31 Jan 2018 11:43:07 +0200 Message-Id: <20180131094308.24946-1-rami.ylimaki@vincit.fi> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 31 Jan 2018 11:21:20 -0500 Cc: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.4 (----) Direct mode terminal definitions from latest Terminfo are already compatible with Emacs 26.1 and later, but only if Terminfo library has been compiled to support 32-bit numerical capability values. Following patch adds support for Terminfo with 16-bit numerical capabilities. Rami Ylimäki (1): Support standard Terminfo direct mode terminals. doc/misc/efaq.texi | 45 +++++++++++++++++++++++++++------------------ src/term.c | 35 ++++++++++++++++++++++------------- src/tparam.h | 3 ++- 3 files changed, 51 insertions(+), 32 deletions(-) -- 2.14.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 31 11:36:28 2018 Received: (at submit) by debbugs.gnu.org; 31 Jan 2018 16:36:28 +0000 Received: from localhost ([127.0.0.1]:51425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egvN5-0007er-KW for submit@debbugs.gnu.org; Wed, 31 Jan 2018 11:36:28 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egowU-0005xG-1Q for submit@debbugs.gnu.org; Wed, 31 Jan 2018 04:44:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egowN-00040l-IB for submit@debbugs.gnu.org; Wed, 31 Jan 2018 04:44:29 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1egowN-00040f-EE for submit@debbugs.gnu.org; Wed, 31 Jan 2018 04:44:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egowL-0000yP-MZ for bug-gnu-emacs@gnu.org; Wed, 31 Jan 2018 04:44:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egowF-0003xr-B3 for bug-gnu-emacs@gnu.org; Wed, 31 Jan 2018 04:44:25 -0500 Received: from mail-lf0-x235.google.com ([2a00:1450:4010:c07::235]:42622) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egowE-0003xN-Vi for bug-gnu-emacs@gnu.org; Wed, 31 Jan 2018 04:44:19 -0500 Received: by mail-lf0-x235.google.com with SMTP id q17so19678187lfa.9 for ; Wed, 31 Jan 2018 01:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vincit.fi; s=ticniv; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=acr9NagMghbBhsb3iZ3KXS6Hsjrs2ip6OxHKRkGk1L8=; b=HuODxOCVunCyLoL1WEiWAIhVUbvuTl2Z047D2swUbs+AaV6Dkf+JRbaFKSIAY8IwJ7 O16DFs7iYspjQXWNR+SstRyDIWabUKCPvLgd2lWMy8a7KFE2HVDi2tZYr/kVdMLjbJU/ asYqlCWKgkhcRvwt5nxOE0hUzo6XL1ypAI608= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=acr9NagMghbBhsb3iZ3KXS6Hsjrs2ip6OxHKRkGk1L8=; b=ePnFbxcc6KhSQ8V29Liqp7BTDMBRI9YkgofiaDL86H7Ey0NHUK54s72llVpnzHr8lE Z/HMkWRAB7A9pbjm2UqwCWhx4gg/quE689EZDUGBmU5Q1oRLtPV70q2t5zTTPCXar4XG oN10sl5KTN53lKdnEbU/IEstL8StwTAOxv0s3XSGzGdv7aZlXyyi4N+2pMwryHZ/OvBm +Pew1BXClTXkI8b8fHLQmnwbFMAOsLsToGvqEifITMs1wes+1rm22gp3FIzTZkgsDYWR Q+6FPpMcFv7KQAfZEZzTe5N6LG8NHLvEb17WKJA9FykqPmwmuxT+jaeHCzHBvIePq4VA haog== X-Gm-Message-State: AKwxytc55l8bhx565Yo4WCvu3+jZpQNEROJ0JqJmKcp6cge+d0d0P0k4 cpqg7ZlAtnp1FK47vDOXXb8Us9wyA+Q= X-Google-Smtp-Source: AH8x2278AsfKPtQw/2e+bGvV6RWpIU3pqp5uS527TcoenDTgpUb5HK4xRRUxzWxo4GPnKTAy2qLRLQ== X-Received: by 10.25.224.17 with SMTP id x17mr18604637lfg.91.1517391857291; Wed, 31 Jan 2018 01:44:17 -0800 (PST) Received: from localhost.localdomain (gw.vincit.cloud. [195.60.252.249]) by smtp.gmail.com with ESMTPSA id e11sm1540882ljf.44.2018.01.31.01.44.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 01:44:16 -0800 (PST) From: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= To: bug-gnu-emacs@gnu.org Subject: [PATCH 1/1] Support standard Terminfo direct mode terminals. Date: Wed, 31 Jan 2018 11:43:08 +0200 Message-Id: <20180131094308.24946-2-rami.ylimaki@vincit.fi> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180131094308.24946-1-rami.ylimaki@vincit.fi> References: <20180131094308.24946-1-rami.ylimaki@vincit.fi> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.4 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 31 Jan 2018 11:36:26 -0500 Cc: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.4 (----) Latest Terminfo introduces terminal definitions that support direct color mode. The "Co"/"colors" capability is set to 0x1000000 on these terminals and Emacs is already compatible with them. However, if used Terminfo library hasn't been compiled with 32-bit value support, "Co"/"colors" is truncated to 0x7fff. In this case direct color mode support can be detected from the "RGB" capability flag. There are some minor problems if the color count isn't corrected from 0x7fff. First eight standard colors defined in xterm-standard-colors are shown correctly. However, their RGB values match the terminal settings, not the RGB values defined in xterm-standard-colors. Bright versions of these colors are shown incorrectly. They are interpreted as pixels #000008 - #000015, which are very dark shades of blue. * src/term.c (init_tty): Force terminal color count to 0x1000000 if "RGB" capability is present. * src/tparam.h: Define prototype for tigetflag. * doc/misc/efaq.texi (Colors on a TTY): Add information about direct mode terminals supported by Terminfo. --- doc/misc/efaq.texi | 45 +++++++++++++++++++++++++++------------------ src/term.c | 35 ++++++++++++++++++++++------------- src/tparam.h | 3 ++- 3 files changed, 51 insertions(+), 32 deletions(-) diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 3e67438ab9..fef9b1051b 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -1496,32 +1496,41 @@ Colors on a TTY take one 24-bit pixel value as argument and transform the pixel to a string that can be used to send 24-bit colors to the terminal. -There aren't yet any standard terminal type definitions that would -support the capabilities, but Emacs can be invoked with a custom -definition as shown below. +Standard terminal definitions don't support these capabilities and +therefore custom definition is needed. @example -$ cat terminfo-24bit.src +$ cat terminfo-custom.src -# Use colon separators. -xterm-24bit|xterm with 24-bit direct color mode, +xterm-emacs|xterm with 24-bit direct color mode for Emacs, use=xterm-256color, - setb24=\E[48:2:%p1%@{65536@}%/%d:%p1%@{256@}%/%@{255@}%&%d:%p1%@{255@}%&%dm, - setf24=\E[38:2:%p1%@{65536@}%/%d:%p1%@{256@}%/%@{255@}%&%d:%p1%@{255@}%&%dm, -# Use semicolon separators. -xterm-24bits|xterm with 24-bit direct color mode, - use=xterm-256color, - setb24=\E[48;2;%p1%@{65536@}%/%d;%p1%@{256@}%/%@{255@}%&%d;%p1%@{255@}%&%dm, - setf24=\E[38;2;%p1%@{65536@}%/%d;%p1%@{256@}%/%@{255@}%&%d;%p1%@{255@}%&%dm, + setb24=\E[48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%dm, + setf24=\E[38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%dm, + +$ tic -x -o ~/.terminfo terminfo-custom.src + +$ TERM=xterm-emacs emacs -nw +@end example + +Emacs 27.1 and later support Terminfo capability @samp{RGB} for +detecting 24-bit direct color mode. Multiple standard terminal +definitions support this capability. + +@example +$ TERM=xterm-direct infocmp | grep seta[bf] -$ tic -x -o ~/.terminfo terminfo-24bit.src + setab=\E[%?%p1%@{8@}%<%t4%p1%d%e48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, + setaf=\E[%?%p1%@{8@}%<%t3%p1%d%e38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, -$ TERM=xterm-24bit emacs -nw +$ TERM=xterm-direct emacs -nw @end example -Currently there's no standard way to determine whether a terminal -supports direct color mode. If such standard arises later on, support -for @samp{setb24} and @samp{setf24} may be removed. +Terminals with @samp{RGB} capability treat pixels #000001 - #000007 as +indexed colors to maintain backward compatibility with applications +that are unaware of direct color mode. Therefore the seven darkest +blue shades may not be available. If this is a problem, you can +always use custom terminal definition with @samp{setb24} and +@samp{setf24}. @node Debugging a customization file @section How do I debug a @file{.emacs} file? diff --git a/src/term.c b/src/term.c index b3707da70a..5e41ca5f6b 100644 --- a/src/term.c +++ b/src/term.c @@ -4144,19 +4144,28 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ tty->TN_max_colors = tgetnum ("Co"); #ifdef TERMINFO - /* Non-standard support for 24-bit colors. */ - { - const char *fg = tigetstr ("setf24"); - const char *bg = tigetstr ("setb24"); - if (fg && bg - && fg != (char *) (intptr_t) -1 - && bg != (char *) (intptr_t) -1) - { - tty->TS_set_foreground = fg; - tty->TS_set_background = bg; - tty->TN_max_colors = 16777216; - } - } + /* Non-standard support for 24-bit colors. */ + if (tigetflag ("RGB") < 1) + { + const char *fg = tigetstr ("setf24"); + const char *bg = tigetstr ("setb24"); + const bool has_fg = fg && (fg != (char *) (intptr_t) -1); + const bool has_bg = bg && (bg != (char *) (intptr_t) -1); + if (has_fg && has_bg) + { + tty->TS_set_foreground = fg; + tty->TS_set_background = bg; + tty->TN_max_colors = 16777216; + } + } + /* Standard support for 24-bit colors. */ + else + { + /* If the used Terminfo library supports only 16-bit signed + values, tgetnum("Co") and tigetnum("colors") could return + 32767. */ + tty->TN_max_colors = 16777216; + } #endif tty->TN_no_color_video = tgetnum ("NC"); diff --git a/src/tparam.h b/src/tparam.h index f8fb9e0869..3a3cb52c17 100644 --- a/src/tparam.h +++ b/src/tparam.h @@ -37,7 +37,8 @@ extern char *BC; extern char *UP; #ifdef TERMINFO -char *tigetstr(const char *); +int tigetflag (const char *); +char *tigetstr (const char *); #endif #endif /* EMACS_TPARAM_H */ -- 2.14.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 31 12:01:00 2018 Received: (at 30308) by debbugs.gnu.org; 31 Jan 2018 17:01:00 +0000 Received: from localhost ([127.0.0.1]:51459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egvkp-0008Hb-Ua for submit@debbugs.gnu.org; Wed, 31 Jan 2018 12:01:00 -0500 Received: from mail-ot0-f180.google.com ([74.125.82.180]:34862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egvko-0008HP-9t for 30308@debbugs.gnu.org; Wed, 31 Jan 2018 12:00:59 -0500 Received: by mail-ot0-f180.google.com with SMTP id a2so2671588otf.2 for <30308@debbugs.gnu.org>; Wed, 31 Jan 2018 09:00:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vincit.fi; s=ticniv; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=LhgnSYdDfW0KsTHNt2gahiEX0agOvPxCChXpFdebX58=; b=H573/lscsZ++eg9HcD5kGSAZtePgrFqsRbf7NQ07zKdQIIbJzK/tSJLGAfjiv7XCxJ AtKZe1APhvbx6wVxOeEP5j6izbLy5fyQ/5W0R3HXglfBeFlIgnp816rP74Tu801YjOV1 0mDoQJ6Zn63DSCNoGbYYAWv6RCz8yyxTMK1o4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=LhgnSYdDfW0KsTHNt2gahiEX0agOvPxCChXpFdebX58=; b=iBu/kCWf/G4tgcmxQzMirrxrjkF9h0B66Hklegok1KIYOwB6pssealN/MwBwdHGqOo OFQu1agiSm0tChUyGfKlmzxv/0tbs0vO2J9gLgXqqxEw7SajQrQVFhKl8xdbyQeWSKl4 AO5UgtsZSkKxZUnhhPf97AUZQLJl7Ekrs+BQZdJoSh3BqTwSw5C+kJ/UqOAGer3DUZHY C2BBfSYtBjZgCZWHaZBNp7mEqbk+FKkgzcxtutAcEx/IB2BDQaa/QuzcHbkdZjIiOhfR 5hqaUROqwR1lc945TtKN55m0KCo2btPEPlRtcdFbLIEz1fgagOt9/GE+ny2GOCi5MTX9 soEg== X-Gm-Message-State: AKwxytdxiw65KYrV2W1nUSjVNqGfjFzICOQjSWao+1qebFkwLmtUenPa kZ2V8f3fPFIHV7kxcXyGpsst5cGjMbqemau/nTQx4HXu X-Google-Smtp-Source: AH8x227WV+CDV5pJ5LE72/jMTVEA6nPw7cZmVKgyE+RrrobiOTugNJSDnCWduhwwt0bVQ07i8snAPmtB8PW1fckYKes= X-Received: by 10.157.96.15 with SMTP id h15mr702923otj.267.1517418051202; Wed, 31 Jan 2018 09:00:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.55.229 with HTTP; Wed, 31 Jan 2018 09:00:50 -0800 (PST) In-Reply-To: <20180131094308.24946-2-rami.ylimaki@vincit.fi> References: <20180131094308.24946-1-rami.ylimaki@vincit.fi> <20180131094308.24946-2-rami.ylimaki@vincit.fi> From: =?UTF-8?Q?Rami_Ylim=C3=A4ki?= Date: Wed, 31 Jan 2018 19:00:50 +0200 Message-ID: Subject: Re: bug#30308: [PATCH 1/1] Support standard Terminfo direct mode terminals. To: 30308@debbugs.gnu.org Content-Type: multipart/alternative; boundary="f4f5e80976a4eb193c0564156bd9" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30308 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --f4f5e80976a4eb193c0564156bd9 Content-Type: text/plain; charset="UTF-8" I'll send a second revision of this patch, because the current revision doesn't allow one to use "RGB" and set[bf]24 at the same time. --f4f5e80976a4eb193c0564156bd9 Content-Type: text/html; charset="UTF-8"
I'll send a second revision of this patch, because the current revision doesn't allow one to use "RGB" and set[bf]24 at the same time.
--f4f5e80976a4eb193c0564156bd9-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 01 04:42:43 2018 Received: (at 30308) by debbugs.gnu.org; 1 Feb 2018 09:42:43 +0000 Received: from localhost ([127.0.0.1]:51817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ehBOD-0004mA-Sz for submit@debbugs.gnu.org; Thu, 01 Feb 2018 04:42:43 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:36380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ehBOB-0004lu-BS for 30308@debbugs.gnu.org; Thu, 01 Feb 2018 04:42:40 -0500 Received: by mail-lf0-f51.google.com with SMTP id t79so25217335lfe.3 for <30308@debbugs.gnu.org>; Thu, 01 Feb 2018 01:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vincit.fi; s=ticniv; h=from:to:subject:date:message-id; bh=oT181XrJHqQDsl89mX88prc6xUjQg7seF6m2RvEN2X8=; b=ir+MmD0OxPvZetbzTFyqEKpOF/GQLlV4Fh3P6oMv/1hG7EtnVPQSIsBsGoRgkgnml5 GCASzUFPGO0PBleLwHkTNhvnN7uaWJwD/z9kpi3IS2J8nACPgSpLuhh18fFdwP6MwNvO HXD5wPbCl+PcBHnxpW0Bl1EpahHctmo0UvFyw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=oT181XrJHqQDsl89mX88prc6xUjQg7seF6m2RvEN2X8=; b=iT0tyR8SlLdvy+K8b1o9Ue/BZhQI3toWuN2lJQZ3zYiMAMHJO+3I9MDymSPbXWv7Dz ddH1dA0ncLPXFngF6F7aZsH/P7ILsPRb8bCAi9FWCyqZcOrQYTYSizNbVsDXz5ojWsEU uhocr408+ci2Bz3GQRPw6jTLWaoSyFZs6NozwODBIA6Uluufho3rG9KiGSajfbL6JbjD TDZrSEwHtRz20VIXNDt0/mS+80GoPAIRVv+gHWC+TMKAzgP87eHFwyIaU4oMwSssxKUo hkV5+qowlIMPB8Wz2RDOGJI+Oj8so60y99N+ImVLkhlkeJqqD6TS2HksFxPT16kMP4on kHCQ== X-Gm-Message-State: AKwxytcLVxL0xTiIUA5jMgDDcWZ0SP+J4RNKzR42ShTTs5iHvjzD+34t HtlAY9QVgGgFFEAXWi3OWuOFVNvd0mQ= X-Google-Smtp-Source: AH8x226U/NMzuNBQfEmy0JorTsN+1jyRKNDVlSBF96j/nKLpg5lJ0HDHQvGuIVm0w9JOfb+2F+GfMQ== X-Received: by 10.25.217.210 with SMTP id s79mr21296564lfi.73.1517478152821; Thu, 01 Feb 2018 01:42:32 -0800 (PST) Received: from localhost.localdomain (gw.vincit.cloud. [195.60.252.249]) by smtp.gmail.com with ESMTPSA id w7sm3659426ljw.25.2018.02.01.01.42.31 for <30308@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 01:42:32 -0800 (PST) From: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= To: 30308@debbugs.gnu.org Subject: [PATCH v2] Support standard Terminfo direct mode terminals. Date: Thu, 1 Feb 2018 11:41:33 +0200 Message-Id: <20180201094133.11024-1-rami.ylimaki@vincit.fi> X-Mailer: git-send-email 2.14.1 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30308 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Latest Terminfo introduces terminal definitions that support direct color mode. The "Co"/"colors" capability is set to 0x1000000 on these terminals and Emacs is already compatible with them. However, if used Terminfo library hasn't been compiled with 32-bit value support, "Co"/"colors" is truncated to 0x7fff. In this case direct color mode support can be detected from the "RGB" capability flag. There are some minor problems if the color count isn't corrected from 0x7fff. First eight standard colors defined in xterm-standard-colors are shown correctly. However, their RGB values match the terminal settings, not the RGB values defined in xterm-standard-colors. Bright versions of these colors are shown incorrectly. They are interpreted as pixels #000008 - #000015, which are very dark shades of blue. * src/term.c (init_tty): Force terminal color count to 0x1000000 if "RGB" capability is present. * src/tparam.h: Define prototype for tigetflag. * doc/misc/efaq.texi (Colors on a TTY): Add information about direct mode terminals supported by Terminfo. --- doc/misc/efaq.texi | 45 +++++++++++++++++++++++++++------------------ src/term.c | 10 +++++++++- src/tparam.h | 3 ++- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 3e67438ab9..fef9b1051b 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -1496,32 +1496,41 @@ Colors on a TTY take one 24-bit pixel value as argument and transform the pixel to a string that can be used to send 24-bit colors to the terminal. -There aren't yet any standard terminal type definitions that would -support the capabilities, but Emacs can be invoked with a custom -definition as shown below. +Standard terminal definitions don't support these capabilities and +therefore custom definition is needed. @example -$ cat terminfo-24bit.src +$ cat terminfo-custom.src -# Use colon separators. -xterm-24bit|xterm with 24-bit direct color mode, +xterm-emacs|xterm with 24-bit direct color mode for Emacs, use=xterm-256color, - setb24=\E[48:2:%p1%@{65536@}%/%d:%p1%@{256@}%/%@{255@}%&%d:%p1%@{255@}%&%dm, - setf24=\E[38:2:%p1%@{65536@}%/%d:%p1%@{256@}%/%@{255@}%&%d:%p1%@{255@}%&%dm, -# Use semicolon separators. -xterm-24bits|xterm with 24-bit direct color mode, - use=xterm-256color, - setb24=\E[48;2;%p1%@{65536@}%/%d;%p1%@{256@}%/%@{255@}%&%d;%p1%@{255@}%&%dm, - setf24=\E[38;2;%p1%@{65536@}%/%d;%p1%@{256@}%/%@{255@}%&%d;%p1%@{255@}%&%dm, + setb24=\E[48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%dm, + setf24=\E[38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%dm, + +$ tic -x -o ~/.terminfo terminfo-custom.src + +$ TERM=xterm-emacs emacs -nw +@end example + +Emacs 27.1 and later support Terminfo capability @samp{RGB} for +detecting 24-bit direct color mode. Multiple standard terminal +definitions support this capability. + +@example +$ TERM=xterm-direct infocmp | grep seta[bf] -$ tic -x -o ~/.terminfo terminfo-24bit.src + setab=\E[%?%p1%@{8@}%<%t4%p1%d%e48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, + setaf=\E[%?%p1%@{8@}%<%t3%p1%d%e38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, -$ TERM=xterm-24bit emacs -nw +$ TERM=xterm-direct emacs -nw @end example -Currently there's no standard way to determine whether a terminal -supports direct color mode. If such standard arises later on, support -for @samp{setb24} and @samp{setf24} may be removed. +Terminals with @samp{RGB} capability treat pixels #000001 - #000007 as +indexed colors to maintain backward compatibility with applications +that are unaware of direct color mode. Therefore the seven darkest +blue shades may not be available. If this is a problem, you can +always use custom terminal definition with @samp{setb24} and +@samp{setf24}. @node Debugging a customization file @section How do I debug a @file{.emacs} file? diff --git a/src/term.c b/src/term.c index b3707da70a..64a2b7e551 100644 --- a/src/term.c +++ b/src/term.c @@ -4144,10 +4144,10 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ tty->TN_max_colors = tgetnum ("Co"); #ifdef TERMINFO - /* Non-standard support for 24-bit colors. */ { const char *fg = tigetstr ("setf24"); const char *bg = tigetstr ("setb24"); + /* Non-standard support for 24-bit colors. */ if (fg && bg && fg != (char *) (intptr_t) -1 && bg != (char *) (intptr_t) -1) @@ -4156,6 +4156,14 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ tty->TS_set_background = bg; tty->TN_max_colors = 16777216; } + /* Standard support for 24-bit colors. */ + else if (tigetflag ("RGB") > 0) + { + /* If the used Terminfo library supports only 16-bit + signed values, tgetnum("Co") and tigetnum("colors") + could return 32767. */ + tty->TN_max_colors = 16777216; + } } #endif diff --git a/src/tparam.h b/src/tparam.h index f8fb9e0869..3a3cb52c17 100644 --- a/src/tparam.h +++ b/src/tparam.h @@ -37,7 +37,8 @@ extern char *BC; extern char *UP; #ifdef TERMINFO -char *tigetstr(const char *); +int tigetflag (const char *); +char *tigetstr (const char *); #endif #endif /* EMACS_TPARAM_H */ -- 2.14.1 From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 10 06:34:08 2018 Received: (at 30308-done) by debbugs.gnu.org; 10 Feb 2018 11:34:08 +0000 Received: from localhost ([127.0.0.1]:36139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekTPz-0006Ip-OJ for submit@debbugs.gnu.org; Sat, 10 Feb 2018 06:34:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekTPx-0006IK-4F for 30308-done@debbugs.gnu.org; Sat, 10 Feb 2018 06:34:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekTPp-0000No-FP for 30308-done@debbugs.gnu.org; Sat, 10 Feb 2018 06:34:00 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekTPp-0000NZ-CN; Sat, 10 Feb 2018 06:33:57 -0500 Received: from [176.228.60.248] (port=3529 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ekTPo-0000WG-7R; Sat, 10 Feb 2018 06:33:56 -0500 Date: Sat, 10 Feb 2018 13:33:39 +0200 Message-Id: <83a7wh2i5o.fsf@gnu.org> From: Eli Zaretskii To: Rami =?iso-8859-1?Q?Ylim=E4ki?= In-reply-to: <20180201094133.11024-1-rami.ylimaki@vincit.fi> (message from Rami =?iso-8859-1?Q?Ylim=E4ki?= on Thu, 1 Feb 2018 11:41:33 +0200) Subject: Re: bug#30308: [PATCH v2] Support standard Terminfo direct mode terminals. References: <20180131094308.24946-1-rami.ylimaki@vincit.fi> <20180201094133.11024-1-rami.ylimaki@vincit.fi> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 30308-done Cc: 30308-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Rami Ylimäki > Date: Thu, 1 Feb 2018 11:41:33 +0200 > > Latest Terminfo introduces terminal definitions that support direct > color mode. The "Co"/"colors" capability is set to 0x1000000 on these > terminals and Emacs is already compatible with them. > > However, if used Terminfo library hasn't been compiled with 32-bit > value support, "Co"/"colors" is truncated to 0x7fff. In this case > direct color mode support can be detected from the "RGB" capability > flag. > > There are some minor problems if the color count isn't corrected from > 0x7fff. First eight standard colors defined in xterm-standard-colors > are shown correctly. However, their RGB values match the terminal > settings, not the RGB values defined in xterm-standard-colors. Bright > versions of these colors are shown incorrectly. They are interpreted > as pixels #000008 - #000015, which are very dark shades of blue. > > * src/term.c (init_tty): Force terminal color count to 0x1000000 if > "RGB" capability is present. > * src/tparam.h: Define prototype for tigetflag. > > * doc/misc/efaq.texi (Colors on a TTY): Add information about direct > mode terminals supported by Terminfo. Thanks, pushed to the master branch. From unknown Mon Aug 18 19:27:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 10 Mar 2018 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator