blog - git - desktop - contact
Visualizing binary files
This is my hex editor bine :
It's all black and white, basically. A while ago, Vim's xxd gained the ability to color the output (this is not included in Vim Classic, which I use):
I wanted to have this feature in bine as well. So I started implementing it. An early draft can be seen here:
I think this is already an improvement, because it's easier to spot ranges with mostly ASCII text. But it's not that great. More colors would be needed and it would probably be better if the hex columns were right next to each other, instead of being separated by a space.
My TUI framework movwin uses ncurses under the hood (this is entirely intentional, because I value ncurses' feature stability). The framework itself is written in Python, ncurses is a C library. I had already noticed that making calls from Python to ncurses can be very expensive (whether this is a problem in general or just with Python + ncurses or simply with ncurses itself, I don't know, and it doesn't matter).
Without colors, bine writes an entire hex line using one curses call. With colors, there would have to be many calls per line. That would be too expensive.
And the framework itself is also not particularly well suited to using lots of different colors in a speedy manner. It has a hierarchical palette system and all that is costly. And I would have to maintain at least two versions of the color palette, because movwin supports a dark and a light theme by default.
Eventually, I came up with this:
... continue reading