Try to detect how many colours the terminal can handle.
This is based on the colors capability of the terminfo detected based on the TERM environment variable.
If the terminal can handle 8-bit colours and also has the COLORTERM environment variable set to 24bit or truecolor, then this function will return With24BitColours.