Manual pages: mcmcdiffmceditmcview

root/src/setup.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. setup__is_cfg_group_must_panel_config
  2. setup__move_panels_config_into_separate_file
  3. load_config
  4. setup__load_panel_state
  5. load_layout
  6. load_keys_from_section
  7. panel_save_type
  8. panels_load_options
  9. panels_save_options
  10. save_config
  11. save_layout
  12. save_panel_types
  13. setup_init
  14. load_setup
  15. save_setup
  16. done_setup
  17. setup_save_config_show_error
  18. load_key_defs
  19. load_anon_passwd
  20. panel_load_setup
  21. panel_save_setup

   1 /*
   2    Setup loading/saving.
   3 
   4    Copyright (C) 1994-2025
   5    Free Software Foundation, Inc.
   6 
   7    This file is part of the Midnight Commander.
   8 
   9    The Midnight Commander is free software: you can redistribute it
  10    and/or modify it under the terms of the GNU General Public License as
  11    published by the Free Software Foundation, either version 3 of the License,
  12    or (at your option) any later version.
  13 
  14    The Midnight Commander is distributed in the hope that it will be useful,
  15    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17    GNU General Public License for more details.
  18 
  19    You should have received a copy of the GNU General Public License
  20    along with this program.  If not, see <https://www.gnu.org/licenses/>.
  21  */
  22 
  23 /** \file setup.c
  24  *  \brief Source: setup loading/saving
  25  */
  26 
  27 #include <config.h>
  28 
  29 #include <stdlib.h>
  30 #include <string.h>
  31 #include <stdio.h>
  32 #include <sys/types.h>
  33 #include <sys/stat.h>
  34 
  35 #include "lib/global.h"
  36 
  37 #include "lib/tty/tty.h"
  38 #include "lib/tty/key.h"
  39 #include "lib/mcconfig.h"  // num_history_items_recorded
  40 #include "lib/fileloc.h"
  41 #include "lib/terminal.h"  // convert_controls()
  42 #include "lib/timefmt.h"
  43 #include "lib/util.h"
  44 #include "lib/charsets.h"
  45 
  46 #ifdef ENABLE_VFS_FTP
  47 #include "src/vfs/ftpfs/ftpfs.h"
  48 #endif
  49 #ifdef ENABLE_VFS_SHELL
  50 #include "src/vfs/shell/shell.h"
  51 #endif
  52 
  53 #include "filemanager/dir.h"
  54 #include "filemanager/filemanager.h"
  55 #include "filemanager/tree.h"      // xtree_mode
  56 #include "filemanager/hotlist.h"   // load/save/done hotlist
  57 #include "filemanager/panelize.h"  // load/save/done panelize
  58 #include "filemanager/layout.h"
  59 #include "filemanager/cmd.h"
  60 
  61 #include "args.h"
  62 #include "execute.h"  // pause_after_run
  63 #include "clipboard.h"
  64 #include "selcodepage.h"
  65 
  66 #ifdef USE_INTERNAL_EDIT
  67 #include "src/editor/edit.h"
  68 #endif
  69 
  70 #include "src/viewer/mcviewer.h"  // For the externs
  71 
  72 #include "setup.h"
  73 
  74 /*** global variables ****************************************************************************/
  75 
  76 /* Only used at program boot */
  77 gboolean boot_current_is_left = TRUE;
  78 
  79 /* If on, default for "No" in delete operations */
  80 gboolean safe_delete = FALSE;
  81 /* If on, default for "No" in overwrite files */
  82 gboolean safe_overwrite = FALSE;
  83 
  84 /* Controls screen clearing before an exec */
  85 gboolean clear_before_exec = TRUE;
  86 
  87 /* Asks for confirmation before deleting a file */
  88 gboolean confirm_delete = TRUE;
  89 /* Asks for confirmation before deleting a hotlist entry */
  90 gboolean confirm_directory_hotlist_delete = FALSE;
  91 /* Asks for confirmation before overwriting a file */
  92 gboolean confirm_overwrite = TRUE;
  93 /* Asks for confirmation before executing a program by pressing enter */
  94 gboolean confirm_execute = FALSE;
  95 /* Asks for confirmation before leaving the program */
  96 gboolean confirm_exit = FALSE;
  97 
  98 /* If true, at startup the user-menu is invoked */
  99 gboolean auto_menu = FALSE;
 100 /* This flag indicates if the pull down menus by default drop down */
 101 gboolean drop_menus = FALSE;
 102 
 103 /* Asks for confirmation when using F3 to view a directory and there
 104    are tagged files */
 105 gboolean confirm_view_dir = FALSE;
 106 
 107 /* Ask file name before start the editor */
 108 gboolean editor_ask_filename_before_edit = FALSE;
 109 
 110 panel_view_mode_t startup_left_mode;
 111 panel_view_mode_t startup_right_mode;
 112 
 113 gboolean copymove_persistent_attr = TRUE;
 114 
 115 /* Tab size */
 116 int option_tab_spacing = DEFAULT_TAB_SPACING;
 117 
 118 /* Ugly hack to allow panel_save_setup to work as a place holder for */
 119 /* default panel values */
 120 int saving_setup;
 121 
 122 panels_options_t panels_options = {
 123     .show_mini_info = TRUE,
 124     .kilobyte_si = FALSE,
 125     .mix_all_files = FALSE,
 126     .show_backups = TRUE,
 127     .show_dot_files = TRUE,
 128     .fast_reload = FALSE,
 129     .fast_reload_msg_shown = FALSE,
 130     .mark_moves_down = TRUE,
 131     .reverse_files_only = TRUE,
 132     .auto_save_setup = FALSE,
 133     .navigate_with_arrows = FALSE,
 134     .scroll_pages = TRUE,
 135     .scroll_center = FALSE,
 136     .mouse_move_pages = TRUE,
 137     .filetype_mode = TRUE,
 138     .permission_mode = FALSE,
 139     .qsearch_mode = QSEARCH_PANEL_CASE,
 140     .torben_fj_mode = FALSE,
 141     .select_flags = SELECT_MATCH_CASE | SELECT_SHELL_PATTERNS,
 142 };
 143 
 144 gboolean easy_patterns = TRUE;
 145 
 146 /* It true saves the setup when quitting */
 147 gboolean auto_save_setup = TRUE;
 148 
 149 /* If true, then the +, - and \ keys have their special meaning only if the
 150  * command line is empty, otherwise they behave like regular letters
 151  */
 152 gboolean only_leading_plus_minus = TRUE;
 153 
 154 /* Automatically fills name with current selected item name on mkdir */
 155 gboolean auto_fill_mkdir_name = TRUE;
 156 
 157 /* If set and you don't have subshell support, then C-o will give you a shell */
 158 gboolean output_starts_shell = FALSE;
 159 
 160 #ifdef USE_FILE_CMD
 161 /* If set, we execute the file command to check the file type */
 162 gboolean use_file_to_check_type = TRUE;
 163 #endif
 164 
 165 gboolean verbose = TRUE;
 166 
 167 /*
 168  * Whether the Midnight Commander tries to provide more
 169  * information about copy/move sizes and bytes transferred
 170  * at the expense of some speed
 171  */
 172 gboolean file_op_compute_totals = TRUE;
 173 
 174 /* If true use the internal viewer */
 175 gboolean use_internal_view = TRUE;
 176 /* If set, use the builtin editor */
 177 gboolean use_internal_edit = TRUE;
 178 
 179 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
 180 int default_source_codepage = -1;
 181 char *autodetect_codeset = NULL;
 182 gboolean is_autodetect_codeset_enabled = FALSE;
 183 
 184 #ifdef HAVE_ASPELL
 185 char *spell_language = NULL;
 186 #endif
 187 
 188 /* Value of "other_dir" key in ini file */
 189 char *saved_other_dir = NULL;
 190 
 191 /* If set, then print to the given file the last directory we were at */
 192 char *last_wd_str = NULL;
 193 
 194 /* Set when main loop should be terminated */
 195 int quit = 0;
 196 
 197 /* Set to TRUE to suppress printing the last directory */
 198 int print_last_revert = FALSE;
 199 
 200 #ifdef USE_INTERNAL_EDIT
 201 /* index to record_macro_buf[], -1 if not recording a macro */
 202 int macro_index = -1;
 203 
 204 /* macro stuff */
 205 struct macro_action_t record_macro_buf[MAX_MACRO_LENGTH];
 206 
 207 GArray *macros_list = NULL;
 208 #endif
 209 
 210 /*** file scope macro definitions ****************************************************************/
 211 
 212 /* In order to use everywhere the same setup for the locale we use defines */
 213 #define FMTYEAR _ ("%b %e  %Y")
 214 #define FMTTIME _ ("%b %e %H:%M")
 215 
 216 /*** file scope type declarations ****************************************************************/
 217 
 218 /*** forward declarations (file scope functions) *************************************************/
 219 
 220 /*** file scope variables ************************************************************************/
 221 
 222 static char *profile_name = NULL;        /* ${XDG_CONFIG_HOME}/mc/ini */
 223 static char *panels_profile_name = NULL; /* ${XDG_CONFIG_HOME}/mc/panels.ini */
 224 
 225 static const struct
 226 {
 227     const char *key;
 228     int list_format;
 229 } list_formats[] = {
 230     { "full", list_full },    //
 231     { "brief", list_brief },  //
 232     { "long", list_long },    //
 233     { "user", list_user },    //
 234     { NULL, 0 },
 235 };
 236 
 237 static const struct
 238 {
 239     const char *opt_name;
 240     panel_view_mode_t opt_type;
 241 } panel_types[] = {
 242     { "listing", view_listing },  //
 243     { "quickview", view_quick },  //
 244     { "info", view_info },        //
 245     { "tree", view_tree },        //
 246     { NULL, view_listing },
 247 };
 248 
 249 static const struct
 250 {
 251     const char *opt_name;
 252     int *opt_addr;
 253 } layout_int_options[] = {
 254     { "output_lines", &output_lines },
 255     { "left_panel_size", &panels_layout.left_panel_size },
 256     { "top_panel_size", &panels_layout.top_panel_size },
 257     {
 258         NULL,
 259         NULL,
 260     },
 261 };
 262 
 263 static const struct
 264 {
 265     const char *opt_name;
 266     gboolean *opt_addr;
 267 } layout_bool_options[] = {
 268     { "message_visible", &mc_global.message_visible },
 269     { "keybar_visible", &mc_global.keybar_visible },
 270     { "xterm_title", &xterm_title },
 271     { "command_prompt", &command_prompt },
 272     { "menubar_visible", &menubar_visible },
 273     { "free_space", &free_space },
 274     { "horizontal_split", &panels_layout.horizontal_split },
 275     { "vertical_equal", &panels_layout.vertical_equal },
 276     { "horizontal_equal", &panels_layout.horizontal_equal },
 277     {
 278         NULL,
 279         NULL,
 280     },
 281 };
 282 
 283 static const struct
 284 {
 285     const char *opt_name;
 286     gboolean *opt_addr;
 287 } bool_options[] = {
 288     { "verbose", &verbose },
 289     { "shell_patterns", &easy_patterns },
 290     { "auto_save_setup", &auto_save_setup },
 291     { "preallocate_space", &mc_global.vfs.preallocate_space },
 292     { "auto_menu", &auto_menu },
 293     { "use_internal_view", &use_internal_view },
 294     { "use_internal_edit", &use_internal_edit },
 295     { "clear_before_exec", &clear_before_exec },
 296     { "confirm_delete", &confirm_delete },
 297     { "confirm_overwrite", &confirm_overwrite },
 298     { "confirm_execute", &confirm_execute },
 299     { "confirm_history_cleanup", &mc_global.widget.confirm_history_cleanup },
 300     { "confirm_exit", &confirm_exit },
 301     { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete },
 302     { "confirm_view_dir", &confirm_view_dir },
 303     { "safe_delete", &safe_delete },
 304     { "safe_overwrite", &safe_overwrite },
 305     { "use_8th_bit_as_meta", &use_8th_bit_as_meta },
 306     { "mouse_move_pages_viewer", &mcview_mouse_move_pages },
 307     { "mouse_close_dialog", &mouse_close_dialog },
 308     { "fast_refresh", &fast_refresh },
 309     { "drop_menus", &drop_menus },
 310     { "wrap_mode", &mcview_global_flags.wrap },
 311     { "old_esc_mode", &old_esc_mode },
 312     { "cd_symlinks", &mc_global.vfs.cd_symlinks },
 313     { "show_all_if_ambiguous", &mc_global.widget.show_all_if_ambiguous },
 314 #ifdef USE_FILE_CMD
 315     { "use_file_to_guess_type", &use_file_to_check_type },
 316 #endif
 317     { "alternate_plus_minus", &mc_global.tty.alternate_plus_minus },
 318     { "only_leading_plus_minus", &only_leading_plus_minus },
 319     { "show_output_starts_shell", &output_starts_shell },
 320     { "xtree_mode", &xtree_mode },
 321     { "file_op_compute_totals", &file_op_compute_totals },
 322     { "classic_progressbar", &classic_progressbar },
 323 #ifdef ENABLE_VFS
 324 #ifdef ENABLE_VFS_FTP
 325     { "use_netrc", &ftpfs_use_netrc },
 326     { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy },
 327     { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections },
 328     { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy },
 329     { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options },
 330     { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls },
 331     { "ignore_ftp_chattr_errors", &ftpfs_ignore_chattr_errors },
 332 #endif
 333 #endif
 334 #ifdef USE_INTERNAL_EDIT
 335     { "editor_fill_tabs_with_spaces", &edit_options.fill_tabs_with_spaces },
 336     { "editor_return_does_auto_indent", &edit_options.return_does_auto_indent },
 337     { "editor_backspace_through_tabs", &edit_options.backspace_through_tabs },
 338     { "editor_fake_half_tabs", &edit_options.fake_half_tabs },
 339     { "editor_option_save_position", &edit_options.save_position },
 340     { "editor_option_auto_para_formatting", &edit_options.auto_para_formatting },
 341     { "editor_option_typewriter_wrap", &edit_options.typewriter_wrap },
 342     { "editor_edit_confirm_save", &edit_options.confirm_save },
 343     { "editor_syntax_highlighting", &edit_options.syntax_highlighting },
 344     { "editor_persistent_selections", &edit_options.persistent_selections },
 345     { "editor_drop_selection_on_copy", &edit_options.drop_selection_on_copy },
 346     { "editor_cursor_beyond_eol", &edit_options.cursor_beyond_eol },
 347     { "editor_cursor_after_inserted_block", &edit_options.cursor_after_inserted_block },
 348     { "editor_visible_tabs", &edit_options.visible_tabs },
 349     { "editor_visible_spaces", &edit_options.visible_tws },
 350     { "editor_line_state", &edit_options.line_state },
 351     { "editor_simple_statusbar", &edit_options.simple_statusbar },
 352     { "editor_check_new_line", &edit_options.check_nl_at_eof },
 353     { "editor_show_right_margin", &edit_options.show_right_margin },
 354     { "editor_group_undo", &edit_options.group_undo },
 355     { "editor_state_full_filename", &edit_options.state_full_filename },
 356 #endif
 357     { "editor_ask_filename_before_edit", &editor_ask_filename_before_edit },
 358     { "nice_rotating_dash", &nice_rotating_dash },
 359     { "shadows", &mc_global.tty.shadows },
 360     { "mcview_remember_file_position", &mcview_remember_file_position },
 361     { "auto_fill_mkdir_name", &auto_fill_mkdir_name },
 362     { "copymove_persistent_attr", &copymove_persistent_attr },
 363     {
 364         NULL,
 365         NULL,
 366     },
 367 };
 368 
 369 static const struct
 370 {
 371     const char *opt_name;
 372     int *opt_addr;
 373 } int_options[] = {
 374     { "pause_after_run", &pause_after_run },
 375     { "mouse_repeat_rate", &mou_auto_repeat },
 376     { "double_click_speed", &double_click_speed },
 377     { "old_esc_mode_timeout", &old_esc_mode_timeout },
 378     { "max_dirt_limit", &mcview_max_dirt_limit },
 379     { "num_history_items_recorded", &num_history_items_recorded },
 380 
 381 #ifdef ENABLE_VFS
 382     { "vfs_timeout", &vfs_timeout },
 383 #ifdef ENABLE_VFS_FTP
 384     { "ftpfs_directory_timeout", &ftpfs_directory_timeout },
 385     { "ftpfs_retry_seconds", &ftpfs_retry_seconds },
 386 #endif
 387 #ifdef ENABLE_VFS_SHELL
 388     { "shell_directory_timeout", &shell_directory_timeout },
 389 #endif
 390 #endif
 391 
 392     // option_tab_spacing is used in internal viewer
 393     { "editor_tab_spacing", &option_tab_spacing },
 394 #ifdef USE_INTERNAL_EDIT
 395     { "editor_word_wrap_line_length", &edit_options.word_wrap_line_length },
 396     { "editor_option_save_mode", &edit_options.save_mode },
 397 #endif
 398     {
 399         NULL,
 400         NULL,
 401     },
 402 };
 403 
 404 static const struct
 405 {
 406     const char *opt_name;
 407     char **opt_addr;
 408     const char *opt_defval;
 409 } str_options[] = {
 410 #ifdef USE_INTERNAL_EDIT
 411     { "editor_backup_extension", &edit_options.backup_ext, "~" },
 412     { "editor_filesize_threshold", &edit_options.filesize_threshold, "64M" },
 413     { "editor_stop_format_chars", &edit_options.stop_format_chars, "-+*\\,.;:&>" },
 414 #endif
 415     { "mcview_eof", &mcview_show_eof, "" },
 416     { NULL, NULL, NULL },
 417 };
 418 
 419 static const struct
 420 {
 421     const char *opt_name;
 422     gboolean *opt_addr;
 423 } panels_ini_options[] = {
 424     { "show_mini_info", &panels_options.show_mini_info },
 425     { "kilobyte_si", &panels_options.kilobyte_si },
 426     { "mix_all_files", &panels_options.mix_all_files },
 427     { "show_backups", &panels_options.show_backups },
 428     { "show_dot_files", &panels_options.show_dot_files },
 429     { "fast_reload", &panels_options.fast_reload },
 430     { "fast_reload_msg_shown", &panels_options.fast_reload_msg_shown },
 431     { "mark_moves_down", &panels_options.mark_moves_down },
 432     { "reverse_files_only", &panels_options.reverse_files_only },
 433     { "auto_save_setup_panels", &panels_options.auto_save_setup },
 434     { "navigate_with_arrows", &panels_options.navigate_with_arrows },
 435     { "panel_scroll_pages", &panels_options.scroll_pages },
 436     { "panel_scroll_center", &panels_options.scroll_center },
 437     { "mouse_move_pages", &panels_options.mouse_move_pages },
 438     { "filetype_mode", &panels_options.filetype_mode },
 439     { "permission_mode", &panels_options.permission_mode },
 440     { "torben_fj_mode", &panels_options.torben_fj_mode },
 441     {
 442         NULL,
 443         NULL,
 444     },
 445 };
 446 
 447 /* --------------------------------------------------------------------------------------------- */
 448 /*** file scope functions ************************************************************************/
 449 /* --------------------------------------------------------------------------------------------- */
 450 
 451 static const char *
 452 setup__is_cfg_group_must_panel_config (const char *grp)
     /* [previous][next][first][last][top][bottom][index][help]  */
 453 {
 454     return (strcasecmp ("Dirs", grp) == 0 || strcasecmp ("Temporal:New Right Panel", grp) == 0
 455             || strcasecmp ("Temporal:New Left Panel", grp) == 0
 456             || strcasecmp ("New Left Panel", grp) == 0 || strcasecmp ("New Right Panel", grp) == 0)
 457         ? grp
 458         : NULL;
 459 }
 460 
 461 /* --------------------------------------------------------------------------------------------- */
 462 
 463 static void
 464 setup__move_panels_config_into_separate_file (const char *profile)
     /* [previous][next][first][last][top][bottom][index][help]  */
 465 {
 466     mc_config_t *tmp_cfg;
 467     char **groups, **curr_grp;
 468 
 469     if (!exist_file (profile))
 470         return;
 471 
 472     tmp_cfg = mc_config_init (profile, FALSE);
 473     if (tmp_cfg == NULL)
 474         return;
 475 
 476     groups = mc_config_get_groups (tmp_cfg, NULL);
 477     if (*groups == NULL)
 478     {
 479         g_strfreev (groups);
 480         mc_config_deinit (tmp_cfg);
 481         return;
 482     }
 483 
 484     for (curr_grp = groups; *curr_grp != NULL; curr_grp++)
 485         if (setup__is_cfg_group_must_panel_config (*curr_grp) == NULL)
 486             mc_config_del_group (tmp_cfg, *curr_grp);
 487 
 488     mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL);
 489     mc_config_deinit (tmp_cfg);
 490 
 491     tmp_cfg = mc_config_init (profile, FALSE);
 492     if (tmp_cfg == NULL)
 493     {
 494         g_strfreev (groups);
 495         return;
 496     }
 497 
 498     for (curr_grp = groups; *curr_grp != NULL; curr_grp++)
 499     {
 500         const char *need_grp;
 501 
 502         need_grp = setup__is_cfg_group_must_panel_config (*curr_grp);
 503         if (need_grp != NULL)
 504             mc_config_del_group (tmp_cfg, need_grp);
 505     }
 506     g_strfreev (groups);
 507 
 508     mc_config_save_file (tmp_cfg, NULL);
 509     mc_config_deinit (tmp_cfg);
 510 }
 511 
 512 /* --------------------------------------------------------------------------------------------- */
 513 
 514 static void
 515 load_config (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 516 {
 517     size_t i;
 518     const char *kt;
 519 
 520     // Load boolean options
 521     for (i = 0; bool_options[i].opt_name != NULL; i++)
 522         *bool_options[i].opt_addr =
 523             mc_config_get_bool (mc_global.main_config, CONFIG_APP_SECTION, bool_options[i].opt_name,
 524                                 *bool_options[i].opt_addr);
 525 
 526     // Load integer options
 527     for (i = 0; int_options[i].opt_name != NULL; i++)
 528         *int_options[i].opt_addr =
 529             mc_config_get_int (mc_global.main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
 530                                *int_options[i].opt_addr);
 531 
 532     // Load string options
 533     for (i = 0; str_options[i].opt_name != NULL; i++)
 534         *str_options[i].opt_addr =
 535             mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION,
 536                                   str_options[i].opt_name, str_options[i].opt_defval);
 537 
 538     // Overwrite some options
 539 #ifdef USE_INTERNAL_EDIT
 540     if (edit_options.word_wrap_line_length <= 0)
 541         edit_options.word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
 542 #else
 543     // Reset forced in case of build without internal editor
 544     use_internal_edit = FALSE;
 545 #endif
 546 
 547     if (option_tab_spacing <= 0)
 548         option_tab_spacing = DEFAULT_TAB_SPACING;
 549 
 550     kt = getenv ("KEYBOARD_KEY_TIMEOUT_US");
 551     if (kt != NULL && kt[0] != '\0')
 552         old_esc_mode_timeout = atoi (kt);
 553 }
 554 
 555 /* --------------------------------------------------------------------------------------------- */
 556 
 557 static panel_view_mode_t
 558 setup__load_panel_state (const char *section)
     /* [previous][next][first][last][top][bottom][index][help]  */
 559 {
 560     char *buffer;
 561     size_t i;
 562     panel_view_mode_t mode = view_listing;
 563 
 564     // Load the display mode
 565     buffer = mc_config_get_string (mc_global.panels_config, section, "display", "listing");
 566 
 567     for (i = 0; panel_types[i].opt_name != NULL; i++)
 568         if (g_ascii_strcasecmp (panel_types[i].opt_name, buffer) == 0)
 569         {
 570             mode = panel_types[i].opt_type;
 571             break;
 572         }
 573 
 574     g_free (buffer);
 575 
 576     return mode;
 577 }
 578 
 579 /* --------------------------------------------------------------------------------------------- */
 580 
 581 static void
 582 load_layout (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 583 {
 584     size_t i;
 585 
 586     // actual options override legacy ones
 587     for (i = 0; layout_int_options[i].opt_name != NULL; i++)
 588         *layout_int_options[i].opt_addr =
 589             mc_config_get_int (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 590                                layout_int_options[i].opt_name, *layout_int_options[i].opt_addr);
 591 
 592     for (i = 0; layout_bool_options[i].opt_name != NULL; i++)
 593         *layout_bool_options[i].opt_addr =
 594             mc_config_get_bool (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 595                                 layout_bool_options[i].opt_name, *layout_bool_options[i].opt_addr);
 596 
 597     startup_left_mode = setup__load_panel_state ("New Left Panel");
 598     startup_right_mode = setup__load_panel_state ("New Right Panel");
 599 
 600     // At least one of the panels is a listing panel
 601     if (startup_left_mode != view_listing && startup_right_mode != view_listing)
 602         startup_left_mode = view_listing;
 603 
 604     boot_current_is_left =
 605         mc_config_get_bool (mc_global.panels_config, "Dirs", "current_is_left", TRUE);
 606 }
 607 
 608 /* --------------------------------------------------------------------------------------------- */
 609 
 610 static void
 611 load_keys_from_section (const char *terminal, mc_config_t *cfg)
     /* [previous][next][first][last][top][bottom][index][help]  */
 612 {
 613     char *section_name;
 614     gchar **profile_keys, **keys;
 615     char *valcopy, *value;
 616 
 617     if (terminal == NULL)
 618         return;
 619 
 620     section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
 621     keys = mc_config_get_keys (cfg, section_name, NULL);
 622 
 623     for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
 624     {
 625         // copy=other causes all keys from [terminal:other] to be loaded.
 626         if (g_ascii_strcasecmp (*profile_keys, "copy") == 0)
 627         {
 628             valcopy = mc_config_get_string (cfg, section_name, *profile_keys, "");
 629             load_keys_from_section (valcopy, cfg);
 630             g_free (valcopy);
 631             continue;
 632         }
 633 
 634         const int key_code = tty_keyname_to_keycode (*profile_keys, NULL);
 635 
 636         if (key_code != 0)
 637         {
 638             gchar **values;
 639 
 640             values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL);
 641             if (values != NULL)
 642             {
 643                 gchar **curr_values;
 644 
 645                 for (curr_values = values; *curr_values != NULL; curr_values++)
 646                 {
 647                     valcopy = convert_controls (*curr_values);
 648                     define_sequence (key_code, valcopy, MCKEY_NOACTION);
 649                     g_free (valcopy);
 650                 }
 651 
 652                 g_strfreev (values);
 653             }
 654             else
 655             {
 656                 value = mc_config_get_string (cfg, section_name, *profile_keys, "");
 657                 valcopy = convert_controls (value);
 658                 define_sequence (key_code, valcopy, MCKEY_NOACTION);
 659                 g_free (valcopy);
 660                 g_free (value);
 661             }
 662         }
 663     }
 664     g_strfreev (keys);
 665     g_free (section_name);
 666 }
 667 
 668 /* --------------------------------------------------------------------------------------------- */
 669 
 670 static void
 671 panel_save_type (const char *section, panel_view_mode_t type)
     /* [previous][next][first][last][top][bottom][index][help]  */
 672 {
 673     size_t i;
 674 
 675     for (i = 0; panel_types[i].opt_name != NULL; i++)
 676         if (panel_types[i].opt_type == type)
 677         {
 678             mc_config_set_string (mc_global.panels_config, section, "display",
 679                                   panel_types[i].opt_name);
 680             break;
 681         }
 682 }
 683 
 684 /* --------------------------------------------------------------------------------------------- */
 685 
 686 /**
 687  * Load panels options from [Panels] section.
 688  */
 689 static void
 690 panels_load_options (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 691 {
 692     if (mc_config_has_group (mc_global.main_config, CONFIG_PANELS_SECTION))
 693     {
 694         size_t i;
 695         int qmode;
 696 
 697         for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
 698             *panels_ini_options[i].opt_addr = mc_config_get_bool (
 699                 mc_global.main_config, CONFIG_PANELS_SECTION, panels_ini_options[i].opt_name,
 700                 *panels_ini_options[i].opt_addr);
 701 
 702         qmode = mc_config_get_int (mc_global.main_config, CONFIG_PANELS_SECTION,
 703                                    "quick_search_mode", (int) panels_options.qsearch_mode);
 704         if (qmode < 0)
 705             panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
 706         else if (qmode >= QSEARCH_NUM)
 707             panels_options.qsearch_mode = QSEARCH_PANEL_CASE;
 708         else
 709             panels_options.qsearch_mode = (qsearch_mode_t) qmode;
 710 
 711         panels_options.select_flags =
 712             mc_config_get_int (mc_global.main_config, CONFIG_PANELS_SECTION, "select_flags",
 713                                (int) panels_options.select_flags);
 714     }
 715 }
 716 
 717 /* --------------------------------------------------------------------------------------------- */
 718 
 719 /**
 720  * Save panels options in [Panels] section.
 721  */
 722 static void
 723 panels_save_options (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 724 {
 725     size_t i;
 726 
 727     for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
 728         mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
 729                             panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr);
 730 
 731     mc_config_set_int (mc_global.main_config, CONFIG_PANELS_SECTION, "quick_search_mode",
 732                        (int) panels_options.qsearch_mode);
 733     mc_config_set_int (mc_global.main_config, CONFIG_PANELS_SECTION, "select_flags",
 734                        (int) panels_options.select_flags);
 735 }
 736 
 737 /* --------------------------------------------------------------------------------------------- */
 738 
 739 static void
 740 save_config (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 741 {
 742     size_t i;
 743 
 744     // Save boolean options
 745     for (i = 0; bool_options[i].opt_name != NULL; i++)
 746         mc_config_set_bool (mc_global.main_config, CONFIG_APP_SECTION, bool_options[i].opt_name,
 747                             *bool_options[i].opt_addr);
 748 
 749     // Save integer options
 750     for (i = 0; int_options[i].opt_name != NULL; i++)
 751         mc_config_set_int (mc_global.main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
 752                            *int_options[i].opt_addr);
 753 
 754     // Save string options
 755     for (i = 0; str_options[i].opt_name != NULL; i++)
 756         mc_config_set_string (mc_global.main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
 757                               *str_options[i].opt_addr);
 758 }
 759 
 760 /* --------------------------------------------------------------------------------------------- */
 761 
 762 static void
 763 save_layout (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 764 {
 765     size_t i;
 766 
 767     // Save integer options
 768     for (i = 0; layout_int_options[i].opt_name != NULL; i++)
 769         mc_config_set_int (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 770                            layout_int_options[i].opt_name, *layout_int_options[i].opt_addr);
 771 
 772     // Save boolean options
 773     for (i = 0; layout_bool_options[i].opt_name != NULL; i++)
 774         mc_config_set_bool (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 775                             layout_bool_options[i].opt_name, *layout_bool_options[i].opt_addr);
 776 }
 777 
 778 /* --------------------------------------------------------------------------------------------- */
 779 
 780 /* save panels.ini */
 781 static void
 782 save_panel_types (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 783 {
 784     panel_view_mode_t type;
 785 
 786     if (mc_global.mc_run_mode != MC_RUN_FULL)
 787         return;
 788 
 789     type = get_panel_type (0);
 790     panel_save_type ("New Left Panel", type);
 791     if (type == view_listing)
 792         panel_save_setup (left_panel, left_panel->name);
 793     type = get_panel_type (1);
 794     panel_save_type ("New Right Panel", type);
 795     if (type == view_listing)
 796         panel_save_setup (right_panel, right_panel->name);
 797 
 798     {
 799         char *dirs;
 800 
 801         dirs = get_panel_dir_for (other_panel);
 802         mc_config_set_string (mc_global.panels_config, "Dirs", "other_dir", dirs);
 803         g_free (dirs);
 804     }
 805 
 806     if (current_panel != NULL)
 807         mc_config_set_bool (mc_global.panels_config, "Dirs", "current_is_left",
 808                             get_current_index () == 0);
 809 
 810     if (mc_global.panels_config->ini_path == NULL)
 811         mc_global.panels_config->ini_path = g_strdup (panels_profile_name);
 812 
 813     mc_config_del_group (mc_global.panels_config, "Temporal:New Left Panel");
 814     mc_config_del_group (mc_global.panels_config, "Temporal:New Right Panel");
 815 
 816     mc_config_save_file (mc_global.panels_config, NULL);
 817 }
 818 
 819 /* --------------------------------------------------------------------------------------------- */
 820 /*** public functions ****************************************************************************/
 821 /* --------------------------------------------------------------------------------------------- */
 822 
 823 const char *
 824 setup_init (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 825 {
 826     if (profile_name == NULL)
 827     {
 828         char *profile;
 829 
 830         profile = mc_config_get_full_path (MC_CONFIG_FILE);
 831         if (!exist_file (profile))
 832         {
 833             char *inifile;
 834 
 835             inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", (char *) NULL);
 836             if (exist_file (inifile))
 837             {
 838                 g_free (profile);
 839                 profile = inifile;
 840             }
 841             else
 842             {
 843                 g_free (inifile);
 844                 inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", (char *) NULL);
 845                 if (!exist_file (inifile))
 846                     g_free (inifile);
 847                 else
 848                 {
 849                     g_free (profile);
 850                     profile = inifile;
 851                 }
 852             }
 853         }
 854 
 855         profile_name = profile;
 856     }
 857 
 858     return profile_name;
 859 }
 860 
 861 /* --------------------------------------------------------------------------------------------- */
 862 
 863 void
 864 load_setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 865 {
 866     const char *profile;
 867 
 868     const char *cbuffer;
 869 
 870     load_codepages_list ();
 871 
 872     profile = setup_init ();
 873 
 874     /* mc.lib is common for all users, but has priority lower than
 875        ${XDG_CONFIG_HOME}/mc/ini.  FIXME: it's only used for keys and treestore now */
 876     mc_global.profile_name =
 877         g_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
 878     if (!exist_file (mc_global.profile_name))
 879     {
 880         g_free (mc_global.profile_name);
 881         mc_global.profile_name =
 882             g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
 883     }
 884 
 885     panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);
 886 
 887     mc_global.main_config = mc_config_init (profile, FALSE);
 888 
 889     if (!exist_file (panels_profile_name))
 890         setup__move_panels_config_into_separate_file (profile);
 891 
 892     mc_global.panels_config = mc_config_init (panels_profile_name, FALSE);
 893 
 894     load_config ();
 895     load_layout ();
 896     panels_load_options ();
 897     external_panelize_load ();
 898 
 899     // Load time formats
 900     user_recent_timeformat = mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION,
 901                                                    "timeformat_recent", FMTTIME);
 902     user_old_timeformat = mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION,
 903                                                 "timeformat_old", FMTYEAR);
 904 
 905 #ifdef ENABLE_VFS_FTP
 906     ftpfs_proxy_host =
 907         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate");
 908     ftpfs_init_passwd ();
 909 #endif
 910 
 911     // The default color and the terminal dependent color
 912     mc_global.tty.setup_color_string =
 913         mc_config_get_string (mc_global.main_config, "Colors", "base_color", "");
 914     mc_global.tty.term_color_string =
 915         mc_config_get_string (mc_global.main_config, "Colors", getenv ("TERM"), "");
 916     mc_global.tty.color_terminal_string =
 917         mc_config_get_string (mc_global.main_config, "Colors", "color_terminals", "");
 918 
 919     // Load the directory history
 920     //    directory_history_load ();
 921     // Remove the temporal entries
 922 
 923     if (codepages->len > 1)
 924     {
 925         char *buffer;
 926 
 927         buffer = mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION,
 928                                        "display_codepage", "");
 929         if (buffer[0] != '\0')
 930         {
 931             mc_global.display_codepage = get_codepage_index (buffer);
 932             cp_display = get_codepage_id (mc_global.display_codepage);
 933         }
 934         g_free (buffer);
 935         buffer = mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION,
 936                                        "source_codepage", "");
 937         if (buffer[0] != '\0')
 938         {
 939             default_source_codepage = get_codepage_index (buffer);
 940             mc_global.source_codepage =
 941                 default_source_codepage;  // May be source_codepage doesn't need this
 942             cp_source = get_codepage_id (mc_global.source_codepage);
 943         }
 944         g_free (buffer);
 945     }
 946 
 947     autodetect_codeset =
 948         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "autodetect_codeset", "");
 949     if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0))
 950         is_autodetect_codeset_enabled = TRUE;
 951 
 952     g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage));
 953     cbuffer = get_codepage_id (mc_global.display_codepage);
 954     if (cbuffer != NULL)
 955         mc_global.utf8_display = str_isutf8 (cbuffer);
 956 
 957 #ifdef HAVE_ASPELL
 958     spell_language =
 959         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "spell_language", "en");
 960 #endif
 961 
 962     clipboard_store_path =
 963         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_store", "");
 964     clipboard_paste_path =
 965         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_paste", "");
 966 }
 967 
 968 /* --------------------------------------------------------------------------------------------- */
 969 
 970 gboolean
 971 save_setup (gboolean save_options, gboolean save_panel_options)
     /* [previous][next][first][last][top][bottom][index][help]  */
 972 {
 973     gboolean ret = TRUE;
 974 
 975     saving_setup = 1;
 976 
 977     save_hotlist ();
 978 
 979     if (save_panel_options)
 980         save_panel_types ();
 981 
 982     if (save_options)
 983     {
 984         char *tmp_profile;
 985 
 986         save_config ();
 987         save_layout ();
 988         panels_save_options ();
 989         external_panelize_save ();
 990         // directory_history_save ();
 991 
 992 #ifdef ENABLE_VFS_FTP
 993         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftpfs_password",
 994                               ftpfs_anonymous_passwd);
 995         if (ftpfs_proxy_host)
 996             mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftp_proxy_host",
 997                                   ftpfs_proxy_host);
 998 #endif
 999 
