1

In terminal I use a white on black. A program appears to expect black on white text or something like that. Because of the use of color to highlight important commands, they force regular text to be black. My question is, is it possible for a program to identify the colors in use in a terminal, local and ssh, as to recognize and change colors if needed? If it is possible I plan to file a bug report but if nothing can be done I won't.

1 Answers1

3

This depends on the terminal, but the short answer is yes: most terminals that support colors also support a way to query the color settings (and even to change the color palette).

Programs that present a full-screen text mode interface often use the curses library. It provides a function color_content to query the red-green-blue value of a color pair, which specifies both the background and the foreground. The color pair 0 is the default.

Programs that just print text but don't move the cursor around often do it by printing escape sequences to change colors. In theory, different terminals might use different escape sequences, but in practice all modern terminals (except on Windows, where terminals work differently) support a basic set of escape sequences including one to set colors. There are escape sequences to query color information (that's how curses works), but they're a bit harder to use.

All of this works transparently over SSH.