Skip to content
Tech News
← Back to articles

Visualizing Binary Files

read original more articles
Why This Matters

This article highlights innovative approaches to visualizing binary files in hex editors, emphasizing the importance of balancing visual clarity with performance constraints. It showcases how creative solutions, like using special characters instead of colors, can improve user experience without sacrificing speed, which is crucial for handling large files efficiently in the tech industry.

Key Takeaways

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