Top
Best
New

Posted by tobr 2 days ago

Your hex editor should color-code bytes(simonomi.dev)
189 points | 53 comments
whizzter 1 minute ago|
Anyone tried using Kaitai descriptions? It seems like a fairly flexible system that would be an excellent starting point for a hex-editor that wants to add good higher level coloring (and perhaps even editing).
dspillett 3 hours ago||
Everything should try do some basic syntax highlighting IMO. Not too much, or it just becomes a sea of formatting that doesn't help at all. It is surprising how much difference just a little splash of colour can make if it isn't overdone. If possible, always include configuration options for the user though, so those with colour-blindness issues can tweak things to their needs, those who are just fussy can make the output fit with their finely adjusted system-wide colour schemes¹, and even better, where you can, allow bold/italic/other as well as colours so that those who barely see colour at all can play too.

Of course none of this helps those using screen-readers and other tech, so make sure that all your fancy colouring & such is additive so if it is all “lost” no meaning is absolutely lost with it.

--------

[1] Some people can be very vocal about this, more so than if highlighting isn't possible at all. If you give any output formatting they'll expect you to match, or be able to be made to match, their preferred style.

PunchyHamster 1 hour ago||
As long as you just give people list of settings for colors, they can pick as much color or monochrome as they want.

So by all means "color everything", people have different opinions on what they want colored so give them option

finaard 1 hour ago|||
I'd recommend for every developer to get one or more colourblind friends. I have some, and regularly send them screenshots of what I'm working on to get feedback what they can see and what they can read/can't read.

They've been absolutely invaluable for making sure their kind of people can't use my apps properly.

gortok 1 hour ago|||
8% of the male population has some form of colorblindness (for women it’s around 0.5%). I have deuteranomaly colorblindness. If you search for images on the internet related to that type of colorblindness you’ll find representations of how we see color and how we see the world.

It is not a fun condition to have, and leads to lots of problems in my everyday life. This blog post accidentally accentuated that issue, since the colors are (to what I can understand) very similar looking to me as a colorblind person.

1 in 12 men and 1 in 200 women go through the same sorts of experiences, and it’s worth it, if you aren’t color deficient, to try out some of the colorblindness sites and see the world as we do.

https://www.colourblindawareness.org/colour-blindness/colour...

gsich 46 minutes ago||
>1 in 12 men and 1 in 200 women go through the same sorts of experiences, and it’s worth it, if you aren’t color

Not the same, it's a gradient.

aa-jv 7 minutes ago|||
For sure, but if you don't have any friends, don't discount the value of using tools such as CoBlis:

https://www.color-blindness.com/coblis-color-blindness-simul...

.. to get an idea of the impact of your UI design on color-limited folks out there ..

I used this a few times to great effect, it was very revealing to see that my carefully selected teals and ambers were incomprehensible to some folks I really wanted to use my apps .. didn't take much iteration to come to a happy palette though, just needed a bit of care.

cubefox 32 minutes ago||
> Everything should try do some basic syntax highlighting IMO.

Interesting idea. So even syntax–highlighting natural language. Grammar highlighting, as it were. Prepositions, verbs, question marks, etc. An LLM could do it. Would it actually improve readability though? Seems likely!

BigTTYGothGF 29 minutes ago||
I think that's a good idea, altho you can probably get away with good old NLP to do it.
diydsp 5 minutes ago||
Were in an era where virtually all sw could have an mcp intf to do anything...not even just color.
Someone 38 minutes ago||
The first example is “go ahead, try to find the single C0 in these bytes” and then argues one should highlight C0 bytes.

If that’s true, how does the tool know I will be looking for C0 bytes and not for 03, D3, etc? The logical conclusion of that would be that the hex editor should uniquely color code every byte. And following the other examples even that’s not enough.

The proposed solution is to create groups of byte values that each get their unique color. I think that helps, but we can do better: add a search feature. That tells your editor what you are looking for. Once you enter a search string, it can highlight all hits.

