Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coloured texted in console/terminal

Using ncurses in C++, how would I colour my text in a console/terminal without breaking MinGW support? Are there any other libraries that can do this? I know that you can do it with ASCII characters, but this isn't fully supported. I don't want to use the Windows API.

like image 338
Will03uk Avatar asked Feb 01 '26 02:02

Will03uk


1 Answers

The discussion in the other answer is regarding Windows, so for the benefit of Win readers, I'm leaving this answer even though it is not cross-platform.

The Old New Thing blog covers some of the Win32 API that can be used to change text color in the console. See FillConsoleOutputAttribute and Console Screen Buffers.

like image 70
sean e Avatar answered Feb 02 '26 15:02

sean e



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!