1000         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "display_codepage",
1001                               get_codepage_id (mc_global.display_codepage));
1002         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "source_codepage",
1003                               get_codepage_id (default_source_codepage));
1004         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "autodetect_codeset",
1005                               autodetect_codeset);
1006 
1007 #ifdef HAVE_ASPELL
1008         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "spell_language",
1009                               spell_language);
1010 #endif
1011 
1012         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_store",
1013                               clipboard_store_path);
1014         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_paste",
1015                               clipboard_paste_path);
1016 
1017         tmp_profile = mc_config_get_full_path (MC_CONFIG_FILE);
1018         ret = mc_config_save_to_file (mc_global.main_config, tmp_profile, NULL);
1019         g_free (tmp_profile);
1020     }
1021 
1022     saving_setup = 0;
1023 
1024     return ret;
1025 }
1026 
1027 /* --------------------------------------------------------------------------------------------- */
1028 
1029 void
1030 done_setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1031 {
1032     size_t i;
1033 
1034     g_free (clipboard_store_path);
1035     g_free (clipboard_paste_path);
1036     g_free (mc_global.profile_name);
1037     g_free (mc_global.tty.color_terminal_string);
1038     g_free (mc_global.tty.term_color_string);
1039     g_free (mc_global.tty.setup_color_string);
1040     g_free (profile_name);
1041     g_free (panels_profile_name);
1042     mc_config_deinit (mc_global.main_config);
1043     mc_config_deinit (mc_global.panels_config);
1044 
1045     g_free (user_recent_timeformat);
1046     g_free (user_old_timeformat);
1047 
1048     for (i = 0; str_options[i].opt_name != NULL; i++)
1049         g_free (*str_options[i].opt_addr);
1050 
1051     done_hotlist ();
1052     external_panelize_free ();
1053     //    directory_history_free ();
1054 
1055     g_free (autodetect_codeset);
1056     free_codepages_list ();
1057 
1058 #ifdef HAVE_ASPELL
1059     g_free (spell_language);
1060 #endif
1061 }
1062 
1063 /* --------------------------------------------------------------------------------------------- */
1064 
1065 void
1066 setup_save_config_show_error (const char *filename, GError **mcerror)
     /* [previous][next][first][last][top][bottom][index][help]  */
