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.bugs Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames Date: Fri, 21 Apr 2023 19:07:33 +0300 Message-ID: <83y1ml2p8a.fsf@gnu.org> References: <20230421143448.339022-1-mohkale@kisara.moe> <20230421143448.339022-3-mohkale@kisara.moe> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29643"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62994@debbugs.gnu.org To: mohkale@kisara.moe Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 21 18:08:17 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pptJ2-0007UH-Ve for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Apr 2023 18:08:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pptIq-0002nL-RH; Fri, 21 Apr 2023 12:08:04 -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 1pptIp-0002mY-1f for bug-gnu-emacs@gnu.org; Fri, 21 Apr 2023 12:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pptIo-0005sr-Lf for bug-gnu-emacs@gnu.org; Fri, 21 Apr 2023 12:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pptIo-0004ze-H2 for bug-gnu-emacs@gnu.org; Fri, 21 Apr 2023 12:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Apr 2023 16:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62994 X-GNU-PR-Package: emacs Original-Received: via spool by 62994-submit@debbugs.gnu.org id=B62994.168209324819151 (code B ref 62994); Fri, 21 Apr 2023 16:08:02 +0000 Original-Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 16:07:28 +0000 Original-Received: from localhost ([127.0.0.1]:41015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pptIG-0004yp-Ar for submit@debbugs.gnu.org; Fri, 21 Apr 2023 12:07:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pptID-0004yZ-7U for 62994@debbugs.gnu.org; Fri, 21 Apr 2023 12:07:26 -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 1pptI7-0005fs-Om; Fri, 21 Apr 2023 12:07:19 -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=YX0DS3Fwyreo6viyPSgN7izv0GTHI9UOQIfUrh6TR5c=; b=a6x9Pg1kBEOg 2tFDdYqe2Qzr1Q+h9+MFzSrM3VYjvP3L/0E6u/oyD64lkT9L2pP72Cxjbx3KAljBESr/vM8G/l4wB qDf3/XkEzXJ8KClw0sOrGBfR7EMMEvfMturuU1dzP3Tfv582J10paOj0PFooGrbK7Zak0kBFsqhYB jok5cDHq5wJIJmkSQH0OuJ8rvrWUFnvhKwjVvxLil2heB2OWMvbFJG9v8+8ubD1zZHLBJRQAPajfP joflUdOdUXouh0cnJIqE1mLwjFUT3eUAE+sV3vw2XO0B47MPU5FGFlB3g0CrEMXkuc98ouoUawIy/ zRp2dS3/5PKuyYF3rQN7iA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pptI7-0002HG-96; Fri, 21 Apr 2023 12:07:19 -0400 In-Reply-To: <20230421143448.339022-3-mohkale@kisara.moe> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:260400 Archived-At: > Cc: Mohsin Kaleem > From: mohkale@kisara.moe > Date: Fri, 21 Apr 2023 15:34:47 +0100 > > diff --git a/etc/NEWS b/etc/NEWS > index 62d2fdcd3a4..9f34927dfad 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1916,6 +1916,22 @@ This command switches to the "*scratch*" buffer. If "*scratch*" doesn't > exist, the command creates it first. You can use this command if you > inadvertently delete the "*scratch*" buffer. > > +--- > +** Support for 'styled-underline' face attributes on TTY frames > +If your terminals termcap or terminfo database entry has the 'Su' or > +'Smulx' capability defined, Emacs will now emit the prescribed escape > +sequence necessary to render faces with styled underlines on TTY > +frames. > + > +Styled underlines are any underlines containing a non-default > +underline style. The available underline styles for TTY frames are > +'double', 'wave', 'dotted', and 'dashed'. > + > +The 'Smulx' capability should define the actual sequence needed to > +render styled underlines. If ommitted, but the 'Su' flag is defined, > +then a default sequence will be used. It's recommended to use 'Smulx' > +instead of 'Su', with priority being given to 'Smulx'. I think the last paragraph is unnecessary in NEWS, since there's nothing users can do about the capabilities exposed by their terminfo database. In any case, please observe our convention of leaving two spaces between sentences, not one. > --- a/src/dispextern.h > +++ b/src/dispextern.h > @@ -1773,7 +1773,7 @@ #define FONT_TOO_HIGH(ft) \ > string meaning the default color of the TTY. */ > bool_bf tty_bold_p : 1; > bool_bf tty_italic_p : 1; > - bool_bf tty_underline_p : 1; > + ENUM_BF (face_underline_type) tty_underline : 3; > bool_bf tty_reverse_p : 1; > bool_bf tty_strike_through_p : 1; Is there any reason for separate tty_* face attribute bits? why cannot we use the same bits on both TTY and GUI frames? > --- a/src/term.c > +++ b/src/term.c > @@ -1948,8 +1948,17 @@ turn_on_face (struct frame *f, int face_id) > OUTPUT1 (tty, tty->TS_enter_dim_mode); > } > > - if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) > - OUTPUT1_IF (tty, tty->TS_enter_underline_mode); > + if (face->tty_underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) { > + if (face->tty_underline == FACE_UNDER_LINE || > + !tty->TF_set_underline_style) { > + OUTPUT1_IF (tty, tty->TS_enter_underline_mode); > + } else if (tty->TF_set_underline_style) { Please use our style of braces and placing of operators in continued lines. The brace should be on their own lines, alone. > + // Styled underlines. > + // > + // Support for this is provided either by the escape sequence in > + // Smulx or the Su flag. The latter results in a common default > + // escape sequence and is not recommended. Comment style again: please use the C style. > +#ifdef TERMINFO > + tty->TF_set_underline_style = tigetstr("Smulx"); > + if (tty->TF_set_underline_style == (char *) (intptr_t) -1) > + tty->TF_set_underline_style = NULL; > +#else > + tty->TF_set_underline_style = tgetstr("Smulx", address); > +#endif > + if (!tty->TF_set_underline_style && tgetflag("Su")) > + tty->TF_set_underline_style = "\x1b[4:%p1%dm"; Any pointers to where this standard escape sequence is defined? I'd like to have that in a comment to this line. > + else if (EQ (CAR_SAFE (val), QCstyle)) > + { > + if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline) || > + EQ (CAR_SAFE (CDR_SAFE (val)), Qdouble) || > + EQ (CAR_SAFE (CDR_SAFE (val)), Qwave) || > + EQ (CAR_SAFE (CDR_SAFE (val)), Qdotted) || > + EQ (CAR_SAFE (CDR_SAFE (val)), Qdashed))) { Continuation line style again. > + return false; /* Unsupported underline style */ Comments should be complete sentences, and should end in a period and 2 spaces. > + /* Text underline. */ > + underline = attrs[LFACE_UNDERLINE_INDEX]; > + if (NILP (underline)) { > + face->tty_underline = FACE_NO_UNDERLINE; > + } else if (EQ (underline, Qt)) { > + face->tty_underline = FACE_UNDER_LINE; > + } else if (STRINGP (underline)) { > + face->tty_underline = FACE_UNDER_LINE; > + } else if (CONSP (underline)) { Style of braces again. > + while (CONSP (underline)) { > + Lisp_Object keyword, value; And here. > + if (EQ (keyword, QCstyle)) { And here.