crumblingstatue / hexerator

Versatile GUI hex editor focused on binary file exploration and aiding pattern recognition
https://crumblingstatue.github.io/hexerator-book/
Apache License 2.0
298 stars 5 forks source link

Pasting from clipboard on a new and empty session crashes. (+ smart paste?) #42

Open CosminPerRam opened 1 year ago

CosminPerRam commented 1 year ago

Regarding the crash: Let's say that I have this in my clipboard (as a string): 20 00 62 75 69 6C, I open Hexerator (a new session) and i go Edit > Paste at cursor > Hex text from clipboard then boom, panic: image As I often inspect hex from my clipboard (as I get it as output from my program) I would like to be able to directly paste it on a new session to inspect it.

Regarding 'smart paste': Doing println!("{:02X?}", data); (where data is an Vec<u8> for example, it outputs in the console this string: [20, 00, 62, 75, 69, 6C], and I want to copy and paste it in the program (let's say without the ending square brackets (so my clipboard now is 20, 00, 62, 75, 69, 6C), i get this error: image ... which is understandable as the string contains commas, but annoying as I have to get rid of all my commas to paste it in. Which is also a bit annoying as I apparently can't just CTRL + V to paste it.

crumblingstatue commented 1 year ago

Thank you for the report. I'll try to think about how to best support pasting data into an empty document, and support multiple formats to parse binary data from text.

crumblingstatue commented 1 year ago

Since Hexerator mainly deals with binary files, for which fixed length can be important, I don't want to silently expand the size of the binary file if the paste exceeds it. What I'm thinking of is displaying a message box that the paste exceeds the size, and ask the user whether they want to expand the file or not to continue with the paste.

However trying to implement this, I ran into some architectural problems with the UI of hexerator. I'll have to think about how to solve those problems before I can implement this in a satisfactory manner. Sorry in advance for the wait.

CosminPerRam commented 1 year ago

What I'm thinking of is displaying a message box that the paste exceeds the size, and ask the user whether they want to expand the file or not to continue with the paste.

Sounds nice, I think of this as being a setting (lets call it "do not exceed original size when pasting data" for example) that defaults to true.

Sorry in advance for the wait.

Absolutely no problem, thanks for considering it and sorry that I'm not able to help (skill issue). Godspeed.

crumblingstatue commented 1 year ago

Working on the UI side of things image

CosminPerRam commented 1 year ago

Heyo, any updates?

crumblingstatue commented 1 year ago

Sorry, I've been not in the mood to do programming in the past few weeks. I'll try to do something about this in the next few days, but no promises.

CosminPerRam commented 1 year ago

No problem, it's understandable, take your time!

crumblingstatue commented 1 year ago

The current situation is, you can paste now (on git main branch) without panicking. You can choose the "Extend document" option. image Then you can right click on the hex view and choose "Region properties" image Then you can click the "Reset" button on the region to reset it to the new size. image

I haven't yet determined how to do this automatically, because Hexerator views are flexible by default, so I don't want to accidentally overwrite a custom region without the user's consent.

Probably the way to go would be to properly establish the concept of "default" views/regions, which can be subject to automatic changes.