News for hackers. Stuff that matters.
Re:Hexyl: A command-line hex viewer by msla on Wednesday January 09, 2019 @11:58AM (#18866329)
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.

Re:Hexyl: A command-line hex viewer by simplicio on Wednesday January 09, 2019 @12:55PM (#18866929)
Eh, 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.

Re:Hexyl: A command-line hex viewer by msla on Friday January 11, 2019 @10:11PM (#18889344)
ncurses wins once you use terminals beyond xterm.
Re:Hexyl: A command-line hex viewer by Sean1708 on Wednesday January 09, 2019 @12:20PM (#18866557)
Aren't termcap and terminfo linux (or maybe unix) only?
Re:Hexyl: A command-line hex viewer by msla on Wednesday January 09, 2019 @05:32PM (#18869686)
Both 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

Re:Hexyl: A command-line hex viewer by ksherlock on Wednesday January 09, 2019 @06:11PM (#18869968)
termcap was written by Bill Joy in 1978. terminfo dates back to 1982.
Re:Hexyl: A command-line hex viewer by feanaro on Wednesday January 09, 2019 @04:22PM (#18869035)
termcap is supported on FreeBSD, at the least.
Re:Hexyl: A command-line hex viewer by ksherlock on Wednesday January 09, 2019 @06:16PM (#18870005)
termcap/terminfo styling is limited to features like underline, bold and reverse. No coloring, per se.
Re:Hexyl: A command-line hex viewer by simplicio on Thursday January 10, 2019 @12:52AM (#18871822)
"man terminfo | grep color" shows that pretty clearly to not be the case. There's plenty of codes for setting colors.
Re:Hexyl: A command-line hex viewer by msla on Friday January 11, 2019 @10:10PM (#18889341)
It's entirely possible termcap and terminfo have been allowing applications to color their output for longer than you've been alive.
Re:Hexyl: A command-line hex viewer by msla on Friday January 11, 2019 @10:09PM (#18889339)
The downvotes prove how much HN hates history, I suppose.