1067 {
1068     if (mcerror != NULL && *mcerror != NULL)
1069     {
1070         message (D_ERROR, MSG_ERROR, _ ("Cannot save file %s:\n%s"), filename, (*mcerror)->message);
1071         g_error_free (*mcerror);
1072         *mcerror = NULL;
1073     }
1074 }
1075 
1076 /* --------------------------------------------------------------------------------------------- */
1077 
1078 void
1079 load_key_defs (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1080 {
1081     /*
1082      * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1083      * definitions override global settings.
1084      */
1085     mc_config_t *mc_global_config;
1086 
1087     mc_global_config = mc_config_init (mc_global.profile_name, FALSE);
1088     if (mc_global_config != NULL)
1089     {
1090         load_keys_from_section ("general", mc_global_config);
1091         load_keys_from_section (getenv ("TERM"), mc_global_config);
1092         mc_config_deinit (mc_global_config);
1093     }
1094 
1095     load_keys_from_section ("general", mc_global.main_config);
1096     load_keys_from_section (getenv ("TERM"), mc_global.main_config);
1097 }
1098 
1099 /* --------------------------------------------------------------------------------------------- */
1100 
1101 #ifdef ENABLE_VFS_FTP
1102 char *
1103 load_anon_passwd (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1104 {
1105     char *buffer;
1106 
1107     buffer =
1108         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftpfs_password", "");
1109 
1110     if ((buffer != NULL) && (buffer[0] != '\0'))
1111         return buffer;
1112 
1113     g_free (buffer);
1114     return NULL;
1115 }
1116 #endif
1117 
1118 /* --------------------------------------------------------------------------------------------- */
1119 
1120 void
1121 panel_load_setup (WPanel *panel, const char *section)
     /* [previous][next][first][last][top][bottom][index][help]  */
1122 {
1123     size_t i;
1124     char *buffer;
1125 
1126     panel->sort_info.reverse =
1127         mc_config_get_bool (mc_global.panels_config, section, "reverse", FALSE);
1128     panel->sort_info.case_sensitive = mc_config_get_bool (
1129         mc_global.panels_config, section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
1130     panel->sort_info.exec_first =
1131         mc_config_get_bool (mc_global.panels_config, section, "exec_first", FALSE);
1132 
1133     // Load sort order
1134     buffer = mc_config_get_string (mc_global.panels_config, section, "sort_order", "name");
1135     panel->sort_field = panel_get_field_by_id (buffer);
1136     if (panel->sort_field == NULL)
1137         panel->sort_field = panel_get_field_by_id ("name");
1138 
1139     g_free (buffer);
1140 
1141     // Load the listing format
1142     buffer = mc_config_get_string (mc_global.panels_config, section, "list_format", NULL);
1143     if (buffer == NULL)
1144     {
1145         // fallback to old option
1146         buffer = mc_config_get_string (mc_global.panels_config, section, "list_mode", "full");
1147     }
1148     panel->list_format = list_full;
1149     for (i = 0; list_formats[i].key != NULL; i++)
1150         if (g_ascii_strcasecmp (list_formats[i].key, buffer) == 0)
1151         {
1152             panel->list_format = list_formats[i].list_format;
1153             break;
1154         }
1155     g_free (buffer);
1156 
1157     panel->brief_cols = mc_config_get_int (mc_global.panels_config, section, "brief_cols", 2);
1158 
1159     // User formats
1160     g_free (panel->user_format);
1161     panel->user_format =
1162         mc_config_get_string (mc_global.panels_config, section, "user_format", NULL);
1163 
1164     for (i = 0; i < LIST_FORMATS; i++)
1165     {
1166         char buffer2[BUF_TINY];
1167 
1168         g_free (panel->user_status_format[i]);
1169         g_snprintf (buffer2, sizeof (buffer2), "user_status%lld", (long long) i);
1170         panel->user_status_format[i] =
1171             mc_config_get_string (mc_global.panels_config, section, buffer2, NULL);
1172     }
1173 
1174     panel->user_mini_status =
1175         mc_config_get_bool (mc_global.panels_config, section, "user_mini_status", FALSE);
1176 
1177     panel->filter.value =
1178         mc_config_get_string (mc_global.panels_config, section, "filter_value", NULL);
1179     panel->filter.flags = mc_config_get_int (mc_global.panels_config, section, "filter_flags",
1180                                              (int) FILE_FILTER_DEFAULT_FLAGS);
1181 }
1182 
1183 /* --------------------------------------------------------------------------------------------- */
1184 
1185 void
1186 panel_save_setup (WPanel *panel, const char *section)
     /* [previous][next][first][last][top][bottom][index][help]  */
1187 {
1188     char buffer[BUF_TINY];
1189     size_t i;
1190 
1191     mc_config_set_bool (mc_global.panels_config, section, "reverse", panel->sort_info.reverse);
1192     mc_config_set_bool (mc_global.panels_config, section, "case_sensitive",
1193                         panel->sort_info.case_sensitive);
1194     mc_config_set_bool (mc_global.panels_config, section, "exec_first",
1195                         panel->sort_info.exec_first);
1196 
1197     mc_config_set_string (mc_global.panels_config, section, "sort_order", panel->sort_field->id);
1198 
1199     for (i = 0; list_formats[i].key != NULL; i++)
1200         if (list_formats[i].list_format == (int) panel->list_format)
1201         {
1202             mc_config_set_string (mc_global.panels_config, section, "list_format",
1203                                   list_formats[i].key);
1204             break;
1205         }
1206 
1207     mc_config_set_int (mc_global.panels_config, section, "brief_cols", panel->brief_cols);
1208 
1209     mc_config_set_string (mc_global.panels_config, section, "user_format", panel->user_format);
1210 
1211     for (i = 0; i < LIST_FORMATS; i++)
1212     {
1213         g_snprintf (buffer, sizeof (buffer), "user_status%lld", (long long) i);
1214         mc_config_set_string (mc_global.panels_config, section, buffer,
1215                               panel->user_status_format[i]);
1216     }
1217 
1218     mc_config_set_bool (mc_global.panels_config, section, "user_mini_status",
1219                         panel->user_mini_status);
1220 
1221     // do not save the default filter
1222     if (panel->filter.handler != NULL)
1223         mc_config_set_string (mc_global.panels_config, section, "filter_value",
1224                               panel->filter.value);
1225     else
1226         mc_config_del_key (mc_global.panels_config, section, "filter_value");
1227     mc_config_set_int (mc_global.panels_config, section, "filter_flags", (int) panel->filter.flags);
1228 }
1229 
1230 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */