From: Sirius <sirius@trudheim.com>
To: Gedalya <gedalya@gedalya.net>
Cc: netdev@vger.kernel.org
Subject: Re: iproute2: color output should assume dark background
Date: Thu, 23 May 2024 09:57:13 +0200 [thread overview]
Message-ID: <Zk722SwDWVe35Ssu@photonic.trudheim.com> (raw)
In-Reply-To: <96b17bae-47f7-4b2d-8874-7fb89ecc052a@gedalya.net>
In days of yore (Thu, 23 May 2024), Gedalya thus quoth:
> On 5/23/24 2:39 PM, Sirius wrote:
> > what terminal background should be used,
> It's not about prescribing what should, but about guessing what is, when that is not explicitly stated. The only "right" way to guess is to always choose what is more probable (common, in this case).
Appeal to authority.
> > read what the background is of the console
> That's COLORFGBG. It is set by some terminal emulators as a way to
> advertise the colors being used.
>
> I'm no expert but AFAIK there is no uniform way to do this that is
> supported by all major terminal emulators.
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Control-Bytes_-Characters_-and-Sequences
https://stackoverflow.com/questions/2507337/how-to-determine-a-terminals-background-color
If you colour the output, then handling the prospect that the background
might not be the assumed colour kind of comes with the territory.
Or you deliberately set the background colour to something so that it is
not undefined. That is what the ANSI colour sequences can do when you use
strings like \e[32;47m where you deliberately set the background.
> > adapt the foreground colours to that. I would guess that means holding
> > two sets of the eight colours and if the background is "dark", use the
> > lighter set and if the background is "light", use the darker set.
>
> That's what iproute2 currently does.
>
> In fact this can't be adequate. You can't turn the question of best
> contrast against 16(million?) different colors into a binary. But this
> is a simple CLI command, not a full-screen productivity app.
If the background as read from terminal is > 127 it is "light", if it is <
127, it is "dark".
Xterm, the sequence \e]11;?\a will give you the background colour, zutty
does too, urxvt does not.
Maybe colouring the output by default isn't such a wise idea as utilities
reading the output now must strip control-codes before the output can be
parsed. Why not leave it as an option via the -c[olor] switch like before?
--
Kind regards,
/S
next prev parent reply other threads:[~2024-05-23 8:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 19:21 iproute2: color output should assume dark background Gedalya
2024-05-22 19:27 ` Dragan Simic
2024-05-23 6:39 ` Sirius
2024-05-23 7:08 ` Gedalya
2024-05-23 7:57 ` Sirius [this message]
2024-05-23 8:05 ` Sirius
2024-05-23 12:36 ` Dragan Simic
2024-05-23 13:02 ` Sirius
2024-05-23 13:04 ` Gedalya
2024-05-23 13:19 ` Sirius
2024-05-23 13:47 ` Dragan Simic
2024-05-28 9:07 ` David Laight
2024-05-28 9:40 ` Gedalya
2024-05-23 13:23 ` Dragan Simic
2024-05-23 13:39 ` Gedalya
2024-05-23 14:02 ` Dragan Simic
2024-05-23 14:11 ` Gedalya
2024-05-23 14:24 ` Dragan Simic
2024-05-23 14:33 ` Gedalya
2024-05-23 14:59 ` Stephen Hemminger
2024-05-23 15:17 ` Gedalya
2024-05-23 13:50 ` Gedalya
2024-05-23 14:07 ` Dragan Simic
2024-05-23 14:13 ` Gedalya
2024-05-23 14:26 ` Dragan Simic
2024-05-23 14:11 ` Sirius
2024-05-23 14:19 ` Gedalya
2024-05-23 14:28 ` Dragan Simic
2024-05-23 14:29 ` Dragan Simic
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=Zk722SwDWVe35Ssu@photonic.trudheim.com \
--to=sirius@trudheim.com \
--cc=gedalya@gedalya.net \
--cc=netdev@vger.kernel.org \
/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.
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.