all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Ansi-color uses the same values for fore- and background colours
@ 2023-08-09 12:10 Tony Zorman
  2023-08-09 13:28 ` Eli Zaretskii
  2023-08-09 16:51 ` Jim Porter
  0 siblings, 2 replies; 7+ messages in thread
From: Tony Zorman @ 2023-08-09 12:10 UTC (permalink / raw)
  To: emacs-devel, Protesilaos Stavrou

Hi,

by default, all of the `ansi-color-«COLOUR»' faces (defined in
`ansi-color.el') set the foreground and background colour to the exact
same value. Depending on the colour scheme, this can lead to text that's
quite hard to read. The question is whether this is intentional, because
some component or other relies on it, or it's just that no one bothered
to think of good matches here.

This was originally a bug report for the modus-themes.[1] Here is the
relevant part of the email:

---

[…] this can result in hard to read text; for example:

    https://i.imgur.com/nZsh00N.png

Notice the blue background in the bottom left corner. Here's a
reproducer:

  1. Basic environment: $ emacs -Q --eval "(load-theme 'modus-operandi)"

  2. Start `term': M-x term RET

     In a second prompt, `term' asks you to choose a shell. To make sure
     no user options are at play here, I opted for `/bin/sh' (this is
     dash for me).

  3. Do something that involves a pager: git add --help

  4. Notice that the temp file name in the bottom left has a very dark
     blue background, making the text almost—or, depending on the
     monitor, completely—illegible.

     Upon pressing any key, the title will vanish. However, one can also
     search for something, which uses the same face: / This RET

---

Note that I'm not necessarily advocating for changing the defaults,
although that would be the most desirable outcome. This is just to make
sure that the modus-themes using different fore- and background colours
doesn't violate any implicit assumptions.

  Tony

[1]: https://lists.sr.ht/~protesilaos/modus-themes/%3C87fs4wforf.fsf%40hyperspace%3E

-- 
Tony Zorman | https://tony-zorman.com/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ansi-color uses the same values for fore- and background colours
  2023-08-09 12:10 Ansi-color uses the same values for fore- and background colours Tony Zorman
@ 2023-08-09 13:28 ` Eli Zaretskii
  2023-08-09 16:18   ` Tony Zorman
  2023-08-09 16:46   ` Jim Porter
  2023-08-09 16:51 ` Jim Porter
  1 sibling, 2 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-09 13:28 UTC (permalink / raw)
  To: Tony Zorman; +Cc: emacs-devel, info

> From: Tony Zorman <tonyzorman@mailbox.org>
> Date: Wed, 09 Aug 2023 14:10:44 +0200
> 
> by default, all of the `ansi-color-«COLOUR»' faces (defined in
> `ansi-color.el') set the foreground and background colour to the exact
> same value.

I believe this is intentional: that's how ANSI SGR sequences work on
terminals, right?

The expectation is that no one in their right mind will send SGR
sequences that set both foreground and background colors to the same
color, because that would make the text illegible.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ansi-color uses the same values for fore- and background colours
  2023-08-09 13:28 ` Eli Zaretskii
