Skip to content

Conversation

shewitt-au
Copy link
Contributor

@shewitt-au shewitt-au commented Jul 20, 2025

Feature description

Add the ability to go from a coloured selection in the hex editor to the location responsible in the pattern editor.

The corresponding pattern language mods are here.

Demo

demo.mp4

Notes

Going to the line instead of the exact variable location would probably be just as good. Possibly better. Part of the reason I made it this way is because column information was being, in some cases, incorrectly calculated. In part it's like this so I could easily check (at least in some cases) that the column information was correct. I think this feature is useful, but a large part of my motivation was to make it this way (exact location) was as a debugging tool.

I made this PR to correct incorrect column calculations in the lexer. They were caused by tabs. This code was rejected in favour of string search-&-replaces before parsing. I think the lexer should handle tabs but what is is. Even if S&R preprocessing is needed now, in future if tabs are supported a lexer that won’t choke on them is one less issue to address. That said, although this PR origionally contained the lexer mods, I have removed them. The code as is seems to work and every S&R seems to feed the text editor (and possibly the lexer too), which can't handle tabs.

I have reused an existing icon in the menu. I guess this could be confusing, I'm no artist however.

Implementation description

We lex, then preprocess and then parse. Then an AST is built. Stuff happens. Eventually we get patterns. I had to make changes to get the line/column info from the lexer to the patterns. There were some places where the location information was incorrect or not useful. All that said, I think I've got the info from the lexer to the patterns without any collateral damage. But I could be wrong.

No more work in this

I am not going to work on this any further. It's far from perfect.

I can't help but I feel I'm wasting my time trying to contribute to ImHex. From my perspective my PRs are just rejected in favour of solutions which, in my opinion, make the product as a whole more fragile and harder to improve. I take the time to justify my choices but get only destructive criticism. I will complete my in progress stuff. Beyond that I can't say.

@shewitt-au shewitt-au changed the title Goto in pattern editor Got from a coloured entry in the hex editor to the location responsible in the pattern editor Jul 20, 2025
@shewitt-au shewitt-au changed the title Got from a coloured entry in the hex editor to the location responsible in the pattern editor hex editor -> location responsible pattern editor Jul 20, 2025
@shewitt-au shewitt-au changed the title hex editor -> location responsible pattern editor hex editor -> location in pattern editor Jul 20, 2025
@shewitt-au shewitt-au force-pushed the goto-in-pattern-editor branch from 6e6685b to 0bebe8c Compare July 21, 2025 16:53
@shewitt-au shewitt-au marked this pull request as ready for review July 21, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant