4 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5 2006, 2007, 2009, 2010, 2011
6 The Free Software Foundation, Inc.
8 This file is part of the Midnight Commander.
10 The Midnight Commander is free software: you can redistribute it
11 and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation, either version 3 of the License,
13 or (at your option) any later version.
15 The Midnight Commander is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * \brief Source: setup loading/saving
33 #include <sys/types.h>
36 #include "lib/global.h"
38 #include "lib/tty/tty.h"
39 #include "lib/tty/key.h"
40 #include "lib/mcconfig.h"
41 #include "lib/fileloc.h"
42 #include "lib/timefmt.h"
44 #include "lib/widget.h"
46 #include "lib/vfs/vfs.h"
49 #include "src/vfs/ftpfs/ftpfs.h"
51 #ifdef ENABLE_VFS_FISH
52 #include "src/vfs/fish/fish.h"
56 #include "lib/charsets.h"
59 #include "filemanager/dir.h"
60 #include "filemanager/midnight.h"
61 #include "filemanager/tree.h" /* xtree_mode */
62 #include "filemanager/hotlist.h" /* load/save/done hotlist */
63 #include "filemanager/panelize.h" /* load/save/done panelize */
64 #include "filemanager/layout.h"
65 #include "filemanager/cmd.h"
68 #include "execute.h" /* pause_after_run */
69 #include "clipboard.h"
70 #include "keybind-defaults.h" /* keybind_lookup_action */
73 #include "selcodepage.h"
76 #ifdef USE_INTERNAL_EDIT
77 #include "src/editor/edit.h"
80 #include "src/viewer/mcviewer.h" /* For the externs */
84 /*** global variables ****************************************************************************/
86 char *profile_name
; /* ${XDG_CONFIG_HOME}/mc/ini */
87 char *global_profile_name
; /* mc.lib */
89 /* Only used at program boot */
90 gboolean boot_current_is_left
= TRUE
;
92 /* If on, default for "No" in delete operations */
95 /* Controls screen clearing before an exec */
96 int clear_before_exec
= 1;
98 /* Asks for confirmation before deleting a file */
99 int confirm_delete
= 1;
100 /* Asks for confirmation before deleting a hotlist entry */
101 int confirm_directory_hotlist_delete
= 1;
102 /* Asks for confirmation before overwriting a file */
103 int confirm_overwrite
= 1;
104 /* Asks for confirmation before executing a program by pressing enter */
105 int confirm_execute
= 0;
106 /* Asks for confirmation before leaving the program */
107 int confirm_exit
= 1;
109 /* If true, at startup the user-menu is invoked */
111 /* This flag indicates if the pull down menus by default drop down */
114 /* Asks for confirmation when using F3 to view a directory and there
116 int confirm_view_dir
= 0;
118 panel_view_mode_t startup_left_mode
;
119 panel_view_mode_t startup_right_mode
;
121 int setup_copymove_persistent_attr
= 1;
124 int option_tab_spacing
= DEFAULT_TAB_SPACING
;
126 /* Ugly hack to allow panel_save_setup to work as a place holder for */
127 /* default panel values */
130 panels_options_t panels_options
= {
131 .show_mini_info
= TRUE
,
132 .kilobyte_si
= FALSE
,
133 .mix_all_files
= FALSE
,
134 .show_backups
= TRUE
,
135 .show_dot_files
= TRUE
,
136 .fast_reload
= FALSE
,
137 .fast_reload_msg_shown
= FALSE
,
138 .mark_moves_down
= TRUE
,
139 .reverse_files_only
= TRUE
,
140 .auto_save_setup
= FALSE
,
141 .navigate_with_arrows
= FALSE
,
142 .scroll_pages
= TRUE
,
143 .mouse_move_pages
= TRUE
,
144 .filetype_mode
= TRUE
,
145 .permission_mode
= FALSE
,
146 .qsearch_mode
= QSEARCH_PANEL_CASE
,
147 .torben_fj_mode
= FALSE
150 int easy_patterns
= 1;
152 /* It true saves the setup when quitting */
153 int auto_save_setup
= 1;
155 /* If true, then the +, - and \ keys have their special meaning only if the
156 * command line is emtpy, otherwise they behave like regular letters
158 int only_leading_plus_minus
= 1;
160 /* Automatically fills name with current selected item name on mkdir */
161 int auto_fill_mkdir_name
= 1;
163 /* If set and you don't have subshell support,then C-o will give you a shell */
164 int output_starts_shell
= 0;
166 /* If set, we execute the file command to check the file type */
167 int use_file_to_check_type
= 1;
172 * Whether the Midnight Commander tries to provide more
173 * information about copy/move sizes and bytes transfered
174 * at the expense of some speed
176 int file_op_compute_totals
= 1;
178 /* If true use the internal viewer */
179 int use_internal_view
= 1;
180 /* If set, use the builtin editor */
181 int use_internal_edit
= 1;
184 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
185 int default_source_codepage
= -1;
186 char *autodetect_codeset
= NULL
;
187 gboolean is_autodetect_codeset_enabled
= FALSE
;
188 #endif /* !HAVE_CHARSET */
191 char *spell_language
= NULL
;
194 /* If set, then print to the given file the last directory we were at */
195 char *last_wd_string
= NULL
;
197 /* Set when main loop should be terminated */
200 /* The user's shell */
204 const char *mc_prompt
= NULL
;
206 /* Set to TRUE to suppress printing the last directory */
207 int print_last_revert
= FALSE
;
209 /* index to record_macro_buf[], -1 if not recording a macro */
210 int macro_index
= -1;
213 struct macro_action_t record_macro_buf
[MAX_MACRO_LENGTH
];
217 /*** file scope macro definitions ****************************************************************/
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")
223 /*** file scope type declarations ****************************************************************/
225 /*** file scope variables ************************************************************************/
227 static char *panels_profile_name
= NULL
; /* ${XDG_CACHE_HOME}/mc/panels.ini */
235 { "full", list_full
},
236 { "brief", list_brief
},
237 { "long", list_long
},
238 { "user", list_user
},
244 const char *opt_name
;
245 panel_view_mode_t opt_type
;
247 { "listing", view_listing
},
248 { "quickview", view_quick
},
249 { "info", view_info
},
250 { "tree", view_tree
},
251 { NULL
, view_listing
}
256 const char *opt_name
;
259 { "message_visible", &mc_global
.message_visible
},
260 { "keybar_visible", &mc_global
.keybar_visible
},
261 { "xterm_title", &xterm_title
},
262 { "output_lines", &output_lines
},
263 { "command_prompt", &command_prompt
},
264 { "menubar_visible", &menubar_visible
},
265 { "free_space", &free_space
},
266 { "horizontal_split", &panels_layout
.horizontal_split
},
267 { "vertical_equal", &panels_layout
.vertical_equal
},
268 { "left_panel_size", &panels_layout
.left_panel_size
},
269 { "horizontal_equal", &panels_layout
.horizontal_equal
},
270 { "top_panel_size", &panels_layout
.top_panel_size
},
276 const char *opt_name
;
279 { "verbose", &verbose
},
280 { "pause_after_run", &pause_after_run
},
281 { "shell_patterns", &easy_patterns
},
282 { "auto_save_setup", &auto_save_setup
},
283 { "preallocate_space", &mc_global
.vfs
.preallocate_space
},
284 { "auto_menu", &auto_menu
},
285 { "use_internal_view", &use_internal_view
},
286 { "use_internal_edit", &use_internal_edit
},
287 { "clear_before_exec", &clear_before_exec
},
288 { "confirm_delete", &confirm_delete
},
289 { "confirm_overwrite", &confirm_overwrite
},
290 { "confirm_execute", &confirm_execute
},
291 { "confirm_history_cleanup", &mc_global
.widget
.confirm_history_cleanup
},
292 { "confirm_exit", &confirm_exit
},
293 { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete
},
294 { "safe_delete", &safe_delete
},
295 { "mouse_repeat_rate", &mou_auto_repeat
},
296 { "double_click_speed", &double_click_speed
},
298 { "eight_bit_clean", &mc_global
.eight_bit_clean
},
299 { "full_eight_bits", &mc_global
.full_eight_bits
},
300 #endif /* !HAVE_CHARSET */
301 { "use_8th_bit_as_meta", &use_8th_bit_as_meta
},
302 { "confirm_view_dir", &confirm_view_dir
},
303 { "mouse_move_pages_viewer", &mcview_mouse_move_pages
},
304 { "mouse_close_dialog", &mouse_close_dialog
},
305 { "fast_refresh", &fast_refresh
},
306 { "drop_menus", &drop_menus
},
307 { "wrap_mode", &mcview_global_wrap_mode
},
308 { "old_esc_mode", &old_esc_mode
},
309 { "old_esc_mode_timeout", &old_esc_mode_timeout
},
310 { "cd_symlinks", &mc_global
.vfs
.cd_symlinks
},
311 { "show_all_if_ambiguous", &mc_global
.widget
.show_all_if_ambiguous
},
312 { "max_dirt_limit", &mcview_max_dirt_limit
},
313 { "use_file_to_guess_type", &use_file_to_check_type
},
314 { "alternate_plus_minus", &mc_global
.tty
.alternate_plus_minus
},
315 { "only_leading_plus_minus", &only_leading_plus_minus
},
316 { "show_output_starts_shell", &output_starts_shell
},
317 { "xtree_mode", &xtree_mode
},
318 { "num_history_items_recorded", &num_history_items_recorded
},
319 { "file_op_compute_totals", &file_op_compute_totals
},
320 { "classic_progressbar", &classic_progressbar
},
322 { "vfs_timeout", &vfs_timeout
},
323 #ifdef ENABLE_VFS_FTP
324 { "ftpfs_directory_timeout", &ftpfs_directory_timeout
},
325 { "use_netrc", &ftpfs_use_netrc
},
326 { "ftpfs_retry_seconds", &ftpfs_retry_seconds
},
327 { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy
},
328 { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections
},
329 { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy
},
330 { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options
},
331 { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls
},
332 #endif /* ENABLE_VFS_FTP */
333 #ifdef ENABLE_VFS_FISH
334 { "fish_directory_timeout", &fish_directory_timeout
},
335 #endif /* ENABLE_VFS_FISH */
336 #endif /* ENABLE_VFS */
337 /* option_tab_spacing is used in internal viewer */
338 { "editor_tab_spacing", &option_tab_spacing
},
339 #ifdef USE_INTERNAL_EDIT
340 { "editor_word_wrap_line_length", &option_word_wrap_line_length
},
341 { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces
},
342 { "editor_return_does_auto_indent", &option_return_does_auto_indent
},
343 { "editor_backspace_through_tabs", &option_backspace_through_tabs
},
344 { "editor_fake_half_tabs", &option_fake_half_tabs
},
345 { "editor_option_save_mode", &option_save_mode
},
346 { "editor_option_save_position", &option_save_position
},
347 { "editor_option_auto_para_formatting", &option_auto_para_formatting
},
348 { "editor_option_typewriter_wrap", &option_typewriter_wrap
},
349 { "editor_edit_confirm_save", &edit_confirm_save
},
350 { "editor_syntax_highlighting", &option_syntax_highlighting
},
351 { "editor_persistent_selections", &option_persistent_selections
},
352 { "editor_cursor_beyond_eol", &option_cursor_beyond_eol
},
353 { "editor_cursor_after_inserted_block", &option_cursor_after_inserted_block
},
354 { "editor_visible_tabs", &visible_tabs
},
355 { "editor_visible_spaces", &visible_tws
},
356 { "editor_line_state", &option_line_state
},
357 { "editor_simple_statusbar", &simple_statusbar
},
358 { "editor_check_new_line", &option_check_nl_at_eof
},
359 { "editor_show_right_margin", &show_right_margin
},
360 { "editor_group_undo", &option_group_undo
},
361 #endif /* USE_INTERNAL_EDIT */
362 { "nice_rotating_dash", &nice_rotating_dash
},
363 { "mcview_remember_file_position", &mcview_remember_file_position
},
364 { "auto_fill_mkdir_name", &auto_fill_mkdir_name
},
365 { "copymove_persistent_attr", &setup_copymove_persistent_attr
},
366 { "select_flags", &select_flags
},
372 const char *opt_name
;
374 const char *opt_defval
;
376 #ifdef USE_INTERNAL_EDIT
377 { "editor_backup_extension", &option_backup_ext
, "~" },
379 { "mcview_eof", &mcview_show_eof
, "" },
385 const char *opt_name
;
387 } panels_ini_options
[] = {
388 { "show_mini_info", &panels_options
.show_mini_info
},
389 { "kilobyte_si", &panels_options
.kilobyte_si
},
390 { "mix_all_files", &panels_options
.mix_all_files
},
391 { "show_backups", &panels_options
.show_backups
},
392 { "show_dot_files", &panels_options
.show_dot_files
},
393 { "fast_reload", &panels_options
.fast_reload
},
394 { "fast_reload_msg_shown", &panels_options
.fast_reload_msg_shown
},
395 { "mark_moves_down", &panels_options
.mark_moves_down
},
396 { "reverse_files_only", &panels_options
.reverse_files_only
},
397 { "auto_save_setup_panels", &panels_options
.auto_save_setup
},
398 { "navigate_with_arrows", &panels_options
.navigate_with_arrows
},
399 { "panel_scroll_pages", &panels_options
.scroll_pages
},
400 { "mouse_move_pages", &panels_options
.mouse_move_pages
},
401 { "filetype_mode", &panels_options
.filetype_mode
},
402 { "permission_mode", &panels_options
.permission_mode
},
403 { "torben_fj_mode", &panels_options
.torben_fj_mode
},
408 /*** file scope functions ************************************************************************/
409 /* --------------------------------------------------------------------------------------------- */
412 * Get name of config file.
414 * @param subdir If not NULL, config is also searched in specified subdir.
415 * @param config_file_name If relative, file if searched in standard paths.
417 * @return newly allocated string with config name or NULL if file is not found.
421 load_setup_get_full_config_name (const char *subdir
, const char *config_file_name
)
424 TODO: IMHO, in future, this function shall be placed in mcconfig module.
426 char *lc_basename
, *ret
;
429 if (config_file_name
== NULL
)
432 /* check for .keymap suffix */
433 if (g_str_has_suffix (config_file_name
, ".keymap"))
434 file_name
= g_strdup (config_file_name
);
436 file_name
= g_strconcat (config_file_name
, ".keymap", (char *) NULL
);
438 canonicalize_pathname (file_name
);
440 if (g_path_is_absolute (file_name
))
443 lc_basename
= g_path_get_basename (file_name
);
446 if (lc_basename
== NULL
)
450 ret
= g_build_filename (mc_config_get_path (), subdir
, lc_basename
, NULL
);
452 ret
= g_build_filename (mc_config_get_path (), lc_basename
, NULL
);
454 if (exist_file (ret
))
456 g_free (lc_basename
);
457 canonicalize_pathname (ret
);
463 ret
= g_build_filename (mc_global
.sysconfig_dir
, subdir
, lc_basename
, NULL
);
465 ret
= g_build_filename (mc_global
.sysconfig_dir
, lc_basename
, NULL
);
467 if (exist_file (ret
))
469 g_free (lc_basename
);
470 canonicalize_pathname (ret
);
476 ret
= g_build_filename (mc_global
.share_data_dir
, subdir
, lc_basename
, NULL
);
478 ret
= g_build_filename (mc_global
.share_data_dir
, lc_basename
, NULL
);
480 g_free (lc_basename
);
482 if (exist_file (ret
))
484 canonicalize_pathname (ret
);
492 /* --------------------------------------------------------------------------------------------- */
495 setup__is_cfg_group_must_panel_config (const char *grp
)
497 return (!strcasecmp ("Dirs", grp
) ||
498 !strcasecmp ("Temporal:New Right Panel", grp
) ||
499 !strcasecmp ("Temporal:New Left Panel", grp
) ||
500 !strcasecmp ("New Left Panel", grp
) || !strcasecmp ("New Right Panel", grp
))
504 /* --------------------------------------------------------------------------------------------- */
507 setup__move_panels_config_into_separate_file (const char *profile
)
509 mc_config_t
*tmp_cfg
;
510 char **groups
, **curr_grp
;
511 const char *need_grp
;
513 if (!exist_file (profile
))
516 tmp_cfg
= mc_config_init (profile
, FALSE
);
520 curr_grp
= groups
= mc_config_get_groups (tmp_cfg
, NULL
);
523 mc_config_deinit (tmp_cfg
);
529 if (setup__is_cfg_group_must_panel_config (*curr_grp
) == NULL
)
530 mc_config_del_group (tmp_cfg
, *curr_grp
);
534 mc_config_save_to_file (tmp_cfg
, panels_profile_name
, NULL
);
535 mc_config_deinit (tmp_cfg
);
537 tmp_cfg
= mc_config_init (profile
, FALSE
);
548 need_grp
= setup__is_cfg_group_must_panel_config (*curr_grp
);
549 if (need_grp
!= NULL
)
551 mc_config_del_group (tmp_cfg
, need_grp
);
557 mc_config_save_file (tmp_cfg
, NULL
);
558 mc_config_deinit (tmp_cfg
);
561 /* --------------------------------------------------------------------------------------------- */
563 Create new mc_config object from specified ini-file or
564 append data to existing mc_config object from ini-file
568 load_setup_init_config_from_file (mc_config_t
** config
, const char *fname
, gboolean read_only
)
571 TODO: IMHO, in future, this function shall be placed in mcconfig module.
573 if (exist_file (fname
))
576 mc_config_read_file (*config
, fname
, read_only
, TRUE
);
578 *config
= mc_config_init (fname
, read_only
);
582 /* --------------------------------------------------------------------------------------------- */
589 int first_panel_size
;
592 panels_layout
.horizontal_split
= mc_config_get_int (mc_main_config
, CONFIG_APP_SECTION
,
593 "horizontal_split", 0);
594 equal_split
= mc_config_get_int (mc_main_config
, "Layout", "equal_split", 1);
595 first_panel_size
= mc_config_get_int (mc_main_config
, "Layout", "first_panel_size", 1);
596 if (panels_layout
.horizontal_split
)
598 panels_layout
.horizontal_equal
= equal_split
;
599 panels_layout
.left_panel_size
= first_panel_size
;
603 panels_layout
.vertical_equal
= equal_split
;
604 panels_layout
.top_panel_size
= first_panel_size
;
607 /* actual options override legacy ones */
608 for (i
= 0; layout
[i
].opt_name
!= NULL
; i
++)
609 *layout
[i
].opt_addr
= mc_config_get_int (mc_main_config
, CONFIG_LAYOUT_SECTION
,
610 layout
[i
].opt_name
, *layout
[i
].opt_addr
);
612 /* remove legacy options */
613 mc_config_del_key (mc_main_config
, CONFIG_APP_SECTION
, "horizontal_split");
614 mc_config_del_key (mc_main_config
, "Layout", "equal_split");
615 mc_config_del_key (mc_main_config
, "Layout", "first_panel_size");
618 /* --------------------------------------------------------------------------------------------- */
621 load_keys_from_section (const char *terminal
, mc_config_t
* cfg
)
624 gchar
**profile_keys
, **keys
;
625 gchar
**values
, **curr_values
;
626 char *valcopy
, *value
;
628 gsize len
, values_len
;
630 if (terminal
== NULL
)
633 section_name
= g_strconcat ("terminal:", terminal
, (char *) NULL
);
634 profile_keys
= keys
= mc_config_get_keys (cfg
, section_name
, &len
);
636 while (*profile_keys
!= NULL
)
638 /* copy=other causes all keys from [terminal:other] to be loaded. */
639 if (g_ascii_strcasecmp (*profile_keys
, "copy") == 0)
641 valcopy
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
642 load_keys_from_section (valcopy
, cfg
);
648 curr_values
= values
=
649 mc_config_get_string_list (cfg
, section_name
, *profile_keys
, &values_len
);
651 key_code
= lookup_key (*profile_keys
, NULL
);
655 if (curr_values
!= NULL
)
657 while (*curr_values
!= NULL
)
659 valcopy
= convert_controls (*curr_values
);
660 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
667 value
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
668 valcopy
= convert_controls (value
);
669 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
679 g_free (section_name
);
682 /* --------------------------------------------------------------------------------------------- */
685 load_keymap_from_section (const char *section_name
, GArray
* keymap
, mc_config_t
* cfg
)
687 gchar
**profile_keys
, **keys
;
690 if (section_name
== NULL
)
693 profile_keys
= keys
= mc_config_get_keys (cfg
, section_name
, &len
);
695 while (*profile_keys
!= NULL
)
697 gchar
**values
, **curr_values
;
699 curr_values
= values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, &len
);
701 if (curr_values
!= NULL
)
705 action
= keybind_lookup_action (*profile_keys
);
707 while (*curr_values
!= NULL
)
709 keybind_cmd_bind (keymap
, *curr_values
, action
);
722 /* --------------------------------------------------------------------------------------------- */
725 load_setup_get_keymap_profile_config (gboolean load_from_file
)
728 TODO: IMHO, in future, this function shall be placed in mcconfig module.
730 mc_config_t
*keymap_config
;
731 char *share_keymap
, *sysconfig_keymap
;
732 char *fname
, *fname2
;
734 /* 0) Create default keymap */
735 keymap_config
= create_default_keymap ();
737 return keymap_config
;
739 /* load and merge global keymaps */
741 /* 1) /usr/share/mc (mc_global.share_data_dir) */
742 share_keymap
= g_build_filename (mc_global
.share_data_dir
, GLOBAL_KEYMAP_FILE
, NULL
);
743 load_setup_init_config_from_file (&keymap_config
, share_keymap
, TRUE
);
745 /* 2) /etc/mc (mc_global.sysconfig_dir) */
746 sysconfig_keymap
= g_build_filename (mc_global
.sysconfig_dir
, GLOBAL_KEYMAP_FILE
, NULL
);
747 load_setup_init_config_from_file (&keymap_config
, sysconfig_keymap
, TRUE
);
749 /* then load and merge one of user-defined keymap */
751 /* 3) --keymap=<keymap> */
752 fname
= load_setup_get_full_config_name (NULL
, mc_args__keymap_file
);
753 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
755 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
760 /* 4) getenv("MC_KEYMAP") */
761 fname
= load_setup_get_full_config_name (NULL
, g_getenv ("MC_KEYMAP"));
762 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
764 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
769 /* 5) main config; [Midnight Commander] -> keymap */
770 fname2
= mc_config_get_string (mc_main_config
, CONFIG_APP_SECTION
, "keymap", NULL
);
771 if (fname2
!= NULL
&& *fname2
!= '\0')
772 fname
= load_setup_get_full_config_name (NULL
, fname2
);
774 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
776 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
781 /* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
782 fname
= mc_config_get_full_path (GLOBAL_KEYMAP_FILE
);
783 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
787 g_free (sysconfig_keymap
);
788 g_free (share_keymap
);
790 return keymap_config
;
793 /* --------------------------------------------------------------------------------------------- */
795 static panel_view_mode_t
796 setup__load_panel_state (const char *section
)
800 panel_view_mode_t mode
= view_listing
;
802 /* Load the display mode */
803 buffer
= mc_config_get_string (mc_panels_config
, section
, "display", "listing");
805 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
806 if (g_ascii_strcasecmp (panel_types
[i
].opt_name
, buffer
) == 0)
808 mode
= panel_types
[i
].opt_type
;
817 /* --------------------------------------------------------------------------------------------- */
820 panel_save_type (const char *section
, panel_view_mode_t type
)
824 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
825 if (panel_types
[i
].opt_type
== type
)
827 mc_config_set_string (mc_panels_config
, section
, "display", panel_types
[i
].opt_name
);
832 /* --------------------------------------------------------------------------------------------- */
834 /* save panels.ini */
836 save_panel_types (void)
838 panel_view_mode_t type
;
840 if (mc_global
.mc_run_mode
!= MC_RUN_FULL
)
843 type
= get_display_type (0);
844 panel_save_type ("New Left Panel", type
);
845 if (type
== view_listing
)
846 panel_save_setup (left_panel
, left_panel
->panel_name
);
847 type
= get_display_type (1);
848 panel_save_type ("New Right Panel", type
);
849 if (type
== view_listing
)
850 panel_save_setup (right_panel
, right_panel
->panel_name
);
855 dirs
= get_panel_dir_for (other_panel
);
856 mc_config_set_string (mc_panels_config
, "Dirs", "other_dir", dirs
);
860 if (current_panel
!= NULL
)
861 mc_config_set_bool (mc_panels_config
, "Dirs", "current_is_left", get_current_index () == 0);
863 if (mc_panels_config
->ini_path
== NULL
)
864 mc_panels_config
->ini_path
= g_strdup (panels_profile_name
);
866 mc_config_del_group (mc_panels_config
, "Temporal:New Left Panel");
867 mc_config_del_group (mc_panels_config
, "Temporal:New Right Panel");
869 mc_config_save_file (mc_panels_config
, NULL
);
872 /* --------------------------------------------------------------------------------------------- */
873 /*** public functions ****************************************************************************/
874 /* --------------------------------------------------------------------------------------------- */
882 if (profile_name
!= NULL
)
885 profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
886 if (!exist_file (profile
))
888 inifile
= mc_build_filename (mc_global
.sysconfig_dir
, "mc.ini", NULL
);
889 if (exist_file (inifile
))
897 inifile
= mc_build_filename (mc_global
.share_data_dir
, "mc.ini", NULL
);
898 if (exist_file (inifile
))
908 profile_name
= profile
;
913 /* --------------------------------------------------------------------------------------------- */
924 load_codepages_list ();
925 #endif /* HAVE_CHARSET */
927 profile
= setup_init ();
929 /* mc.lib is common for all users, but has priority lower than
930 ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */
931 global_profile_name
=
932 g_build_filename (mc_global
.sysconfig_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
933 if (!exist_file (global_profile_name
))
935 g_free (global_profile_name
);
936 global_profile_name
=
937 g_build_filename (mc_global
.share_data_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
940 panels_profile_name
= mc_config_get_full_path (MC_PANELS_FILE
);
942 mc_main_config
= mc_config_init (profile
, FALSE
);
944 if (!exist_file (panels_profile_name
))
945 setup__move_panels_config_into_separate_file (profile
);
947 mc_panels_config
= mc_config_init (panels_profile_name
, FALSE
);
949 /* Load integer boolean options */
950 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
951 *int_options
[i
].opt_addr
=
952 mc_config_get_int (mc_main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
953 *int_options
[i
].opt_addr
);
955 if (option_tab_spacing
<= 0)
956 option_tab_spacing
= DEFAULT_TAB_SPACING
;
958 #ifdef USE_INTERNAL_EDIT
959 if (option_word_wrap_line_length
<= 0)
960 option_word_wrap_line_length
= DEFAULT_WRAP_LINE_LENGTH
;
961 #endif /* USE_INTERNAL_EDIT */
963 /* overwrite old_esc_mode_timeout */
964 kt
= getenv ("KEYBOARD_KEY_TIMEOUT_US");
965 if ((kt
!= NULL
) && (kt
[0] != '\0'))
966 old_esc_mode_timeout
= atoi (kt
);
968 /* Load string options */
969 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
970 *str_options
[i
].opt_addr
=
971 mc_config_get_string (mc_main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
,
972 str_options
[i
].opt_defval
);
975 panels_load_options ();
978 startup_left_mode
= setup__load_panel_state ("New Left Panel");
979 startup_right_mode
= setup__load_panel_state ("New Right Panel");
981 /* At least one of the panels is a listing panel */
982 if (startup_left_mode
!= view_listing
&& startup_right_mode
!= view_listing
)
983 startup_left_mode
= view_listing
;
985 if (mc_run_param1
== NULL
)
988 buffer
= mc_config_get_string (mc_panels_config
, "Dirs", "other_dir", ".");
989 vpath
= vfs_path_from_str (buffer
);
990 if (vfs_file_is_local (vpath
))
991 mc_run_param1
= buffer
;
994 vfs_path_free (vpath
);
997 boot_current_is_left
= mc_config_get_bool (mc_panels_config
, "Dirs", "current_is_left", TRUE
);
999 /* Load time formats */
1000 user_recent_timeformat
=
1001 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "timeformat_recent", FMTTIME
);
1002 user_old_timeformat
=
1003 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "timeformat_old", FMTYEAR
);
1005 #ifdef ENABLE_VFS_FTP
1007 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host", "gate");
1008 ftpfs_ignore_chattr_errors
=
1009 mc_config_get_bool (mc_main_config
, CONFIG_APP_SECTION
, "ignore_ftp_chattr_errors", TRUE
);
1010 ftpfs_init_passwd ();
1011 #endif /* ENABLE_VFS_FTP */
1013 /* The default color and the terminal dependent color */
1014 mc_global
.tty
.setup_color_string
=
1015 mc_config_get_string (mc_main_config
, "Colors", "base_color", "");
1016 mc_global
.tty
.term_color_string
=
1017 mc_config_get_string (mc_main_config
, "Colors", getenv ("TERM"), "");
1018 mc_global
.tty
.color_terminal_string
=
1019 mc_config_get_string (mc_main_config
, "Colors", "color_terminals", "");
1021 /* Load the directory history */
1022 /* directory_history_load (); */
1023 /* Remove the temporal entries */
1026 if (codepages
->len
> 1)
1028 buffer
= mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "display_codepage", "");
1029 if (buffer
[0] != '\0')
1031 mc_global
.display_codepage
= get_codepage_index (buffer
);
1032 cp_display
= get_codepage_id (mc_global
.display_codepage
);
1035 buffer
= mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "source_codepage", "");
1036 if (buffer
[0] != '\0')
1038 default_source_codepage
= get_codepage_index (buffer
);
1039 mc_global
.source_codepage
= default_source_codepage
; /* May be source_codepage doesn't need this */
1040 cp_source
= get_codepage_id (mc_global
.source_codepage
);
1045 autodetect_codeset
=
1046 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset", "");
1047 if ((autodetect_codeset
[0] != '\0') && (strcmp (autodetect_codeset
, "off") != 0))
1048 is_autodetect_codeset_enabled
= TRUE
;
1050 g_free (init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
));
1051 buffer
= (char *) get_codepage_id (mc_global
.display_codepage
);
1053 mc_global
.utf8_display
= str_isutf8 (buffer
);
1054 #endif /* HAVE_CHARSET */
1058 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "spell_language", "en");
1059 #endif /* HAVE_ASPELL */
1061 clipboard_store_path
=
1062 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_store", "");
1063 clipboard_paste_path
=
1064 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_paste", "");
1067 /* --------------------------------------------------------------------------------------------- */
1070 save_setup (gboolean save_options
, gboolean save_panel_options
)
1072 gboolean ret
= TRUE
;
1078 if (save_panel_options
)
1079 save_panel_types ();
1087 panels_save_options ();
1089 /* directory_history_save (); */
1091 #ifdef ENABLE_VFS_FTP
1092 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftpfs_password",
1093 ftpfs_anonymous_passwd
);
1094 if (ftpfs_proxy_host
)
1095 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host",
1097 #endif /* ENABLE_VFS_FTP */
1100 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "display_codepage",
1101 get_codepage_id (mc_global
.display_codepage
));
1102 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "source_codepage",
1103 get_codepage_id (default_source_codepage
));
1104 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset",
1105 autodetect_codeset
);
1106 #endif /* HAVE_CHARSET */
1109 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "spell_language",
1111 #endif /* HAVE_ASPELL */
1113 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_store",
1114 clipboard_store_path
);
1115 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_paste",
1116 clipboard_paste_path
);
1118 tmp_profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
1119 ret
= mc_config_save_to_file (mc_main_config
, tmp_profile
, NULL
);
1120 g_free (tmp_profile
);
1128 /* --------------------------------------------------------------------------------------------- */
1135 g_free (clipboard_store_path
);
1136 g_free (clipboard_paste_path
);
1137 g_free (profile_name
);
1138 g_free (global_profile_name
);
1139 g_free (mc_global
.tty
.color_terminal_string
);
1140 g_free (mc_global
.tty
.term_color_string
);
1141 g_free (mc_global
.tty
.setup_color_string
);
1142 g_free (panels_profile_name
);
1143 mc_config_deinit (mc_main_config
);
1144 mc_config_deinit (mc_panels_config
);
1146 g_free (user_recent_timeformat
);
1147 g_free (user_old_timeformat
);
1149 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1150 g_free (*str_options
[i
].opt_addr
);
1154 /* directory_history_free (); */
1157 g_free (autodetect_codeset
);
1158 free_codepages_list ();
1162 g_free (spell_language
);
1163 #endif /* HAVE_ASPELL */
1166 /* --------------------------------------------------------------------------------------------- */
1173 /* Save integer options */
1174 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
1175 mc_config_set_int (mc_main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
1176 *int_options
[i
].opt_addr
);
1178 /* Save string options */
1179 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1180 mc_config_set_string (mc_main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
,
1181 *str_options
[i
].opt_addr
);
1184 /* --------------------------------------------------------------------------------------------- */
1187 setup_save_config_show_error (const char *filename
, GError
** error
)
1189 if (error
!= NULL
&& *error
!= NULL
)
1191 message (D_ERROR
, MSG_ERROR
, _("Cannot save file %s:\n%s"), filename
, (*error
)->message
);
1192 g_error_free (*error
);
1197 /* --------------------------------------------------------------------------------------------- */
1204 /* Save integer options */
1205 for (i
= 0; layout
[i
].opt_name
!= NULL
; i
++)
1206 mc_config_set_int (mc_main_config
, CONFIG_LAYOUT_SECTION
, layout
[i
].opt_name
,
1207 *layout
[i
].opt_addr
);
1210 /* --------------------------------------------------------------------------------------------- */
1213 load_key_defs (void)
1216 * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1217 * definitions override global settings.
1219 mc_config_t
*mc_global_config
;
1221 mc_global_config
= mc_config_init (global_profile_name
, FALSE
);
1222 if (mc_global_config
!= NULL
)
1224 load_keys_from_section ("general", mc_global_config
);
1225 load_keys_from_section (getenv ("TERM"), mc_global_config
);
1226 mc_config_deinit (mc_global_config
);
1229 load_keys_from_section ("general", mc_main_config
);
1230 load_keys_from_section (getenv ("TERM"), mc_main_config
);
1233 /* --------------------------------------------------------------------------------------------- */
1235 #ifdef ENABLE_VFS_FTP
1237 load_anon_passwd (void)
1241 buffer
= mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftpfs_password", "");
1243 if ((buffer
!= NULL
) && (buffer
[0] != '\0'))
1249 #endif /* ENABLE_VFS_FTP */
1251 /* --------------------------------------------------------------------------------------------- */
1254 load_keymap_defs (gboolean load_from_file
)
1257 * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
1258 * definitions override global settings.
1260 mc_config_t
*mc_global_keymap
;
1262 mc_global_keymap
= load_setup_get_keymap_profile_config (load_from_file
);
1264 if (mc_global_keymap
!= NULL
)
1266 main_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1267 load_keymap_from_section (KEYMAP_SECTION_MAIN
, main_keymap
, mc_global_keymap
);
1268 main_x_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1269 load_keymap_from_section (KEYMAP_SECTION_MAIN_EXT
, main_x_keymap
, mc_global_keymap
);
1271 panel_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1272 load_keymap_from_section (KEYMAP_SECTION_PANEL
, panel_keymap
, mc_global_keymap
);
1274 dialog_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1275 load_keymap_from_section (KEYMAP_SECTION_DIALOG
, dialog_keymap
, mc_global_keymap
);
1277 input_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1278 load_keymap_from_section (KEYMAP_SECTION_INPUT
, input_keymap
, mc_global_keymap
);
1280 listbox_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1281 load_keymap_from_section (KEYMAP_SECTION_LISTBOX
, listbox_keymap
, mc_global_keymap
);
1283 tree_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1284 load_keymap_from_section (KEYMAP_SECTION_TREE
, tree_keymap
, mc_global_keymap
);
1286 help_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1287 load_keymap_from_section (KEYMAP_SECTION_HELP
, help_keymap
, mc_global_keymap
);
1289 #ifdef USE_INTERNAL_EDIT
1290 editor_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1291 load_keymap_from_section (KEYMAP_SECTION_EDITOR
, editor_keymap
, mc_global_keymap
);
1292 editor_x_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1293 load_keymap_from_section (KEYMAP_SECTION_EDITOR_EXT
, editor_x_keymap
, mc_global_keymap
);
1296 viewer_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1297 load_keymap_from_section (KEYMAP_SECTION_VIEWER
, viewer_keymap
, mc_global_keymap
);
1298 viewer_hex_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1299 load_keymap_from_section (KEYMAP_SECTION_VIEWER_HEX
, viewer_hex_keymap
, mc_global_keymap
);
1301 #ifdef USE_DIFF_VIEW
1302 diff_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1303 load_keymap_from_section (KEYMAP_SECTION_DIFFVIEWER
, diff_keymap
, mc_global_keymap
);
1306 mc_config_deinit (mc_global_keymap
);
1309 main_map
= (global_keymap_t
*) main_keymap
->data
;
1310 main_x_map
= (global_keymap_t
*) main_x_keymap
->data
;
1311 panel_map
= (global_keymap_t
*) panel_keymap
->data
;
1312 dialog_map
= (global_keymap_t
*) dialog_keymap
->data
;
1313 input_map
= (global_keymap_t
*) input_keymap
->data
;
1314 listbox_map
= (global_keymap_t
*) listbox_keymap
->data
;
1315 tree_map
= (global_keymap_t
*) tree_keymap
->data
;
1316 help_map
= (global_keymap_t
*) help_keymap
->data
;
1317 #ifdef USE_INTERNAL_EDIT
1318 editor_map
= (global_keymap_t
*) editor_keymap
->data
;
1319 editor_x_map
= (global_keymap_t
*) editor_x_keymap
->data
;
1321 viewer_map
= (global_keymap_t
*) viewer_keymap
->data
;
1322 viewer_hex_map
= (global_keymap_t
*) viewer_hex_keymap
->data
;
1323 #ifdef USE_DIFF_VIEW
1324 diff_map
= (global_keymap_t
*) diff_keymap
->data
;
1328 /* --------------------------------------------------------------------------------------------- */
1331 free_keymap_defs (void)
1333 if (main_keymap
!= NULL
)
1334 g_array_free (main_keymap
, TRUE
);
1335 if (main_x_keymap
!= NULL
)
1336 g_array_free (main_x_keymap
, TRUE
);
1337 if (panel_keymap
!= NULL
)
1338 g_array_free (panel_keymap
, TRUE
);
1339 if (dialog_keymap
!= NULL
)
1340 g_array_free (dialog_keymap
, TRUE
);
1341 if (input_keymap
!= NULL
)
1342 g_array_free (input_keymap
, TRUE
);
1343 if (listbox_keymap
!= NULL
)
1344 g_array_free (listbox_keymap
, TRUE
);
1345 if (tree_keymap
!= NULL
)
1346 g_array_free (tree_keymap
, TRUE
);
1347 if (help_keymap
!= NULL
)
1348 g_array_free (help_keymap
, TRUE
);
1349 #ifdef USE_INTERNAL_EDIT
1350 if (editor_keymap
!= NULL
)
1351 g_array_free (editor_keymap
, TRUE
);
1352 if (editor_x_keymap
!= NULL
)
1353 g_array_free (editor_x_keymap
, TRUE
);
1355 if (viewer_keymap
!= NULL
)
1356 g_array_free (viewer_keymap
, TRUE
);
1357 if (viewer_hex_keymap
!= NULL
)
1358 g_array_free (viewer_hex_keymap
, TRUE
);
1359 #ifdef USE_DIFF_VIEW
1360 if (diff_keymap
!= NULL
)
1361 g_array_free (diff_keymap
, TRUE
);
1365 /* --------------------------------------------------------------------------------------------- */
1368 panel_load_setup (WPanel
* panel
, const char *section
)
1371 char *buffer
, buffer2
[BUF_TINY
];
1373 panel
->sort_info
.reverse
= mc_config_get_int (mc_panels_config
, section
, "reverse", 0);
1374 panel
->sort_info
.case_sensitive
=
1375 mc_config_get_int (mc_panels_config
, section
, "case_sensitive",
1376 OS_SORT_CASE_SENSITIVE_DEFAULT
);
1377 panel
->sort_info
.exec_first
= mc_config_get_int (mc_panels_config
, section
, "exec_first", 0);
1379 /* Load sort order */
1380 buffer
= mc_config_get_string (mc_panels_config
, section
, "sort_order", "name");
1381 panel
->sort_info
.sort_field
= panel_get_field_by_id (buffer
);
1382 if (panel
->sort_info
.sort_field
== NULL
)
1383 panel
->sort_info
.sort_field
= panel_get_field_by_id ("name");
1387 /* Load the listing mode */
1388 buffer
= mc_config_get_string (mc_panels_config
, section
, "list_mode", "full");
1389 panel
->list_type
= list_full
;
1390 for (i
= 0; list_types
[i
].key
!= NULL
; i
++)
1391 if (g_ascii_strcasecmp (list_types
[i
].key
, buffer
) == 0)
1393 panel
->list_type
= list_types
[i
].list_type
;
1399 g_free (panel
->user_format
);
1400 panel
->user_format
=
1401 mc_config_get_string (mc_panels_config
, section
, "user_format", DEFAULT_USER_FORMAT
);
1403 for (i
= 0; i
< LIST_TYPES
; i
++)
1405 g_free (panel
->user_status_format
[i
]);
1406 g_snprintf (buffer2
, BUF_TINY
, "user_status%lld", (long long) i
);
1407 panel
->user_status_format
[i
] =
1408 mc_config_get_string (mc_panels_config
, section
, buffer2
, DEFAULT_USER_FORMAT
);
1411 panel
->user_mini_status
= mc_config_get_int (mc_panels_config
, section
, "user_mini_status", 0);
1414 /* --------------------------------------------------------------------------------------------- */
1417 panel_save_setup (struct WPanel
*panel
, const char *section
)
1419 char buffer
[BUF_TINY
];
1422 mc_config_set_int (mc_panels_config
, section
, "reverse", panel
->sort_info
.reverse
);
1423 mc_config_set_int (mc_panels_config
, section
, "case_sensitive",
1424 panel
->sort_info
.case_sensitive
);
1425 mc_config_set_int (mc_panels_config
, section
, "exec_first", panel
->sort_info
.exec_first
);
1427 mc_config_set_string (mc_panels_config
, section
, "sort_order", panel
->sort_info
.sort_field
->id
);
1429 for (i
= 0; list_types
[i
].key
!= NULL
; i
++)
1430 if (list_types
[i
].list_type
== panel
->list_type
)
1432 mc_config_set_string (mc_panels_config
, section
, "list_mode", list_types
[i
].key
);
1436 mc_config_set_string (mc_panels_config
, section
, "user_format", panel
->user_format
);
1438 for (i
= 0; i
< LIST_TYPES
; i
++)
1440 g_snprintf (buffer
, BUF_TINY
, "user_status%lld", (long long) i
);
1441 mc_config_set_string (mc_panels_config
, section
, buffer
, panel
->user_status_format
[i
]);
1444 mc_config_set_int (mc_panels_config
, section
, "user_mini_status", panel
->user_mini_status
);
1447 /* --------------------------------------------------------------------------------------------- */
1450 Load panels options from [Panels] section.
1453 panels_load_options (void)
1455 if (mc_config_has_group (mc_main_config
, CONFIG_PANELS_SECTION
))
1460 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
1461 *panels_ini_options
[i
].opt_addr
=
1462 mc_config_get_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
1463 panels_ini_options
[i
].opt_name
,
1464 *panels_ini_options
[i
].opt_addr
);
1466 qmode
= mc_config_get_int (mc_main_config
, CONFIG_PANELS_SECTION
,
1467 "quick_search_mode", (int) panels_options
.qsearch_mode
);
1469 panels_options
.qsearch_mode
= QSEARCH_CASE_INSENSITIVE
;
1470 else if (qmode
>= QSEARCH_NUM
)
1471 panels_options
.qsearch_mode
= QSEARCH_PANEL_CASE
;
1473 panels_options
.qsearch_mode
= (qsearch_mode_t
) qmode
;
1477 /* --------------------------------------------------------------------------------------------- */
1480 Save panels options in [Panels] section.
1483 panels_save_options (void)
1487 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
1488 mc_config_set_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
1489 panels_ini_options
[i
].opt_name
, *panels_ini_options
[i
].opt_addr
);
1491 mc_config_set_int (mc_main_config
, CONFIG_PANELS_SECTION
,
1492 "quick_search_mode", (int) panels_options
.qsearch_mode
);
1495 /* --------------------------------------------------------------------------------------------- */