C++ Logo


Advanced search

Re: Color Text Output

From: David Braun <da.braun1_at_[hidden]>
Date: Sat, 26 Jun 2021 02:10:01 +0000
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_hotmail.com>
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]g<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-25 21:10:13