GideonZ / 1541ultimate

Official GIT archive of 1541 ultimate II sources
GNU General Public License v3.0
173 stars 45 forks source link

Viewer should support hex mode for binary files #320

Open radius75 opened 1 year ago

radius75 commented 1 year ago

Related to #30

It depends on the file on which we are doing VIEW. Shows fragments of text that is "under" the window. I attach elv1.d64 on which it occurs. Probably some symbol causes that the content of the window is not cleared with spaces in the text line.

obraz obraz elv1.zip

GideonZ commented 1 year ago

The viewer should switch to binary mode when it is not text. Then the problem is solved.

Can you change the ticket title?

Message ID: @.***>

radius75 commented 1 year ago

Then the problem is solved.

Now I updated u2+ to fw3.10f and it doesn't show binary values. I choose View on elv1.d64. It's the same as it was. Did I misunderstand "solved"?

GideonZ commented 1 year ago

I didn't say it was solved. Someone else did. Was it you?

radius75 commented 1 year ago

I understood that Solved means Fixed on master branch :) obraz

GideonZ commented 1 year ago

No, the problem that you are seeing old data from the file browser will be solved, once / when the file viewer will support hex mode. It doesn't at this point. This is why I mentioned: change the ticket to: "Viewer should support hex mode for binary files."

radius75 commented 1 year ago

I reopen the issue, my mistake.

chrisgleissner commented 1 year ago

I would also find this feature very useful as I noticed its absence frequently when browsing my file collection.

When displaying the hex content, it would be great to use the format used by many C64 machine code monitors such as SMON:

<16 bit offset from start of file, in hex> ' ' <8 bytes of file data in hex, each byte followed by a space> ' ' <same 8 bytes rendered as PETSCII or '.' if not printable>

Example:

0000 00 00 41 42 43 44 45 46    ..ABCDEF
0008 00 00 00 00 00 00 00 47    .......G

The benefit of not just showing hex code, but also PETSCII, is to have the best of both worlds in the same view, e.g. when trying to find text in binary files.

Btw, issue #151 is closely related to this and could be viewed as an extension. The hex viewer idea is mentioned there, as well.

chrisgleissner commented 12 months ago

@radius75 This is now fixed as part of https://github.com/GideonZ/1541ultimate/pull/357

I added a new "Hex View" context-sensitive menu option rather than some magic which automatically infers whether to open the file using the existing (Text) viewer or the new hex viewer.

We could infer it using the file suffix (.prg || .d64 || .g64 || .d71 || .g71 || .t64 || -> hex viewer, else text viewer), but there are various edge cases which may be hard to understand for every user without additional documentation. For example, it is a perfectly valid use case to open a text file (.txt or .cfg suffix) in the hex viewer in order to check non-printable chars, such as Windows vs Unix line endings. Also, some users may have become accustomed to the current behaviour of the "View" option and even use it for binary files. One may decide to browse binary files not typical for a C64, such as .exe, .out, .c, .yaml, etc. It's hard to come up with a good generic logic that is both intuitive for every user without requiring lengthy documentation plus doesn't rely on an every increasing list of "suffix to editor" mappings. Thus, I found it cleaner to just introduce a dedicated new option to let the user be in control.

If you'd like to start using it, just checkout the branch in which I performed the change, build it as per Gideon's instructions, and flash your device. Please note that I only tested this using the Ultimate 64 Elite 1.4, however the changes are very high level (user interface tier only) and should work with other devices, as well.