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

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