C++ Logo


Advanced search

Re: Color Text Output

From: Antoine Viallon <antoine_at_[hidden]>
Date: Sat, 26 Jun 2021 11:54:44 +0200
I would probably use it in my professional programs, as it is very useful for quickly distinguishing important things in the logging output.

Just my 2 cents,
Antoine Viallon

-------- Courriel d’origine --------
De : Ed B via Std-Proposals <std-proposals_at_[hidden]>
Envoyé : 26 juin 2021 09:17:36 GMT+02:00
À : David Braun via Std-Proposals <std-proposals_at_[hidden]>
Cc : Ed B <hyper-nova_at_[hidden]>
Objet : Re: [std-proposals] Color Text Output

C++ is supposed to be a professional language for development of applications across a wide range of industries. Had you considered how many of those industries would want something like colored text output?

I would guess probably less than 5 % would have any interest in such a thing.

This is not really something which is suitable for inclusion into the core of the language.

There are a lot more things which are higher priority than this, and even if there were not, C++ is already a monolith which arguably could benefit from being split up or overhauled in some way, so adding yet more features to it which very few people are likely to use really isn't a good idea.

We only just got proper cross platform filesystem support in C++17 and this was something that existed in boost for decades prior.
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of David Braun via Std-Proposals <std-proposals_at_[hidden]>
Sent: Saturday, June 26, 2021 02:10
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: David Braun <da.braun1_at_[hidden]>
Subject: Re: [std-proposals] Color Text Output

Wow, yours is way more advanced and fleshed out than my suggestion. You obviously know a lot more about advanced terminal output than me.

Have you considered writing a proposal to include it in the standard?

I think if we do get Colored Text Output in the console in standard C++ we need to do it right the first time (we don’t want a situation like std::regex) so I think you should try getting your library into the standard.

You would probably have to add some things to it get it to work in native (non-emulated terminals).

I would also suggest that you put your list of colors in an enum class and/or change them from std::string to const char so that they’d be stack allocated instead of heap allocated, although it might not matter in the context of IO.

Also maybe look at which if any modern C++ features you can take advantage of because this is pretty C-Like (the committee doesn’t really like that as far as I know.)

Very impressive. You really should write a proposal.

David Aaron Braun




From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Bill Kerney via Std-Proposals
Sent: Friday, June 25, 2021 6:32 PM
To: C++ STD Proposals (std-proposals_at_[hidden]) <std-proposals_at_[hidden]>
Cc: Bill Kerney <bkerney_at_[hidden]>
Subject: Re: [std-proposals] Color Text Output

I have a color library that does enum-based colors, as well as 24-bit color. I used it to make a text-based image renderer that works inside of PuTTY or other terminals that support 24-bit color. I couldn't use NCURSES since, well, you can read what Dickey wrote about it here: https://invisible-island.net/ncurses/ncurses.faq.html#xterm_16MegaColors

Here's my git repo for it: https://github.com/ShakaUVM/colors

It also enables non-blocking I/O from the keyboard (which is something that honestly should be a standard option in C++), enables mouse support inside a terminal, getting the terminal size, and so forth. It's not as powerful as NCURSES, but works reasonably well on modern terminals (I have no desire to support old terminals, which is an advantage NCURSES has). You can compare your implementation against mine and copy anything you like from it.

Here's a screenshot of a Monet rendered inside PuTTY: https://user-images.githubusercontent.com/8254997/123489896-d42f2600-d5c7-11eb-8a81-c0989abe0224.png

Bill Kerney

Clovis Community College


From: Std-Proposals <std-proposals-bounces_at_[hidden]<mailto:std-proposals-bounces_at_[hidden]>> on behalf of David Braun via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>
Sent: Friday, June 25, 2021 12:14 AM
To: C++ STD Proposals (std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>) <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>
Cc: David Braun <da.braun1_at_[hidden]<mailto:da.braun1_at_[hidden]>>
Subject: [std-proposals] Color Text Output

I propose to add colored text output to the C++ standard via the <iomanip> header. See the attached document for details.

I am looking for feedback, particularly for the ANSI (Linux/Unix/Mac) implementation.

I was also wondering if anyone could tell me what happened to the C++ (14?) proposal for std::audio; is that project dead?

I’d also like to know if the idea for constexpr function parameters which has been floated since around C++17 is being seriously considered or not.

Like this:

Now: Discussed:

<template double d> void myFunc(constexpr double d){}

void myFunc(){}


David Aaron Braun




Received on 2021-06-26 04:54:54