Ticket #4453 (new enhancement)
16-column HEX view in wide monitor
Reported by: | xintrea | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | Future Releases |
Component: | mcview | Version: | master |
Keywords: | columns, HEX, view | Cc: | |
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
In the current versions of MC, there is no setting to show the HEX viewer in the traditional 16-column form. The number of columns is adjusted to the width of the console. As a result, it is very inconvenient to calculate the byte addresses in the file being viewed.
It would be nice to add a setting that will allow you to include the traditional width of 16 columns. The setting can be made in the form of a number so that the user can write both 8 and 24 and 32 columns, as it will be more convenient for him.
The ready-made change is already in the form of a diff file: https://pastebin.com/NUKwveMZ
The appearance of the MC can be viewed in the article (RU) at the link: https://webhamster.ru/site/page/index/main/news/689
Change History
comment:3 Changed 18 months ago by zaytsev
Copying the patch from the pastebin:
diff --git a/src/editor/editoptions.c b/src/editor/editoptions.c index 11fd79caa..ffdc13b30 100644 --- a/src/editor/editoptions.c +++ b/src/editor/editoptions.c @@ -117,8 +117,8 @@ edit_reload_syntax (void *data, void *user_data) void edit_options_dialog (WDialog * h) { - char wrap_length[16], tab_spacing[16]; - char *p, *q; + char wrap_length[16], tab_spacing[16], bytes_per_line[16]; + char *p, *q, *r; int wrap_mode = 0; gboolean old_syntax_hl; @@ -134,6 +134,7 @@ edit_options_dialog (WDialog * h) g_snprintf (wrap_length, sizeof (wrap_length), "%d", option_word_wrap_line_length); g_snprintf (tab_spacing, sizeof (tab_spacing), "%d", option_tab_spacing); + g_snprintf (bytes_per_line, sizeof (bytes_per_line), "%d", option_bytes_per_line); if (option_auto_para_formatting) wrap_mode = 1; @@ -177,6 +178,8 @@ edit_options_dialog (WDialog * h) QUICK_CHECKBOX (N_("&Group undo"), &option_group_undo, NULL), QUICK_LABELED_INPUT (N_("Word wrap line length:"), input_label_left, wrap_length, "edit-word-wrap", &p, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), + QUICK_LABELED_INPUT (N_("Hex viewer bytes per line:"), input_label_left, bytes_per_line, + "view-bytes-per-line", &r, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE), QUICK_STOP_GROUPBOX, QUICK_STOP_COLUMNS, QUICK_BUTTONS_OK_CANCEL, @@ -215,6 +218,14 @@ edit_options_dialog (WDialog * h) g_free (q); } + if (r != NULL) + { + option_bytes_per_line = atoi (r); + if (option_bytes_per_line <= 0) + option_bytes_per_line = -1; + g_free (r); + } + if (wrap_mode == 1) { option_auto_para_formatting = TRUE; diff --git a/src/setup.c b/src/setup.c index 085b1d15b..fc761a7c4 100644 --- a/src/setup.c +++ b/src/setup.c @@ -122,6 +122,9 @@ gboolean copymove_persistent_attr = TRUE; /* Tab size */ int option_tab_spacing = DEFAULT_TAB_SPACING; +/* Hex viewer bytes per line (0 to disable) */ +int option_bytes_per_line = 0; + /* Ugly hack to allow panel_save_setup to work as a place holder for */ /* default panel values */ int saving_setup; @@ -393,6 +396,7 @@ static const struct #ifdef USE_INTERNAL_EDIT { "editor_word_wrap_line_length", &option_word_wrap_line_length }, { "editor_option_save_mode", &option_save_mode }, + { "viewer_bytes_per_line", &option_bytes_per_line }, #endif /* USE_INTERNAL_EDIT */ { NULL, NULL } }; @@ -533,6 +537,8 @@ load_config (void) #ifdef USE_INTERNAL_EDIT if (option_word_wrap_line_length <= 0) option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH; + if (option_bytes_per_line < 0) + option_bytes_per_line = 0; #else /* Reset forced in case of build without internal editor */ use_internal_edit = FALSE; diff --git a/src/setup.h b/src/setup.h index b43420f63..cfa6d754f 100644 --- a/src/setup.h +++ b/src/setup.h @@ -91,6 +91,7 @@ extern gboolean copymove_persistent_attr; extern gboolean classic_progressbar; extern gboolean easy_patterns; extern int option_tab_spacing; +extern int option_bytes_per_line; extern gboolean auto_save_setup; extern gboolean only_leading_plus_minus; extern int cd_symlinks; diff --git a/src/viewer/display.c b/src/viewer/display.c index be6d60eb7..2f9d386ce 100644 --- a/src/viewer/display.c +++ b/src/viewer/display.c @@ -324,7 +324,10 @@ mcview_update_bytes_per_line (WView * view) g_assert (bytes != 0); - view->bytes_per_line = bytes; + view->bytes_per_line = + (option_bytes_per_line > 0) && (bytes > option_bytes_per_line) ? + option_bytes_per_line : + bytes; view->dirty = mcview_max_dirt_limit + 1; /* To force refresh */ }