Set console output color

I have

“C:\Program Files\swipl\bin\swipl.exe” --goal=run_server -o …....\build\server\startserv.exe -c load2.pl

Works great but the warnings come in red (on black) which is barely readable. How can I change this?

Doc search points me to this wiki page:
http://www.swi-prolog.org/FAQ/ColorConsole.txt

I do not want to disable color. I don’t know what else I can try.

Made some progress but not satisfied with it because it is not done from the top level.

Create a Prolog source code file, e.g. message_property_test.pl

:- multifile
    user:message_property/2.

user:message_property(warning, color(fg(blue))).

test :-
 print_message(warning,'here').

Start top level

Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.0)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- 

Consult file and run test.

?- consult('D:/Cellular Information/Source Code/Prolog/message_property_test.pl').
true.

?- test.
Warning: Unknown message: here
true.

?- 

It is really blue on my screen.

Capture

Hope that helps.

One upon a time terminals were black with green characters. Then they got mostly white as this was supposed to be easier to read, something to which I fully agree. Now they seem to turn black again. I guess that is called innovation :slight_smile:

Anyway, SWI-Prolog’s color palettes are designed for light backgrounds. The ones for PceEmacs are still fairly easy to modify AFAIK, but the ones for the terminal are hard coded and can only be disabled. What should happen is that the code should use symbolic names and an additional table should translate this to physical colors. As @EricGT points out this is already the case for print_message/2 based on the level argument (thanks, forgot about that). Still, boot/messages.pl uses direct ansi color names for e.g., false, etc.

That all is not that hard. There is one harder problem: find the current foreground and (notably) background color of the console. There is an ansi sequence to ask the terminal, but then you have to be aware that the reply may appear just about anywhere in the input due to delays and filled buffers.

If someone wants to sort it out, I’m more than happy to review and merge. A first attempt could or course demand the user to select the color theme in swipl.ini/.swiplrc

What is the value of the environment variable TERM?

In general not of much use. @abaljeu is (I guess) the Windows console. I run terminator, on Ubuntu which tells me

COLORTERM=truecolor
TERM=xterm-256color

That doesn’t change if I change the fore or background color.

Does TERM=xrvt help? (I needed to do this to make Ubuntu-under-Windows usable, due to a bug that Microsoft has yet to fix)

Ah so I tried that, white on black. Works great. Until the next line of the script runs Visual Studio build, which dumps warnings in Yellow.

For what it’s worth, there is NO option to configure this in MSBuild, but Powershell has an ability to piping the output and recolor the text, so my problem is resolved.