Why are there setf / setb and setaf / setab in tput?

I am trying to use tput to set the foreground and background colors in my terminal in a device-independent way.

If the whole termcap / terminfo / tput target becomes device independent, why are there both versions that explicitly use ANSI controls (setaf / setab) and versions that don't (shouldn't)?

This discussion cites terminfo (5), which in turn cites standards that explicitly state that they should be implemented using ANSI, not ANSI, respectively.

Why not just setf / setb, and they always set the foreground and background colors. I don't care how it's done, so I use tput!

+6
source share
1 answer

Why not just setf / setb, and they always set the foreground and background colors are actually two questions!

In the first part, why ANSI and non-ANSI commands exist are too long for exaplin, and this is not necessary, as the story is pretty well explained on Wikipedia.

The second part, perhaps, can be freely rephrased to "what's the difference?" or "what can I do with this?"

Difference: ANSI terminals use a different mapping between color number and colors than non-ANSI terminals. For example, the code for yellow on one will be blue on the other. There are only two mapping tables. These things are described pretty well on Wikipedia.

What you can do with this: Find out what type of terminal you have and use the appropriate command. Or change your termcap. However, unfortunately, none of these solutions is completely general.

+1
source

Source: https://habr.com/ru/post/954160/


All Articles