Advertisement
Guest User

mcview_limit_hex_viewer_bytes_per_line

a guest
Mar 29th, 2022
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/src/editor/editoptions.c b/src/editor/editoptions.c
  2. index 11fd79caa..ffdc13b30 100644
  3. --- a/src/editor/editoptions.c
  4. +++ b/src/editor/editoptions.c
  5. @@ -117,8 +117,8 @@ edit_reload_syntax (void *data, void *user_data)
  6.  void
  7.  edit_options_dialog (WDialog * h)
  8.  {
  9. -    char wrap_length[16], tab_spacing[16];
  10. -    char *p, *q;
  11. +    char wrap_length[16], tab_spacing[16], bytes_per_line[16];
  12. +    char *p, *q, *r;
  13.      int wrap_mode = 0;
  14.      gboolean old_syntax_hl;
  15.  
  16. @@ -134,6 +134,7 @@ edit_options_dialog (WDialog * h)
  17.  
  18.      g_snprintf (wrap_length, sizeof (wrap_length), "%d", option_word_wrap_line_length);
  19.      g_snprintf (tab_spacing, sizeof (tab_spacing), "%d", option_tab_spacing);
  20. +    g_snprintf (bytes_per_line, sizeof (bytes_per_line), "%d", option_bytes_per_line);
  21.  
  22.      if (option_auto_para_formatting)
  23.          wrap_mode = 1;
  24. @@ -177,6 +178,8 @@ edit_options_dialog (WDialog * h)
  25.                      QUICK_CHECKBOX (N_("&Group undo"), &option_group_undo, NULL),
  26.                      QUICK_LABELED_INPUT (N_("Word wrap line length:"), input_label_left, wrap_length,
  27.                                           "edit-word-wrap", &p, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE),
  28. +                    QUICK_LABELED_INPUT (N_("Hex viewer bytes per line:"), input_label_left, bytes_per_line,
  29. +                                         "view-bytes-per-line", &r, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE),
  30.                  QUICK_STOP_GROUPBOX,
  31.              QUICK_STOP_COLUMNS,
  32.              QUICK_BUTTONS_OK_CANCEL,
  33. @@ -215,6 +218,14 @@ edit_options_dialog (WDialog * h)
  34.          g_free (q);
  35.      }
  36.  
  37. +    if (r != NULL)
  38. +    {
  39. +        option_bytes_per_line = atoi (r);
  40. +        if (option_bytes_per_line <= 0)
  41. +            option_bytes_per_line = -1;
  42. +        g_free (r);
  43. +    }
  44. +
  45.      if (wrap_mode == 1)
  46.      {
  47.          option_auto_para_formatting = TRUE;
  48. diff --git a/src/setup.c b/src/setup.c
  49. index 085b1d15b..fc761a7c4 100644
  50. --- a/src/setup.c
  51. +++ b/src/setup.c
  52. @@ -122,6 +122,9 @@ gboolean copymove_persistent_attr = TRUE;
  53.  /* Tab size */
  54.  int option_tab_spacing = DEFAULT_TAB_SPACING;
  55.  
  56. +/* Hex viewer bytes per line (0 to disable) */
  57. +int option_bytes_per_line = 0;
  58. +
  59.  /* Ugly hack to allow panel_save_setup to work as a place holder for */
  60.  /* default panel values */
  61.  int saving_setup;
  62. @@ -393,6 +396,7 @@ static const struct
  63.  #ifdef USE_INTERNAL_EDIT
  64.      { "editor_word_wrap_line_length", &option_word_wrap_line_length },
  65.      { "editor_option_save_mode", &option_save_mode },
  66. +    { "viewer_bytes_per_line", &option_bytes_per_line },
  67.  #endif /* USE_INTERNAL_EDIT */
  68.      { NULL, NULL }
  69.  };
  70. @@ -533,6 +537,8 @@ load_config (void)
  71.  #ifdef USE_INTERNAL_EDIT
  72.      if (option_word_wrap_line_length <= 0)
  73.          option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
  74. +    if (option_bytes_per_line < 0)
  75. +        option_bytes_per_line = 0;
  76.  #else
  77.      /* Reset forced in case of build without internal editor */
  78.      use_internal_edit = FALSE;
  79. diff --git a/src/setup.h b/src/setup.h
  80. index b43420f63..cfa6d754f 100644
  81. --- a/src/setup.h
  82. +++ b/src/setup.h
  83. @@ -91,6 +91,7 @@ extern gboolean copymove_persistent_attr;
  84.  extern gboolean classic_progressbar;
  85.  extern gboolean easy_patterns;
  86.  extern int option_tab_spacing;
  87. +extern int option_bytes_per_line;
  88.  extern gboolean auto_save_setup;
  89.  extern gboolean only_leading_plus_minus;
  90.  extern int cd_symlinks;
  91. diff --git a/src/viewer/display.c b/src/viewer/display.c
  92. index be6d60eb7..2f9d386ce 100644
  93. --- a/src/viewer/display.c
  94. +++ b/src/viewer/display.c
  95. @@ -324,7 +324,10 @@ mcview_update_bytes_per_line (WView * view)
  96.  
  97.      g_assert (bytes != 0);
  98.  
  99. -    view->bytes_per_line = bytes;
  100. +    view->bytes_per_line =
  101. +      (option_bytes_per_line > 0) && (bytes > option_bytes_per_line) ?
  102. +      option_bytes_per_line :
  103. +      bytes;
  104.      view->dirty = mcview_max_dirt_limit + 1;    /* To force refresh */
  105.  }
  106.  
  107.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement