News for hackers. Stuff that matters.
Re:Hexyl: A command-line hex viewer by Sean1708 on Wednesday January 09, 2019 @11:39AM (#18866124)
I'm struggling to even find the canonical source code for xxd, let alone a way to provide a patch. You could probably email the address in the man page, but that's from 1997 so I wouldn't be too optimistic about getting a response. And even then it's quite likely that the original author considers xxd finished and would be reluctant to accept patches for it anyway. On top of all that the hard part of this work (cross-platform terminal colours) had already been done for the author, so the implementation was probably far easier than adding colour output to xxd would have been.
Re:Hexyl: A command-line hex viewer by kazinator on Wednesday January 09, 2019 @02:29PM (#18867945)
xxd is distributed with Vim.

I've never thought of xxd as being anything but a "Vim thing".

That it had its own history (1990-1998) before being pulled into Vim is a TIL for me.

Here you go:

https://github.com/vim/vim/tree/master/src/xxd

There might still be other versions of this out there, but I suspect most OS distros pick up xxd by way of packaging Vim.

So if you work on some other xxd, you're probably in a dead fork.

The man page is also from Vim:

https://github.com/vim/vim/blob/master/runtime/doc/xxd.1

My first patch to xxd, if I were to work on it, would be to fix the man page to indicate clearly that it's the xxd bundled with Vim.

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.