WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
42.78k stars 1.88k forks source link

[Feature] Patterns should be stored project wide/globally #1241

Open LennardF1989 opened 1 year ago

LennardF1989 commented 1 year ago

What feature would you like to see?

Currently patterns in a project are tied to a specific file. This is great initially, but if you want to test the same pattern for another file, you will have to do some moving around.

On top of that, when you close a file tab, all associated data is lost (including the patterns).

A project should have a list of patterns (defined by a name, optionally associated with a file extension). When you then drag/drop a file on ImHex in an active project, you can pick which pattern you want to see (and edit) on the file (from a dropdown list of something).

Basically, this will decouple the pattern editor itself a file and rather couple it with a project (if there is one). Switching files will then just set the active pattern.

How will this feature be useful to you and others?

Larger projects with multiple files, or a file with one pattern, but testing it over multiple files, will become much easier.

This is also in line with some of the 010 Editor functionality where patterns are stored on the file system, and running it will just run it over the current active file. I do like ImHex approach though, where each file has its own "Pattern editor space", so to speak.

Maybe another solution is storing patterns outside of the project file and make them globally available. In the end, just looking for a way to easily have 1 "master pattern file" I can use for multiple files, without exporting/importing it constantly.

Request Type

Additional context?

No response

paxcut commented 1 year ago

patterns are associated to files using MIME. If you want to a one version of the pattern in many files use the option in the settings to Sync the pattern source code between providers then all the patterns in the project will be identical.

LennardF1989 commented 1 year ago

That's a possibility, but not exactly what I'm looking for. Basically what I'm proposing here is slighlty better pattern management within a project.

MIME/Type is hardly any useful in this case, since most files will be "application/octet-stream", and .pak is a pretty common file extension (for games and such) which can literally be any type of file.

Just as an example, this is how 010 Editor does its global templates in settings: image

Unless a "project" in ImHex is meant for a single file type (and even then a global setting that is applicable to ALL projects to sync the pattern source is hardly flexible :P), I feel it could use some QoL in that regard.

On top of that, this "feature" will also fix a situation where the original file a pattern was made for is moved and can no longer be opened. Unless you place the file back, or extract the pattern, you can no longer access it.

paxcut commented 1 year ago

The option doesnt sync all pattern in all projects only the patterns in the current project. How would you start to write a new pattern if every time you load a file you have to choose from the previous patterns? Right now when you open a file you are free to import any pattern to it or write your own. File associations only offer a suggestion which can be rejected but if you have a type that you use a lot it pays to create a mime for it so you don't have to import the same pattern all the time.

The system you propose is very confusing to me. I dont associate pattern with projects or with files. I prefer to have the freedom to choose how things are stored and projects are a great way to store many related parts of a setup into one file that can be easily saved and shared with others.

LennardF1989 commented 1 year ago

I'm in no way proposing limiting the available flexibility, but it's hard to argue that there are (some) UX oversights.

Let's say you started a project for a single file. You make a nice pattern for it. You then decide to test this pattern on another file, so you drag/drop that file into your workspace.

The workflow to now apply the pattern is either:

Rinse and repeat if you have a third or fourth file.

What I'm proposing here is that a pattern can be tagged as "project-wide", meaning that if I go into a pattern editor of another file, I can simply select it from a list and apply it, rather than going through the steps above. This does not replace currently functionality where any file can have its own "pattern editor space", but rather allows you to switch modes. On top of that, this keeps a "single point of truth", as you are sharing a single pattern, it means if I edit it in one editor, it's edited in all of them.

This last scenario is also not covered by the export/import process as it is. If I make changes to the file I imported earlier, I have to reimport it in all the tabs I want to apply the pattern to.

You could argue this may seem like I am just very lazy to perform a few extra steps, but just imagine reversing a package file of a game, you have to test it on 10-20 files, fix a bug here and there, and then export/import the adjusted file back into 10-20 other tabs. The current process is fine in most situations, if you go to larger scale things, it just becomes annoying.

qknight commented 3 months ago

@LennardF1989 I love your proposal. Just lost all my edits in the pattern editor because of a crash due to a bug in the pattern. Then I reloaded the program and all changes were lost. Took me 5 minutes to figure out what was going on and that each time I make a pattern change I have to manually export the pattern before trying it in case it could crash ImHex again.

The current state of pattern handling makes me even more want https://github.com/WerWolv/ImHex/issues/862 to be implemented.

At least we should make sure that users understand that their changes in the patterns are temporary thus not persisted compared to 010 editor templates.

@WerWolv I could offer some fuding for #862.

WerWolv commented 3 months ago

@qknight I'm all for improving the project and pattern loading/storing system. To do it properly will require quite a bit of time investment however. Fundings or PRs are always welcome, thank you