4 ms·
Cross-platform terminal coloring was solved in the 1980s with termcap and then terminfo, for every terminal that's even come close to seeing mainstream use and
by msla 8y ago
Cross-platform terminal coloring was solved in the 1980s with termcap and then terminfo, for every terminal that's even come close to seeing mainstream use and which had colors in the first place. The libraries are part of the ncurses library and are shipped with every OS this stuff would build on to begin with.
This also solves the problem of moving the cursor and drawing a screen in general.
- Sean1708 8y agoAren't termcap and terminfo linux (or maybe unix) only?
- feanaro 8y agotermcap is supported on FreeBSD, at the least.
- msla 8y agoBoth of them long predate Linux. They're definitely Unix-flavored, but so's the Berkeley sockets library, and that's available everywhere, too. Ultimately, they're a library which is packaged with a database, and nothing about them is very system-specific except the terminal information in the database. https://en.wikipedia.org/wiki/Terminfo https://en.wikipedia.org/wiki/Terminfo
- ksherlock 8y agotermcap was written by Bill Joy in 1978. terminfo dates back to 1982.
- simplicio 8y agoEh, A lot of modern terminal emulators don't seem to bother providing termcap/info entries, or setting their own $TERM variables. In reality, most code just fires off ANSI sequences and hopes for the best. Looking quickly at the source for Hexyl, I think that's what the ansi_term library it uses does. If anything, I've found doing this works better then trying to muck around with ncurses, which often gets actively mislead by incorrect terminfo entries.
- msla 8y agoncurses wins once you use terminals beyond xterm.
- ksherlock 8y agotermcap/terminfo styling is limited to features like underline, bold and reverse. No coloring, per se.
- msla 8y agoThe downvotes prove how much HN hates history, I suppose.