QT color console on MacOS - lost default foreground colour

MacOS 10.13.6, SWIP 8.2.0

On one of my computers the default foreground colour for the QT console seems to have been set to white making it invisible on the white background. Selecting it makes it visible. It wasn’t originally this way - the release worked fine for some time - and it isn’t occurring on my other computer. In addition, previously installed releases (e.g., 8.1.32) now have the same issue.


  1. In init.pl set the color_term environment flag to false and restart.
  2. Load library(themes/dark).

I’ve tried digging into the ansi_term library without much success. For example, the doc says I should be able to query the foreground colour using alias foreground but:

?- ansi_get_color(foreground,RGB).

Not really sure how all this is supposed to work, so hoping I’m just missing something obvious. Any suggestions of how to get out of this welcome.

Further digging seems to indicate that some color table is broken. black, and red both output as white. So print_message(query,halt) isn’t visible while print_message(information,halt) is (in green with a % prefix).

Is the color picker (menu item Settings/Colors …) relevant to this? I’ve never figured out what this is for.

There have been similar issues in the past. The color picker menu can re-arrange the mapping for the 16 ANSI color palette. Somehow that can get mixed up. Possibly remove the config file in ~/.config/swi-prolog (think it is called pqConsole.plist or something like that).

This predicate performs a handshake with normal terminals to find the color mapping. This doesn’t work for pqConsole. It also makes little sense as the console doesn’t listen to some sort of system preferences AFAIK. So, normally all should work find as is in light theme and you can load dark theme if you prefer (or define a new theme :slight_smile: ).

This sounds promising. However. the only file in ~/.config/swi-prolog is init.pl (along with directories dir-history and xpce). Also a search of that name fails.

A search on swipl-devel indicates that pqConsole is referenced from library/win_menu.pl and the menu item is associated with pqConsole:select_ANSI_term_colors. But I’m not sure where that reference leads.

Right. It is there in the Linux version of the Qt console, but on in the Mac version. Can’t find this right now :frowning:

Into the packages/swipl-win code … Don’t ask more …

Sorry for the problem…

Not having a Mac where to debug is making this more difficult than it should be.
I’tried yesterday on a Linux box, and could not spot the problem.

Today I have only Win10, and Qt + MSVC 2017 cannot even compile the (small) project.
(@Jan: seems there is an include of SWI-Stream.h missing, or a misplacing of MSVC flags, since it chockes about unknown ssize_t… will try to solve this…)

The location of the preferences file is handled by QSettings, so, according to the docs and the source, the path could be

So many years I didn’t compiled on Windows, now I think MSVC cannot be used…
Trying with MinGW, if I survive the Qt compiler kit setup…

Found it; thanks for the info. I’ve got one working system so I should be able to resolve this one way or the other.

1 Like

If you are using Windows, WSL 2 is releasing/has been released to the public this week. I have it being on the slow ring, but that should not be needed any more.

See: How to get the Windows 10 May 2020 Update

The com.swi-prolog.pqConsole.plist on the working system matches the on the non-working system except for the MRU2.path, pqMainWindow.pos and pqMainWindow.size values, which is to be expected. So my theory of a corrupted config file doesn’t fit. I’ll keep digging.

You could try to set the environment variable QDEBUG=stderr, or better (since I don’t know where the stderr output could show) an absolute writable path. Then loading the Preferences class should display some info…

Not sure how to do this with a MacOS bundle; any hints?

OK. Launched SWI_Prolog executable from terminal with QDEBUG=stderr. Just message:
Loading preferences from "~/Library/Preferences/com.swi-prolog.pqConsole.plist"

repeated 4 times. QT console text still invisible.

I guess you already tried to delete the file, as suggested by Jan … sorry I have no better clue …

Yes, tried that. I was a bit surprised that the font setting was preserved. It seems like there’s some other persistent data somewhere.

Thanks for the suggestions.

I fixed this by experimenting with the custom colour table using the QT Color Picker Dialog. To summarize:

Module ansi_term maps 8 color names to numbers:

ansi_color(black,   0).
ansi_color(red,     1).
ansi_color(green,   2).
ansi_color(yellow,  3).
ansi_color(blue,    4).
ansi_color(magenta, 5).
ansi_color(cyan,    6).
ansi_color(white,   7).
ansi_color(default, 9).

At least numbers 0-7 correspond to custom colours in the picker dialog (2 rows of 8) as follows:

0 2 4 6 ? ? ? ?
1 3 5 7 ? ? ? ?

Note that yellow is currently a rust color, at least on my two systems.

Somehow in my ad hoc testing of the stable release I had re-defined red and black to be the colour white. My bad. But these definitions seem to have been preserved somewhere but it’s not clear where, since deleting the pqConsole.plist didn’t seem to change anything.

Unless I’m missing something, it’s not clear this color picker is very useful and can be problematic, e.g., if black is white, particularly for naive users (like me). ansi_term supports many colour formats (8 bit and 24 bit among others), so re-defining the core colour set isn’t something that is needed IMO. I suggest it at least be removed from the menu. As an escape hatch, it can still be invoked as pqConsole:select_ANSI_term_colors.