-
-
Notifications
You must be signed in to change notification settings - Fork 332
Description
There are some ways to detect truecolor terminals that tcell is not using, if the README is currently correct.
Please see this document for more ways to detect truecolor. I will quote the important sections below.
Since ncurses-6.0-20180121, terminfo began to support the 24-bit True Color capability under the name of "RGB". You need to use the "setaf" and "setab" commands to set the foreground and background respectively.
Out of all the options I mention, this seems like it could be the most reliable. I am not sure how widespread support for this is though, and whether it depends on ncurses or not.
There will be no reliable way to detect the "RGB" flag until the new release of terminfo/ncurses. S-Lang author added a check for $COLORTERM containing either "truecolor" or "24bit" (case sensitive). In addition, VTE, Konsole and iTerm2 set this variable to "truecolor". It has been in VTE for a while and but is relatively new, being still git-only in Konsole and iTerm2).
This is obviously not a reliable method, and is not forwarded via sudo, SSH etc. However, whenever it errs, it errs on the safe side. It does not advertise support when it is actually supported. [...] Checking $COLORTERM is recommended though since it will lead to a more seamless desktop experience where only one variable needs to be set. This would be system-wide so that the user would not need to set it separately for each app.
The $COLORTERM
variable is why I originally made this issue. It is very easy to add support for, solves my personal terminal concerns (I use Guake), and is a growing standard, due to support from terminal libraries like VTE. I could make a PR to support this, although I would appreciate some guidance/direction.
The document mentions another method:
A more reliable method in an interactive program which can read terminal responses, and one that is transparent to things like sudo, SSH, etc.. is to simply try setting a truecolor value and then query the terminal to ask what color it currently has. If the response replies the same color that was set then it indicates truecolor is supported.
[...] Here we ask to set the background color to
RGB(1,2,3)
- an unlikely default choice - and request the value that we just set.
While potentially being more accurate, I don't see this as a viable solution for tcell, as it would be comparatively slow, and require changing visual things like the background on application startup. Maybe changing text color (without printing text yet) is possible?