Will03uk
Will03uk

Reputation: 3444

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.

Upvotes: 3

Views: 1199

Answers (3)

EvilTeach
EvilTeach

Reputation: 28882

I can't speak for NCurses, but I have used PDCurses to do color under winXP/MSVC 6, WIN7/MSVC 2010 in a console application.

Upvotes: 0

sean e
sean e

Reputation: 11925

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.

Upvotes: 2

Mark Ransom
Mark Ransom

Reputation: 308530

Your reference to mingw implies that you expect this to work in a Windows Cmd window. Unfortunately the Cmd window doesn't support color, except globally for the whole window.

Upvotes: 1

Related Questions