Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

[PATCH 0/2] Stop downgrading styled underlines to regular underlines

12 views
Skip to first unread message

Johannes Altmanninger

unread,
May 3, 2025, 3:03:35 PMMay 3
to tmux-...@googlegroups.com
As discussed in https://github.com/orgs/tmux/discussions/4477

Also added a second experimental patch, not sure about that one.

Johannes Altmanninger

unread,
May 3, 2025, 3:03:37 PMMay 3
to tmux-...@googlegroups.com, Johannes Altmanninger
Given

for i in $(seq 5); do
printf '\e[4:${i}m%s\e[m\n' "underline style $i"
done

when terminfo doesn't advertise the Smulx capability, we fall back to emitting
regular underlines.

I use curly underlines to highlight syntax errors in my interactive shell.
I don't want the fallback because in this context, a regular underline means
something else (namely that a file path exists).

Remove the smart fallback, matching what most (non-multiplexing) terminals do.

This might annoy some users, in particular those using TUI programs that
do not allow setting their text face that results in the program sending
'\e[4m\e[4:2m' (underline followed by double underline). I guess that not
many programs enable styled underlines by default. For example, Neovim seems
to use regular underlines for errors.

Other instances of this fallback pattern are that we downgrade both reverse
and italics mode to standout mode if they are missing. Perhaps we should
try to remove those as well, for consistency (sketched in the next patch).
---
tty.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tty.c b/tty.c
index bfedb8ee..19e55757 100644
--- a/tty.c
+++ b/tty.c
@@ -2756,8 +2756,7 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
if (changed & GRID_ATTR_ITALICS)
tty_set_italics(tty);
if (changed & GRID_ATTR_ALL_UNDERSCORE) {
- if ((changed & GRID_ATTR_UNDERSCORE) ||
- !tty_term_has(tty->term, TTYC_SMULX))
+ if (changed & GRID_ATTR_UNDERSCORE)
tty_putcode(tty, TTYC_SMUL);
else if (changed & GRID_ATTR_UNDERSCORE_2)
tty_putcode_i(tty, TTYC_SMULX, 2);
--
2.49.0

Johannes Altmanninger

unread,
May 3, 2025, 3:03:37 PMMay 3
to tmux-...@googlegroups.com, Johannes Altmanninger
(this is an experimental patch, mainly for demonstration. I haven't done
much research).

https://www.gnu.org/software/termutils/manual/termcap-1.3/html_node/termcap_33.html
presents a reason for using standout mode:

> Programs that use appearance modes only to highlight some text generally
> use the standout mode so that they can work on as many terminals as possible.

This is a nice idea, though it seems a bit dated. I'm not sure how many
applications really want to use this indirection.

Most software terminals seem support both italics and reverse mode.
Most terminals interpret standout mode as reverse mode.
The exception is GNU screen where it means italics.

According to the terminfo database on my system, terminals that do not
support italics mode (sitm) include
- Putty
- linux
- Emacs ansi-term (TERM=eterm)
---
tty.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/tty.c b/tty.c
index 19e55757..680a0961 100644
--- a/tty.c
+++ b/tty.c
@@ -684,16 +684,14 @@ tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
static void
tty_set_italics(struct tty *tty)
{
- const char *s;
+ const char *s = options_get_string(global_options, "default-terminal");;

- if (tty_term_has(tty->term, TTYC_SITM)) {
- s = options_get_string(global_options, "default-terminal");
- if (strcmp(s, "screen") != 0 && strncmp(s, "screen-", 7) != 0) {
- tty_putcode(tty, TTYC_SITM);
- return;
- }
+ if (strcmp(s, "screen") == 0 && strncmp(s, "screen-", 7) == 0) {
+ tty_putcode(tty, TTYC_SMSO);
+ return;
}
- tty_putcode(tty, TTYC_SMSO);
+
+ tty_putcode(tty, TTYC_SITM);
}

void
@@ -2769,12 +2767,8 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
}
if (changed & GRID_ATTR_BLINK)
tty_putcode(tty, TTYC_BLINK);
- if (changed & GRID_ATTR_REVERSE) {
- if (tty_term_has(tty->term, TTYC_REV))
- tty_putcode(tty, TTYC_REV);
- else if (tty_term_has(tty->term, TTYC_SMSO))
- tty_putcode(tty, TTYC_SMSO);
- }
+ if (changed & GRID_ATTR_REVERSE)
+ tty_putcode(tty, TTYC_REV);
if (changed & GRID_ATTR_HIDDEN)
tty_putcode(tty, TTYC_INVIS);
if (changed & GRID_ATTR_STRIKETHROUGH)
--
2.49.0

Nicholas Marriott

unread,
May 12, 2025, 5:51:34 AMMay 12
to Johannes Altmanninger, tmux-...@googlegroups.com
I think this is OK so I've applied this now. I forgot to put your name in the commit, sorry...


--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/tmux-users/20250503190316.409246-2-aclopte%40gmail.com.

Nicholas Marriott

unread,
May 12, 2025, 5:58:33 AMMay 12
to Johannes Altmanninger, tmux-...@googlegroups.com
I don't understand what this change is meant to do. We should send SITM for italics if the terminal supports it, unless we are emulating screen in which case we send SMSO. That is what it does at the moment and it's likely that even now changing it will make a horde of people appear to complain that less is suddenly showing italics. Anyone who wants the right (non-screen-bug-compatible behaviour) should have default-terminal set to tmux or tmux-256color (which is now the default anyway).



On Sat, 3 May 2025 at 20:03, Johannes Altmanninger <acl...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages