far2l icon indicating copy to clipboard operation
far2l copied to clipboard

Implement hex editor

Open unxed opened this issue 1 year ago • 4 comments

Something like Hexitor Windows Far plug in: https://plugring.farmanager.com/plugin.php?l=ru&pid=912

Another option is to use far2m, it has hex editor: https://github.com/shmuz/far2m https://habr.com/ru/articles/845998/comments/#comment_27388670

Another option is to use hiew (best thing in the world as for me), but it has some problems in Wine: https://bugs.winehq.org/show_bug.cgi?id=57281

And one more option is to build and use beye (ex biew): https://github.com/unxed/beye

unxed avatar Oct 07 '24 12:10 unxed

@unxed 3 последние ссылки почему ссылаются на winehq

Zeroes1 avatar Oct 07 '24 14:10 Zeroes1

@unxed 3 последние ссылки почему ссылаются на winehq

Спасибо, поправил.

unxed avatar Oct 07 '24 14:10 unxed

Пример как может работать уже сейчас в FAR2M, в hex моде нажал F3 я вошёл в режим редактирования байтов, чтобы проапдейтить файл - нажал F9, если хотим отменить ESC (хоткеи и поведение как в Hiew) :) всё это работает благодаря встроенному движку LUA.

https://github.com/user-attachments/assets/f2203a75-2465-409d-9824-985478cb8efb

Zeroes1 avatar Oct 07 '24 14:10 Zeroes1

Out of curiosity I made it in python (PR #2637) and what surprised me is that it works faster than the charmap plugin (the idea of ​​operation is based on the hexitor plugin).

At the moment there are no functions (F5-goto, F7-search, ..) and no editing of byte values, but ... I don't know how to read the shift/ctrl/alt key presses so that I can change the descriptions of the function keys. far3 calls the dialogue handling functions with the DN_CONTROLINPUT parameter, and far2 doesn't have it.

Please help (@unxed @akruphi) - indicating the code in far2l itself would be appreciated

m32 avatar Jan 17 '25 11:01 m32

I've ported this plugin to FarL2; a working version is available at https://github.com/m32/far2lhexitor

The following still needs to be added:

  • save_as (Shift+F2)
  • color selection in the settings dialog. It appears that the GetColorDialog function in the pick_color.hpp file is not available for plugins.

m32 avatar Sep 10 '25 02:09 m32

I've ported this plugin to FarL2; a working version is available at https://github.com/m32/far2lhexitor

Very fine!!! 👍 @m32 thank you!!!

May be you also add info about it in https://github.com/elfmz/far2l/#useful3party or are you planning to implement it directly in far2l master?

Note 1: now hexitor show file with ANSI codepage and by F8 available switch only ANSI->OEM->1200-> (Shift+F8 and other codepages not available). But now usually binaries has UTF-8 strings inside. Please, if possible, add UTF-8 codepage.

Also Find sequence (via F7) work only with Hex / ANSI / OEM / UTF16) and not understand Esc. Please add here UTF-8.

Note 2: when I open file from panel via F11->Hex editor I can not switch by F12 / Ctrl+Tab and after close Hex editor in panel current file changed to .. 😢

akruphi avatar Sep 10 '25 08:09 akruphi

Meanwhile, I added it in my repo, I think it will be better if it is in far2l itself - if someone uses far, they probably need a hexadecimal editor at hand. What is your opinion @elfmz ?

bugs :) - I just launched it, but now that it's there, it can be improved.

By the way:

  • fardialog.cpp - I don't like enumerations when creating dialogs, so I added a few classes and only provide what interests me, and the positioning and sizing are handled automatically - the idea is similar to wxWidgets. What do you think about adding this file to utils?

  • the color picker frame far2l/src should be in utils, otherwise you have to create the dialog yourself each time

m32 avatar Sep 10 '25 08:09 m32

Current file mark on panel is moved to 1st line after hex editor is closed.

PS: So cool! Thanks a lot. Dreaming of having it merged as one of default plugins

unxed avatar Sep 10 '25 19:09 unxed

added to main repo as https://github.com/elfmz/far2l/pull/2866

m32 avatar Sep 11 '25 07:09 m32

  • Hexitor must have a fixed number of bytes per character, so UTF-8 encoding is not supported in display/edit or search.
  • Hexitor is dialog-based, although it looks like a view/editor, so it's impossible to use F12 to switch to another window.

I fixed an error on exit and the current file would jump to the first one on the list.

m32 avatar Sep 15 '25 10:09 m32

Does utf8 limitation is also for docs? Russian text is broken now as it was converted from win1252, not from win1251 as it should

unxed avatar Sep 15 '25 10:09 unxed

  • Hexitor is dialog-based, although it looks like a view/editor, so it's impossible to use F12 to switch to another window.

Non-modal dialogs works in far2m and I hope I will can backport this functionality to far2l.

akruphi avatar Sep 15 '25 11:09 akruphi

I changed the codepage for readme_ru.txt, now it looks correct

m32 avatar Sep 15 '25 12:09 m32

I changed the codepage for readme_ru.txt, now it looks correct

Thank you!

Same codepage mismatch in hexitor/ChangeLog, if possible please fix it.

akruphi avatar Sep 15 '25 12:09 akruphi

ChangeLog properly converted

m32 avatar Sep 15 '25 13:09 m32

There are a few elements I don't know how to deal with: src/file.cpp: // TODO implement save as src/settings.cpp: // TODO: Implement color selection dialog src/settings.cpp: // TODO pick_color inaccessibile for plugins ? src/goto_dlg.cpp: // TODO implement checks uppon return src/goto_dlg.cpp: // TODO manage history in aHist src/editor.cpp: // TODO implement paste from keyboard

m32 avatar Sep 15 '25 13:09 m32

Something like Hexitor Windows Far plug in: https://plugring.farmanager.com/plugin.php?l=ru&pid=912

Done

unxed avatar Sep 25 '25 14:09 unxed