From: Eli Zaretskii <eliz@gnu.org>
To: mohkale@kisara.moe
Cc: 62994@debbugs.gnu.org
Subject: bug#62994: [PATCH v5] Add support for colored and styled underlines on tty frames
Date: Mon, 12 Feb 2024 14:48:49 +0200 [thread overview]
Message-ID: <86a5o5sv9q.fsf@gnu.org> (raw)
In-Reply-To: <20240211180501.695192-1-mohkale@kisara.moe>
> From: mohkale@kisara.moe
> Cc: Mohsin Kaleem <mohkale@kisara.moe>
> Date: Sun, 11 Feb 2024 18:05:01 +0000
>
> From: Mohsin Kaleem <mohkale@kisara.moe>
>
> * src/dispextern.h (face, face_underline_type, syms_of_xfacse,
> internal-set-lisp-face-attribute, gui_supports_face_attributes_p):
> Add definitions for new underline styles of Double, Dotted and Dashed.
> Delete tty_underline_p from the face struct and use just underline going
> forward. Add a flag to check whether styled underlines are available.
> * lisp/cus-face.el (custom-face-attributes): Add entries for Double,
> Dotted and Dashed so they can be set through `customize'.
> * src/termchar.c (tty_display_info): Add an entry for the escape
> sequence to set the underline style and color on terminal frames.
> * src/term.c (init_tty, tty_capable_p, turn_on_face): Read and save the
> underline style escape sequence from the Smulx termcap (alternatively if
> the Su flag is set use a default sequence). Allow checking for support
> of styled underlines in the current terminal frame. Output the necessary
> escape sequences to activate a styled underline on turn_on_face; this is
> currently only used for the new special underline styles, a default
> straight underline will still use the "us" termcap. Output escape
> sequence to set underline color when set in the face and supported by
> the tty. Save a default value for this sequence on init_tty when styled
> underlines are supported.
> * src/xfaces.c (tty_supports_face_attributes_p, realize_tty_face,
> map_tty_color, map_tty_color2): Assert whether styled underlines are
> supported by the current terminal on
> display-supports-face-attributes-p checks. Populate the correct
> underline style and color in the face spec when realizing a face.
> Allow map_tty_color to map underline colors alongside foreground and
> background. The interface of map_tty_color was amended to allow
> the caller to supply the underline color instead of accessing it
> through the face attributes. A new variant map_tty_color2 was added
> for contexts where caller doesn't care about foreground/background
> face defaulting.
> ---
> etc/NEWS | 15 +++++
> lisp/cus-face.el | 5 +-
> src/dispextern.h | 10 ++-
> src/term.c | 54 +++++++++++++--
> src/termchar.h | 7 ++
> src/xfaces.c | 171 +++++++++++++++++++++++++++++++++++++++--------
> 6 files changed, 227 insertions(+), 35 deletions(-)
Thanks. I think in addition to NEWS, we'd need to update the ELisp
Reference manual, because the new underline styles are not currently
mentioned there.
> --- a/src/term.c
> +++ b/src/term.c
> @@ -2014,8 +2014,19 @@ 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->underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
> + {
> + if (face->underline == FACE_UNDER_LINE
> + || !tty->TF_set_underline_style)
> + OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
> + else if (tty->TF_set_underline_style)
> + {
> + char *p;
Here and elsewhere in the patch, you use indentation style slightly
different from ours, so please reindent to follow our style (which
uses TABs and SPACEs, not just TABs).
> + p = tparam(tty->TF_set_underline_style, NULL, 0, face->underline, 0, 0, 0);
^^
Our style is to leave a single SPACE between the name of a function
and the opening parenthesis. Several places in the patch don't leave
that SPACE.
> + /* Styled underlines. Support for this is provided either by the
^^^^^^^
Please don't use TABs inside comments, except as indentation.
> + if (!tty->TF_set_underline_style && tgetflag("Su"))
> + /* Default to the kitty escape sequence. See
> + https://sw.kovidgoyal.net/kitty/underlines/ */
^^
This should be a period. Also, our style is to leave two SPACEs after
the final sentence of a comment, before the "*/" comment delimiter.
> + return false; /* Unsupported underline style */
^
Period and one more SPACE are missing there.
> + 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)))
> + {
> + return false; /* Face uses an unsupported underline style. */
> + }
Our style is not to use braces for single-statement blocks.
> +/* Map the specified color COLOR of face FACE on frame F to a tty
> + color index. IDX is one of LFACE_FOREGROUND_INDEX,
> + LFACE_BACKGROUND_INDEX or LFACE_UNDERLINE_INDEX, and specifies
> + which color to map. Set *DEFAULTED to true if mapping to the
> + default foreground/background colors. */
^^
One more SPACE there.
> - if (foreground_p)
> - face->foreground = pixel;
> - else
> - face->background = pixel;
> + switch (idx)
> + {
> + case LFACE_FOREGROUND_INDEX:
> + face->foreground = pixel;
> + break;
> + case LFACE_BACKGROUND_INDEX:
> + face->background = pixel;
> + break;
> + case LFACE_UNDERLINE_INDEX:
> + face->underline_color = pixel;
> + break;
> + default:
> + emacs_abort ();
The original code didn't call emacs_abort, but instead simply used
PIXEL as the background color. Why would we do something different
now?
> +static void
> +map_tty_color2 (struct frame *f, struct face *face, Lisp_Object color,
> + enum lface_attribute_index idx)
> +{
> + bool face_colors_defaulted = false;
> + map_tty_color (f, face, color, idx, &face_colors_defaulted);
> }
Is this function really justified? why not call map_tty_color?
next prev parent reply other threads:[~2024-02-12 12:48 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 14:29 bug#62994: Support styled underlines on TTY frames Mohsin Kaleem
[not found] ` <handler.62994.B.168208734930664.ack@debbugs.gnu.org>
2023-04-21 14:34 ` bug#62994: [PATCH 0/3] Support styled underlines on tty Emacs frames mohkale
2023-04-21 14:34 ` bug#62994: [PATCH 1/3] Add face definitions for more underline styles mohkale
2023-04-21 15:58 ` Eli Zaretskii
2023-04-21 16:08 ` Mohsin Kaleem
2023-04-21 14:34 ` bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames mohkale
2023-04-21 16:07 ` Eli Zaretskii
[not found] ` <878rel5fqr.fsf@kisara.moe>
2023-04-21 17:49 ` Eli Zaretskii
2023-04-21 18:04 ` Mohsin Kaleem
2023-04-21 18:43 ` Mohsin Kaleem
2023-04-22 7:00 ` Eli Zaretskii
2023-04-22 9:32 ` Mohsin Kaleem
2023-04-22 6:47 ` Eli Zaretskii
2023-04-22 9:57 ` Mohsin Kaleem
2023-04-21 14:34 ` bug#62994: [PATCH 3/3] Add support for colored " mohkale
2023-04-21 16:12 ` Eli Zaretskii
[not found] ` <875y9p5fg0.fsf@kisara.moe>
2023-04-21 17:56 ` Eli Zaretskii
2023-04-21 15:52 ` bug#62994: [PATCH 0/3] Support styled underlines on tty Emacs frames Eli Zaretskii
2023-04-21 16:10 ` Mohsin Kaleem
2023-04-21 19:24 ` bug#62994: [PATCH v2 0/1] " mohkale
2023-04-21 19:24 ` bug#62994: [PATCH v2 1/1] Add support for colored and styled underlines on tty frames mohkale
2023-04-24 9:21 ` Robert Pluim
2023-04-22 10:21 ` bug#62994: [PATCH v3 0/1] Support styled underlines on tty Emacs frames mohkale
2023-04-22 10:21 ` bug#62994: [PATCH v3 1/1] Add support for colored and styled underlines on tty frames mohkale
2024-02-12 1:28 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-28 11:30 ` bug#62994: [PATCH v3 0/1] Support styled underlines on tty Emacs frames Mohsin Kaleem
2024-01-28 12:05 ` Eli Zaretskii
[not found] ` <86fryg62kh.fsf@kisara.moe>
2024-01-29 12:37 ` Eli Zaretskii
2024-02-11 17:40 ` bug#62994: [PATCH v4] Add support for colored and styled underlines on tty frames mohkale
2024-02-11 18:05 ` bug#62994: [PATCH v5] " mohkale
2024-02-11 18:07 ` Mohsin Kaleem
2024-02-12 1:43 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-12 13:50 ` Eli Zaretskii
2024-02-12 14:49 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-10 17:20 ` Mohsin Kaleem
2024-03-10 17:15 ` Mohsin Kaleem
2024-03-10 17:45 ` Eli Zaretskii
2024-03-10 18:22 ` Mohsin Kaleem
2024-03-10 18:51 ` Jim Porter
2024-03-10 19:28 ` Eli Zaretskii
2024-03-10 19:47 ` Jim Porter
2024-03-11 2:07 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-10 19:27 ` Eli Zaretskii
2024-02-12 12:48 ` Eli Zaretskii [this message]
2024-03-10 18:08 ` Mohsin Kaleem
2024-03-14 10:20 ` Eli Zaretskii
2024-02-14 19:40 ` Jim Porter
2024-03-10 18:10 ` Mohsin Kaleem
2024-04-14 13:56 ` bug#62994: [PATCH v6] " mohkale
2024-04-14 14:13 ` Mohsin Kaleem
2024-04-20 8:16 ` Eli Zaretskii
2024-04-21 14:51 ` Mohsin Kaleem
2024-04-21 15:57 ` Eli Zaretskii
2024-04-21 16:09 ` Mohsin Kaleem
2024-04-21 16:11 ` bug#62994: [PATCH v7] " Mohsin Kaleem
2024-04-22 0:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 6:01 ` Eli Zaretskii
2024-04-22 17:35 ` Jim Porter
2024-04-23 0:53 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-23 6:02 ` Eli Zaretskii
2024-04-23 7:32 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22 17:52 ` Mohsin Kaleem
2024-04-22 17:53 ` bug#62994: [PATCH v8] " Mohsin Kaleem
2024-04-27 9:11 ` Eli Zaretskii
2024-04-29 1:04 ` Jim Porter
2024-04-29 4:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 7:25 ` Eli Zaretskii
2024-04-29 11:36 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 7:10 ` Eli Zaretskii
2024-04-30 17:53 ` Mohsin Kaleem
2024-04-30 18:20 ` Eli Zaretskii
2024-02-11 17:15 ` bug#62994: [PATCH v4 0/3] Support styled underlines on tty Emacs frames mohkale
2024-02-11 17:15 ` bug#62994: [PATCH v4 1/3] Add face definitions for more underline styles mohkale
2024-02-11 17:15 ` bug#62994: [PATCH v4 2/3] Add support for styled underlines on tty frames mohkale
2024-02-11 17:15 ` bug#62994: [PATCH v4 3/3] Add support for colored " mohkale
2024-02-11 17:23 ` bug#62994: [PATCH v4 0/3] Support styled underlines on tty Emacs frames Mohsin Kaleem
2024-02-11 17:46 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86a5o5sv9q.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=62994@debbugs.gnu.org \
--cc=mohkale@kisara.moe \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.