From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mike Hamrick Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] TTY Support for ECMA-48 strike-through graphic rendition Date: Mon, 14 Sep 2020 15:25:24 -0700 Message-ID: References: <837dvurtnn.fsf@gnu.org> <83v9hpngaz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13398"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.0; emacs 25.3.1 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 15 00:26:24 2020 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 1kHwvX-0003NN-Si for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Sep 2020 00:26:23 +0200 Original-Received: from localhost ([::1]:53134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHwvW-0002A9-V9 for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Sep 2020 18:26:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHwuf-0001gr-T1 for emacs-devel@gnu.org; Mon, 14 Sep 2020 18:25:29 -0400 Original-Received: from eidolon.muppetlabs.com ([207.66.255.52]:50568) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1kHwud-0002UT-0f; Mon, 14 Sep 2020 18:25:29 -0400 Original-Received: from mikeh by eidolon.muppetlabs.com with local (Exim 4.82) (envelope-from ) id 1kHwua-00020I-2R; Mon, 14 Sep 2020 15:25:24 -0700 In-reply-to: <83v9hpngaz.fsf@gnu.org> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: mikeh@muppetlabs.com X-SA-Exim-Scanned: No (on eidolon.muppetlabs.com); SAEximRunCond expanded to false Received-SPF: pass client-ip=207.66.255.52; envelope-from=mikeh@muppetlabs.com; helo=eidolon.muppetlabs.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/14 18:25:24 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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.23 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" Xref: news.gmane.io gmane.emacs.devel:255693 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Mike Hamrick >> Cc: emacs-devel@gnu.org >> Date: Fri, 26 Jun 2020 12:23:48 -0700 >> >> I've updated my patch to include a NEWS item. I grepped through the >> manual looking for areas that might need updating, and did not find >> any. > > Thanks, a couple of really minor nits below: > >> @@ -1971,7 +1974,8 @@ turn_off_face (struct frame *f, int face_id) >> if (face->tty_bold_p >> || face->tty_italic_p >> || face->tty_reverse_p >> - || face->tty_underline_p) >> + || face->tty_underline_p >> + || face->tty_strike_through_p) > > Please use our style of indentation in C source files (basically, make > sure indent-tabs-mode is non-nil). > > Also, please make sure the patch still applies to the current master, > and if not, please update it. It occurs to me that last time I responded to this, I didn't attach the patch to this email, but instead tacked it on to the end of my message. Sending the patch as an attachment this time. Mike --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-TTY-Support-for-ECMA-48-strike-through-graphic-rendi.patch >From 26d60beb11286a2f6496cb2df11c88c1646788a5 Mon Sep 17 00:00:00 2001 From: Mike Hamrick Date: Sun, 13 Sep 2020 15:52:24 -0700 Subject: [PATCH] TTY Support for ECMA-48 strike-through graphic rendition * term.c: Support strike-through in capable terminals. (no_color_bit): Replace unused NC_INVIS with NC_STRIKE_THROUGH. (turn_on_face): Output via TS_enter_strike_through_mode if available. (turn_off_face): Handle strike-through case. (tty_capable_p, init_tty): Support strike-through. * termchar.h (struct tty_display_info): Add field for strike-through. * xfaces.c (tty_supports_face_attributes_p, realize_tty_face): Handle strike-through case. * dispextern.h: Add TTY_CAP_STRIKE_THROUGH definition. (struct face): Add field tty_strike_through_p. --- etc/NEWS | 7 +++++++ src/dispextern.h | 2 ++ src/term.c | 34 ++++++++++++++++++++-------------- src/termchar.h | 1 + src/xfaces.c | 12 +++++++++++- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 52092f2ef7..757b4c74ae 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -85,6 +85,13 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 +--- +** Support for the 'strike-through' face attribute on TTY frames. +If your terminal's termcap or terminfo database entry has the 'smxx' +capability defined, Emacs will now emit the prescribed escape +sequences necessary to render faces with the 'strike-through' +attribute on TTY frames. + +++ *** Emacs now defaults to UTF-8 instead of ISO-8859-1. This is only for the default, where the user has set no LANG (or diff --git a/src/dispextern.h b/src/dispextern.h index 956ca96eb6..e20f7bb7b6 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1744,6 +1744,7 @@ #define FONT_TOO_HIGH(ft) \ bool_bf tty_italic_p : 1; bool_bf tty_underline_p : 1; bool_bf tty_reverse_p : 1; + bool_bf tty_strike_through_p : 1; /* True means that colors of this face may not be freed because they have been copied bitwise from a base face (see @@ -3290,6 +3291,7 @@ #define TTY_CAP_UNDERLINE 0x02 #define TTY_CAP_BOLD 0x04 #define TTY_CAP_DIM 0x08 #define TTY_CAP_ITALIC 0x10 +#define TTY_CAP_STRIKE_THROUGH 0x20 /*********************************************************************** diff --git a/src/term.c b/src/term.c index 5cbb092ad1..22035f4fe3 100644 --- a/src/term.c +++ b/src/term.c @@ -105,14 +105,14 @@ #define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } whil enum no_color_bit { - NC_STANDOUT = 1 << 0, - NC_UNDERLINE = 1 << 1, - NC_REVERSE = 1 << 2, - NC_ITALIC = 1 << 3, - NC_DIM = 1 << 4, - NC_BOLD = 1 << 5, - NC_INVIS = 1 << 6, - NC_PROTECT = 1 << 7 + NC_STANDOUT = 1 << 0, + NC_UNDERLINE = 1 << 1, + NC_REVERSE = 1 << 2, + NC_ITALIC = 1 << 3, + NC_DIM = 1 << 4, + NC_BOLD = 1 << 5, + NC_STRIKE_THROUGH = 1 << 6, + NC_PROTECT = 1 << 7 }; /* internal state */ @@ -1931,6 +1931,9 @@ turn_on_face (struct frame *f, int face_id) if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) OUTPUT1_IF (tty, tty->TS_enter_underline_mode); + if (face->tty_strike_through_p && MAY_USE_WITH_COLORS_P (tty, NC_STRIKE_THROUGH)) + OUTPUT1_IF (tty, tty->TS_enter_strike_through_mode); + if (tty->TN_max_colors > 0) { const char *ts; @@ -1971,7 +1974,8 @@ turn_off_face (struct frame *f, int face_id) if (face->tty_bold_p || face->tty_italic_p || face->tty_reverse_p - || face->tty_underline_p) + || face->tty_underline_p + || face->tty_strike_through_p) { OUTPUT1_IF (tty, tty->TS_exit_attribute_mode); if (strcmp (tty->TS_exit_attribute_mode, tty->TS_end_standout_mode) == 0) @@ -2006,11 +2010,12 @@ #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \ if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit))) \ return 0; - TTY_CAPABLE_P_TRY (tty, TTY_CAP_INVERSE, tty->TS_standout_mode, NC_REVERSE); - TTY_CAPABLE_P_TRY (tty, TTY_CAP_UNDERLINE, tty->TS_enter_underline_mode, NC_UNDERLINE); - TTY_CAPABLE_P_TRY (tty, TTY_CAP_BOLD, tty->TS_enter_bold_mode, NC_BOLD); - TTY_CAPABLE_P_TRY (tty, TTY_CAP_DIM, tty->TS_enter_dim_mode, NC_DIM); - TTY_CAPABLE_P_TRY (tty, TTY_CAP_ITALIC, tty->TS_enter_italic_mode, NC_ITALIC); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_INVERSE, tty->TS_standout_mode, NC_REVERSE); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_UNDERLINE, tty->TS_enter_underline_mode, NC_UNDERLINE); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_BOLD, tty->TS_enter_bold_mode, NC_BOLD); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_DIM, tty->TS_enter_dim_mode, NC_DIM); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_ITALIC, tty->TS_enter_italic_mode, NC_ITALIC); + TTY_CAPABLE_P_TRY (tty, TTY_CAP_STRIKE_THROUGH, tty->TS_enter_strike_through_mode, NC_STRIKE_THROUGH); /* We can do it! */ return 1; @@ -4124,6 +4129,7 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed) tty->TS_enter_alt_charset_mode = tgetstr ("as", address); tty->TS_exit_alt_charset_mode = tgetstr ("ae", address); tty->TS_exit_attribute_mode = tgetstr ("me", address); + tty->TS_enter_strike_through_mode = tgetstr ("smxx", address); MultiUp (tty) = tgetstr ("UP", address); MultiDown (tty) = tgetstr ("DO", address); diff --git a/src/termchar.h b/src/termchar.h index c96b81913b..a8b3051767 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -136,6 +136,7 @@ #define EMACS_TERMCHAR_H const char *TS_enter_reverse_mode; /* "mr" -- enter reverse video mode. */ const char *TS_exit_underline_mode; /* "us" -- start underlining. */ const char *TS_enter_underline_mode; /* "ue" -- end underlining. */ + const char *TS_enter_strike_through_mode; /* "smxx" -- turn on strike-through mode. */ /* "as"/"ae" -- start/end alternate character set. Not really supported, yet. */ diff --git a/src/xfaces.c b/src/xfaces.c index 06d2f994de..73a536b19c 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -5217,7 +5217,6 @@ tty_supports_face_attributes_p (struct frame *f, || !UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX]) || !UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX]) || !UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX]) - || !UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX]) || !UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])) return false; @@ -5282,6 +5281,15 @@ tty_supports_face_attributes_p (struct frame *f, test_caps |= TTY_CAP_INVERSE; } + /* strike through */ + val = attrs[LFACE_STRIKE_THROUGH_INDEX]; + if (!UNSPECIFIEDP (val)) + { + if (face_attr_equal_p (val, def_attrs[LFACE_STRIKE_THROUGH_INDEX])) + return false; /* same as default */ + else + test_caps |= TTY_CAP_STRIKE_THROUGH; + } /* Color testing. */ @@ -6244,6 +6252,8 @@ realize_tty_face (struct face_cache *cache, face->tty_underline_p = true; if (!NILP (attrs[LFACE_INVERSE_INDEX])) face->tty_reverse_p = true; + if (!NILP (attrs[LFACE_STRIKE_THROUGH_INDEX])) + face->tty_strike_through_p = true; /* Map color names to color indices. */ map_tty_color (f, face, LFACE_FOREGROUND_INDEX, &face_colors_defaulted); -- 2.24.0 --=-=-=--