Yes, “colorful output in a hexdump is useful for the same reason that syntax highlighting for code is useful”, but do you know what syntax highlighting needs? Knowledge of the expected content of a file. Without that, a hex editor at best can guess at how to color-code stuff.

IMO, if you want to add syntax coloring to a hex editor, give it pluggable syntax coloring and heuristics for deciding which one to use when.

While at it, also let those plugins control where to break lines, whether to show hex at all (why show it at all if a file has a few paragraphs of English text or an array of IEEE doubles?), etc.

Those plug-ins will make errors and sometimes, users will want to see all byte values, so you’ll need a way for the user to override them.

Antibabelic 14 minutes ago|
I don't think that's quite the point that example was intended to illustrate. The idea is not the you're looking for C0 bytes or any other kinds of bytes in particular, but rather that it's easier to fish out unique and interesting information in a sea of noise when you have color-coded bytes: like the fact that there's a conspicuous lonely C0 or some other value or series of values that stand out.
bombcar 5 minutes ago||
Exactly - though the writing style buries the lede until the end; the recommendation is to have at least a different color for each of the first nibbles (e.g, 0x is one color, 1x another). As a minimum that makes some outliers pop out. He then has other recommendations like highlighting the ASCII range, etc.

As a note, the some up there is load-bearing - color may lull you into complacency where the difference between 01 and 0F is major and important but not highlighted. More complicated regex built color tools designed to highlight "anomalies" could be developed but then you need to define what anomalies are (patters, places where a pattern changes, etc).

cuechan 1 hour ago||
For anyone who regularly has to look at/analyze binary files, i highly recommend ImHex [1].

Its a hex editor built with imgui and has a lot of built in tools. Imo the best feature is the data structure editor. You can write a data type definition similar to C and it overlays it on the hexdump and parses it in a structured way while you type.

It also has a node based editor.

1: https://github.com/WerWolv/ImHex

altairprime 54 minutes ago||
Does it do color highlighting by value of hex bytes, though?
sandos 38 minutes ago||
But does it have colors!?!??!
NooneAtAll3 2 hours ago||
Why did author decide that best way to demonstrate his idea would be by cutting contrast in half?

color-coding might be a great solution, but you don't really know beforehand which byte values are important. Manually selecting C0 to make it stand out it just ctrl+f with extra steps. (But I wouldn't mind something like "color 00 separate from ascii separate from the rest)

seszett 1 hour ago|
> Manually selecting C0 to make it stand out

That's not what they did, actually. C0 is the only byte in there that's above 3F or so, and it's far from it. Hence the very different colour, and the lack of contrast between the colours of the other bytes.

roelschroeven 1 hour ago||
When you're going to color-code bytes in a hex dump, I would expect each ASCII character in the right column to have the same color as the hex byte in the left column, making it easier to pair them. I wonder why that wasn't done here.
delta_p_delta_x 2 hours ago||

  > Your hex editor should colour-code bytes so it is easier for users to distinguish patterns
  > Article is fully in lowercase, which makes it harder for readers to make out sentences and the flow of the article
  > mfw the irony
gblargg 1 hour ago|
The text smashed up to the left border doesn't help either.
fleebee 23 minutes ago||
> having more colors makes it possible to recognize more complex patterns

The implicit cost here is that the simple patterns become harder to recognize when every byte is only subtly differently colored. Rather than give everything a different color, I'd rather have the important stuff highlighted.

In the comparisons given, I think hexyl's highlighting scheme is significantly more useful.

orphea 1 hour ago||
I get the idea but those specific examples are awful - not enough contrast.
ChrisRR 1 hour ago|
What a bad way to illustrate your point by using such similar looking pastel colours
altairprime 51 minutes ago|
Ironically, my complaint about the article was that the author apparently only uses typical human vision ranges here, rather than mapping 00..FFh onto an OKlab gradient of hue 0..359° that rewards those few of us with impeccable color fidelity with even better highlighting than most can see :) No doubt there’s value in contentful highlighting but I’d rather just have a straight hue translation on the circle at a fixed luminosity. There’s only 256 hues to discern, after all! And what a pleasure it would be to learn to read hex code by hue alone :D
More comments...