@ 2023-08-09 16:18   ` Tony Zorman
  2023-08-09 16:31     ` Eli Zaretskii
  2023-08-09 16:46   ` Jim Porter
  1 sibling, 1 reply; 7+ messages in thread
From: Tony Zorman @ 2023-08-09 16:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, info

On Wed, Aug 09 2023 16:28, Eli Zaretskii wrote:
>> From: Tony Zorman <tonyzorman@mailbox.org>
>> Date: Wed, 09 Aug 2023 14:10:44 +0200
>> 
>> by default, all of the `ansi-color-«COLOUR»' faces (defined in
>> `ansi-color.el') set the foreground and background colour to the exact
>> same value.
>
> I believe this is intentional: that's how ANSI SGR sequences work on
> terminals, right?

I'm a bit rusty with my escape sequences; they don't hard-code colours,
right? I thought that e.g. `ESC[31m' just means "colour the foreground
on some kind of red", `ESC[41m' means the same for the background, and
then the terminal interprets this appropriately. Is there actually some
standard that says these two colours have to be the same, or am I
missing some other detail? I suppose terminals implementing this could
choose to use the same value for both colours, and maybe most of them
did.

Either way, I guess the modus-themes shouldn't run into any issues when
diverging from this.

Thanks!

-- 
Tony Zorman | https://tony-zorman.com/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ansi-color uses the same values for fore- and background colours
  2023-08-09 16:18   ` Tony Zorman
@ 2023-08-09 16:31     ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-09 16:31 UTC (permalink / raw)
  To: Tony Zorman; +Cc: emacs-devel, info

> From: Tony Zorman <tonyzorman@mailbox.org>
> Cc: emacs-devel@gnu.org, info@protesilaos.com
> Date: Wed, 09 Aug 2023 18:18:19 +0200
> 
> On Wed, Aug 09 2023 16:28, Eli Zaretskii wrote:
> >> From: Tony Zorman <tonyzorman@mailbox.org>
> >> Date: Wed, 09 Aug 2023 14:10:44 +0200
> >> 
> >> by default, all of the `ansi-color-«COLOUR»' faces (defined in
> >> `ansi-color.el') set the foreground and background colour to the exact
> >> same value.
> >
> > I believe this is intentional: that's how ANSI SGR sequences work on
> > terminals, right?
> 
> I'm a bit rusty with my escape sequences; they don't hard-code colours,
> right? I thought that e.g. `ESC[31m' just means "colour the foreground
> on some kind of red", `ESC[41m' means the same for the background, and
> then the terminal interprets this appropriately. Is there actually some
> standard that says these two colours have to be the same

Well, they are both "red", so they are the same color.  Anything else
will be very confusing, I think.  Just think about it: you ask for
"red", but get something else, even if red-dish.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ansi-color uses the same values for fore- and background colours
  2023-08-09 13:28 ` Eli Zaretskii
  2023-08-09 16:18   ` Tony Zorman
@ 2023-08-09 16:46   ` Jim Porter
  1 sibling, 0 replies; 7+ messages in thread
From: Jim Porter @ 2023-08-09 16:46 UTC (permalink / raw)
  To: Eli Zaretskii, Tony Zorman; +Cc: emacs-devel, info

On 8/9/2023 6:28 AM, Eli Zaretskii wrote:
>> From: Tony Zorman <tonyzorman@mailbox.org>
>> Date: Wed, 09 Aug 2023 14:10:44 +0200
>>
>> by default, all of the `ansi-color-«COLOUR»' faces (defined in
>> `ansi-color.el') set the foreground and background colour to the exact
>> same value.
> 
> I believe this is intentional: that's how ANSI SGR sequences work on
> terminals, right?

Yes. Emacs *could* color the foreground and background differently, but 
I don't believe it should (users are free to customize things however 
they like, of course). Every terminal emulator I'm aware of uses the 
same palette for foreground and background colors, so I think we should 
follow suit.

Instead, the goal should be to ensure a reasonable level of contrast 
between commonly-used color pairs of different foregrounds/backgrounds. 
At minimum, SGR white or black on any of the other basic colors should 
be readable.

I don't think there's a bug here.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ansi-color uses the same values for fore- and background colours
  2023-08-09 12:10 Ansi-color uses the same values for fore- and background colours Tony Zorman
  2023-08-09 13:28 ` Eli Zaretskii
@ 2023-08-09 16:51 ` Jim Porter
  2023-08-10  3:59   ` Tony Zorman
  1 sibling, 1 reply; 7+ messages in thread
From: Jim Porter @ 2023-08-09 16:51 UTC (permalink / raw)
  To: Tony Zorman, emacs-devel, Protesilaos Stavrou

On 8/9/2023 5:10 AM, Tony Zorman wrote:
> by default, all of the `ansi-color-«COLOUR»' faces (defined in
> `ansi-color.el') set the foreground and background colour to the exact
> same value.
[snip]
> 
> ---
> 
> […] this can result in hard to read text; for example:
> 
>      https://i.imgur.com/nZsh00N.png
> 
> Notice the blue background in the bottom left corner.

Have you customized your settings for "man" somehow (or maybe changed 
your pager)? I don't see colors that look like that at all. In fact, I 
only see black and white text (or vice versa), as I'd normally expect 
when looking at "man" output. It's all perfectly easy to read on my end.

If you *have* customized some of your settings, maybe you just need to 
tweak them so that they don't produce unreadable output.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ansi-color uses the same values for fore- and background colours
  2023-08-09 16:51 ` Jim Porter
@ 2023-08-10  3:59   ` Tony Zorman
  0 siblings, 0 replies; 7+ messages in thread
From: Tony Zorman @ 2023-08-10  3:59 UTC (permalink / raw)
  To: Jim Porter, emacs-devel, Protesilaos Stavrou

On Wed, Aug 09 2023 09:51, Jim Porter wrote:
> Have you customized your settings for "man" somehow (or maybe changed 
> your pager)?

I was going to say "no", but in the deepest recesses of my ~/.profile I
did find some stuff that direction! The "offending" line was something
like

    export LESS_TERMCAP_so="$(printf '%b' 'ESC[01;44;33m')"; a="${a%_}"

However…

> If you *have* customized some of your settings, maybe you just need to 
> tweak them so that they don't produce unreadable output.

…I don't think this invalidates the question. This was just the easiest
reproducer for me, but something akin to this could certainly happen "in
the wild". There can be, visually, quite a big difference between fore-
and background colours. Especially for high-contrast themes, I wouldn't
expect foreground colours—sometimes very saturated/dark—to be
particularly good when used as a background.

-- 
Tony Zorman | https://tony-zorman.com/



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-10  3:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 12:10 Ansi-color uses the same values for fore- and background colours Tony Zorman
2023-08-09 13:28 ` Eli Zaretskii
2023-08-09 16:18   ` Tony Zorman
2023-08-09 16:31     ` Eli Zaretskii
2023-08-09 16:46   ` Jim Porter
2023-08-09 16:51 ` Jim Porter
2023-08-10  3:59   ` Tony Zorman

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.