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

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