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 */
190 /* If set, then print to the given file the last directory we were at */
191 char *last_wd_string
= NULL
;
193 /* Set when main loop should be terminated */
196 /* The user's shell */
200 const char *mc_prompt
= NULL
;
202 /* Set to TRUE to suppress printing the last directory */
203 int print_last_revert
= FALSE
;
205 /* index to record_macro_buf[], -1 if not recording a macro */
206 int macro_index
= -1;
209 struct macro_action_t record_macro_buf
[MAX_MACRO_LENGTH
];
213 /*** file scope macro definitions ****************************************************************/
215 /* In order to use everywhere the same setup for the locale we use defines */
216 #define FMTYEAR _("%b %e %Y")
217 #define FMTTIME _("%b %e %H:%M")
219 /*** file scope type declarations ****************************************************************/
221 /*** file scope variables ************************************************************************/
223 static char *panels_profile_name
= NULL
; /* ${XDG_CACHE_HOME}/mc/panels.ini */
231 { "full", list_full
},
232 { "brief", list_brief
},
233 { "long", list_long
},
234 { "user", list_user
},
240 const char *opt_name
;
241 panel_view_mode_t opt_type
;
243 { "listing", view_listing
},
244 { "quickview", view_quick
},
245 { "info", view_info
},
246 { "tree", view_tree
},
247 { NULL
, view_listing
}
252 const char *opt_name
;
255 { "message_visible", &mc_global
.message_visible
},
256 { "keybar_visible", &mc_global
.keybar_visible
},
257 { "xterm_title", &xterm_title
},
258 { "output_lines", &output_lines
},
259 { "command_prompt", &command_prompt
},
260 { "menubar_visible", &menubar_visible
},
261 { "free_space", &free_space
},
262 { "horizontal_split", &panels_layout
.horizontal_split
},
263 { "vertical_equal", &panels_layout
.vertical_equal
},
264 { "left_panel_size", &panels_layout
.left_panel_size
},
265 { "horizontal_equal", &panels_layout
.horizontal_equal
},
266 { "top_panel_size", &panels_layout
.top_panel_size
},
272 const char *opt_name
;
275 { "verbose", &verbose
},
276 { "pause_after_run", &pause_after_run
},
277 { "shell_patterns", &easy_patterns
},
278 { "auto_save_setup", &auto_save_setup
},
279 { "preallocate_space", &mc_global
.vfs
.preallocate_space
},
280 { "auto_menu", &auto_menu
},
281 { "use_internal_view", &use_internal_view
},
282 { "use_internal_edit", &use_internal_edit
},
283 { "clear_before_exec", &clear_before_exec
},
284 { "confirm_delete", &confirm_delete
},
285 { "confirm_overwrite", &confirm_overwrite
},
286 { "confirm_execute", &confirm_execute
},
287 { "confirm_history_cleanup", &mc_global
.widget
.confirm_history_cleanup
},
288 { "confirm_exit", &confirm_exit
},
289 { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete
},
290 { "safe_delete", &safe_delete
},
291 { "mouse_repeat_rate", &mou_auto_repeat
},
292 { "double_click_speed", &double_click_speed
},
294 { "eight_bit_clean", &mc_global
.eight_bit_clean
},
295 { "full_eight_bits", &mc_global
.full_eight_bits
},
296 #endif /* !HAVE_CHARSET */
297 { "use_8th_bit_as_meta", &use_8th_bit_as_meta
},
298 { "confirm_view_dir", &confirm_view_dir
},
299 { "mouse_move_pages_viewer", &mcview_mouse_move_pages
},
300 { "mouse_close_dialog", &mouse_close_dialog
},
301 { "fast_refresh", &fast_refresh
},
302 { "drop_menus", &drop_menus
},
303 { "wrap_mode", &mcview_global_wrap_mode
},
304 { "old_esc_mode", &old_esc_mode
},
305 { "old_esc_mode_timeout", &old_esc_mode_timeout
},
306 { "cd_symlinks", &mc_global
.vfs
.cd_symlinks
},
307 { "show_all_if_ambiguous", &mc_global
.widget
.show_all_if_ambiguous
},
308 { "max_dirt_limit", &mcview_max_dirt_limit
},
309 { "use_file_to_guess_type", &use_file_to_check_type
},
310 { "alternate_plus_minus", &mc_global
.tty
.alternate_plus_minus
},
311 { "only_leading_plus_minus", &only_leading_plus_minus
},
312 { "show_output_starts_shell", &output_starts_shell
},
313 { "xtree_mode", &xtree_mode
},
314 { "num_history_items_recorded", &num_history_items_recorded
},
315 { "file_op_compute_totals", &file_op_compute_totals
},
316 { "classic_progressbar", &classic_progressbar
},
318 { "vfs_timeout", &vfs_timeout
},
319 #ifdef ENABLE_VFS_FTP
320 { "ftpfs_directory_timeout", &ftpfs_directory_timeout
},
321 { "use_netrc", &ftpfs_use_netrc
},
322 { "ftpfs_retry_seconds", &ftpfs_retry_seconds
},
323 { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy
},
324 { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections
},
325 { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy
},
326 { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options
},
327 { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls
},
328 #endif /* ENABLE_VFS_FTP */
329 #ifdef ENABLE_VFS_FISH
330 { "fish_directory_timeout", &fish_directory_timeout
},
331 #endif /* ENABLE_VFS_FISH */
332 #endif /* ENABLE_VFS */
333 /* option_tab_spacing is used in internal viewer */
334 { "editor_tab_spacing", &option_tab_spacing
},
335 #ifdef USE_INTERNAL_EDIT
336 { "editor_word_wrap_line_length", &option_word_wrap_line_length
},
337 { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces
},
338 { "editor_return_does_auto_indent", &option_return_does_auto_indent
},
339 { "editor_backspace_through_tabs", &option_backspace_through_tabs
},
340 { "editor_fake_half_tabs", &option_fake_half_tabs
},
341 { "editor_option_save_mode", &option_save_mode
},
342 { "editor_option_save_position", &option_save_position
},
343 { "editor_option_auto_para_formatting", &option_auto_para_formatting
},
344 { "editor_option_typewriter_wrap", &option_typewriter_wrap
},
345 { "editor_edit_confirm_save", &edit_confirm_save
},
346 { "editor_syntax_highlighting", &option_syntax_highlighting
},
347 { "editor_persistent_selections", &option_persistent_selections
},
348 { "editor_cursor_beyond_eol", &option_cursor_beyond_eol
},
349 { "editor_cursor_after_inserted_block", &option_cursor_after_inserted_block
},
350 { "editor_visible_tabs", &visible_tabs
},
351 { "editor_visible_spaces", &visible_tws
},
352 { "editor_line_state", &option_line_state
},
353 { "editor_simple_statusbar", &simple_statusbar
},
354 { "editor_check_new_line", &option_check_nl_at_eof
},
355 { "editor_show_right_margin", &show_right_margin
},
356 { "editor_group_undo", &option_group_undo
},
357 #endif /* USE_INTERNAL_EDIT */
358 { "nice_rotating_dash", &nice_rotating_dash
},
359 { "mcview_remember_file_position", &mcview_remember_file_position
},
360 { "auto_fill_mkdir_name", &auto_fill_mkdir_name
},
361 { "copymove_persistent_attr", &setup_copymove_persistent_attr
},
362 { "select_flags", &select_flags
},
368 const char *opt_name
;
370 const char *opt_defval
;
372 #ifdef USE_INTERNAL_EDIT
373 { "editor_backup_extension", &option_backup_ext
, "~" },
375 { "mcview_eof", &mcview_show_eof
, "" },
381 const char *opt_name
;
383 } panels_ini_options
[] = {
384 { "show_mini_info", &panels_options
.show_mini_info
},
385 { "kilobyte_si", &panels_options
.kilobyte_si
},
386 { "mix_all_files", &panels_options
.mix_all_files
},
387 { "show_backups", &panels_options
.show_backups
},
388 { "show_dot_files", &panels_options
.show_dot_files
},
389 { "fast_reload", &panels_options
.fast_reload
},
390 { "fast_reload_msg_shown", &panels_options
.fast_reload_msg_shown
},
391 { "mark_moves_down", &panels_options
.mark_moves_down
},
392 { "reverse_files_only", &panels_options
.reverse_files_only
},
393 { "auto_save_setup_panels", &panels_options
.auto_save_setup
},
394 { "navigate_with_arrows", &panels_options
.navigate_with_arrows
},
395 { "panel_scroll_pages", &panels_options
.scroll_pages
},
396 { "mouse_move_pages", &panels_options
.mouse_move_pages
},
397 { "filetype_mode", &panels_options
.filetype_mode
},
398 { "permission_mode", &panels_options
.permission_mode
},
399 { "torben_fj_mode", &panels_options
.torben_fj_mode
},
404 /*** file scope functions ************************************************************************/
405 /* --------------------------------------------------------------------------------------------- */
408 * Get name of config file.
410 * @param subdir If not NULL, config is also searched in specified subdir.
411 * @param config_file_name If relative, file if searched in standard paths.
413 * @return newly allocated string with config name or NULL if file is not found.
417 load_setup_get_full_config_name (const char *subdir
, const char *config_file_name
)
420 TODO: IMHO, in future, this function shall be placed in mcconfig module.
422 char *lc_basename
, *ret
;
425 if (config_file_name
== NULL
)
428 /* check for .keymap suffix */
429 if (g_str_has_suffix (config_file_name
, ".keymap"))
430 file_name
= g_strdup (config_file_name
);
432 file_name
= g_strconcat (config_file_name
, ".keymap", (char *) NULL
);
434 canonicalize_pathname (file_name
);
436 if (g_path_is_absolute (file_name
))
439 lc_basename
= g_path_get_basename (file_name
);
442 if (lc_basename
== NULL
)
446 ret
= g_build_filename (mc_config_get_path (), subdir
, lc_basename
, NULL
);
448 ret
= g_build_filename (mc_config_get_path (), lc_basename
, NULL
);
450 if (exist_file (ret
))
452 g_free (lc_basename
);
453 canonicalize_pathname (ret
);
459 ret
= g_build_filename (mc_global
.sysconfig_dir
, subdir
, lc_basename
, NULL
);
461 ret
= g_build_filename (mc_global
.sysconfig_dir
, lc_basename
, NULL
);
463 if (exist_file (ret
))
465 g_free (lc_basename
);
466 canonicalize_pathname (ret
);
472 ret
= g_build_filename (mc_global
.share_data_dir
, subdir
, lc_basename
, NULL
);
474 ret
= g_build_filename (mc_global
.share_data_dir
, lc_basename
, NULL
);
476 g_free (lc_basename
);
478 if (exist_file (ret
))
480 canonicalize_pathname (ret
);
488 /* --------------------------------------------------------------------------------------------- */
491 setup__is_cfg_group_must_panel_config (const char *grp
)
493 return (!strcasecmp ("Dirs", grp
) ||
494 !strcasecmp ("Temporal:New Right Panel", grp
) ||
495 !strcasecmp ("Temporal:New Left Panel", grp
) ||
496 !strcasecmp ("New Left Panel", grp
) || !strcasecmp ("New Right Panel", grp
))
500 /* --------------------------------------------------------------------------------------------- */
503 setup__move_panels_config_into_separate_file (const char *profile
)
505 mc_config_t
*tmp_cfg
;
506 char **groups
, **curr_grp
;
507 const char *need_grp
;
509 if (!exist_file (profile
))
512 tmp_cfg
= mc_config_init (profile
, FALSE
);
516 curr_grp
= groups
= mc_config_get_groups (tmp_cfg
, NULL
);
519 mc_config_deinit (tmp_cfg
);
525 if (setup__is_cfg_group_must_panel_config (*curr_grp
) == NULL
)
526 mc_config_del_group (tmp_cfg
, *curr_grp
);
530 mc_config_save_to_file (tmp_cfg
, panels_profile_name
, NULL
);
531 mc_config_deinit (tmp_cfg
);
533 tmp_cfg
= mc_config_init (profile
, FALSE
);
544 need_grp
= setup__is_cfg_group_must_panel_config (*curr_grp
);
545 if (need_grp
!= NULL
)
547 mc_config_del_group (tmp_cfg
, need_grp
);
553 mc_config_save_file (tmp_cfg
, NULL
);
554 mc_config_deinit (tmp_cfg
);
557 /* --------------------------------------------------------------------------------------------- */
559 Create new mc_config object from specified ini-file or
560 append data to existing mc_config object from ini-file
564 load_setup_init_config_from_file (mc_config_t
** config
, const char *fname
, gboolean read_only
)
567 TODO: IMHO, in future, this function shall be placed in mcconfig module.
569 if (exist_file (fname
))
572 mc_config_read_file (*config
, fname
, read_only
, TRUE
);
574 *config
= mc_config_init (fname
, read_only
);
578 /* --------------------------------------------------------------------------------------------- */
585 int first_panel_size
;
588 panels_layout
.horizontal_split
= mc_config_get_int (mc_main_config
, CONFIG_APP_SECTION
,
589 "horizontal_split", 0);
590 equal_split
= mc_config_get_int (mc_main_config
, "Layout", "equal_split", 1);
591 first_panel_size
= mc_config_get_int (mc_main_config
, "Layout", "first_panel_size", 1);
592 if (panels_layout
.horizontal_split
)
594 panels_layout
.horizontal_equal
= equal_split
;
595 panels_layout
.left_panel_size
= first_panel_size
;
599 panels_layout
.vertical_equal
= equal_split
;
600 panels_layout
.top_panel_size
= first_panel_size
;
603 /* actual options override legacy ones */
604 for (i
= 0; layout
[i
].opt_name
!= NULL
; i
++)
605 *layout
[i
].opt_addr
= mc_config_get_int (mc_main_config
, CONFIG_LAYOUT_SECTION
,
606 layout
[i
].opt_name
, *layout
[i
].opt_addr
);
608 /* remove legacy options */
609 mc_config_del_key (mc_main_config
, CONFIG_APP_SECTION
, "horizontal_split");
610 mc_config_del_key (mc_main_config
, "Layout", "equal_split");
611 mc_config_del_key (mc_main_config
, "Layout", "first_panel_size");
614 /* --------------------------------------------------------------------------------------------- */
617 load_keys_from_section (const char *terminal
, mc_config_t
* cfg
)
620 gchar
**profile_keys
, **keys
;
621 gchar
**values
, **curr_values
;
622 char *valcopy
, *value
;
624 gsize len
, values_len
;
626 if (terminal
== NULL
)
629 section_name
= g_strconcat ("terminal:", terminal
, (char *) NULL
);
630 profile_keys
= keys
= mc_config_get_keys (cfg
, section_name
, &len
);
632 while (*profile_keys
!= NULL
)
634 /* copy=other causes all keys from [terminal:other] to be loaded. */
635 if (g_ascii_strcasecmp (*profile_keys
, "copy") == 0)
637 valcopy
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
638 load_keys_from_section (valcopy
, cfg
);
644 curr_values
= values
=
645 mc_config_get_string_list (cfg
, section_name
, *profile_keys
, &values_len
);
647 key_code
= lookup_key (*profile_keys
, NULL
);
651 if (curr_values
!= NULL
)
653 while (*curr_values
!= NULL
)
655 valcopy
= convert_controls (*curr_values
);
656 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
663 value
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
664 valcopy
= convert_controls (value
);
665 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
675 g_free (section_name
);
678 /* --------------------------------------------------------------------------------------------- */
681 load_keymap_from_section (const char *section_name
, GArray
* keymap
, mc_config_t
* cfg
)
683 gchar
**profile_keys
, **keys
;
686 if (section_name
== NULL
)
689 profile_keys
= keys
= mc_config_get_keys (cfg
, section_name
, &len
);
691 while (*profile_keys
!= NULL
)
693 gchar
**values
, **curr_values
;
695 curr_values
= values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, &len
);
697 if (curr_values
!= NULL
)
701 action
= keybind_lookup_action (*profile_keys
);
703 while (*curr_values
!= NULL
)
705 keybind_cmd_bind (keymap
, *curr_values
, action
);
718 /* --------------------------------------------------------------------------------------------- */
721 load_setup_get_keymap_profile_config (gboolean load_from_file
)
724 TODO: IMHO, in future, this function shall be placed in mcconfig module.
726 mc_config_t
*keymap_config
;
727 char *share_keymap
, *sysconfig_keymap
;
728 char *fname
, *fname2
;
730 /* 0) Create default keymap */
731 keymap_config
= create_default_keymap ();
733 return keymap_config
;
735 /* load and merge global keymaps */
737 /* 1) /usr/share/mc (mc_global.share_data_dir) */
738 share_keymap
= g_build_filename (mc_global
.share_data_dir
, GLOBAL_KEYMAP_FILE
, NULL
);
739 load_setup_init_config_from_file (&keymap_config
, share_keymap
, TRUE
);
741 /* 2) /etc/mc (mc_global.sysconfig_dir) */
742 sysconfig_keymap
= g_build_filename (mc_global
.sysconfig_dir
, GLOBAL_KEYMAP_FILE
, NULL
);
743 load_setup_init_config_from_file (&keymap_config
, sysconfig_keymap
, TRUE
);
745 /* then load and merge one of user-defined keymap */
747 /* 3) --keymap=<keymap> */
748 fname
= load_setup_get_full_config_name (NULL
, mc_args__keymap_file
);
749 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
751 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
756 /* 4) getenv("MC_KEYMAP") */
757 fname
= load_setup_get_full_config_name (NULL
, g_getenv ("MC_KEYMAP"));
758 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
760 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
765 /* 5) main config; [Midnight Commander] -> keymap */
766 fname2
= mc_config_get_string (mc_main_config
, CONFIG_APP_SECTION
, "keymap", NULL
);
767 if (fname2
!= NULL
&& *fname2
!= '\0')
768 fname
= load_setup_get_full_config_name (NULL
, fname2
);
770 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
772 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
777 /* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
778 fname
= mc_config_get_full_path (GLOBAL_KEYMAP_FILE
);
779 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
783 g_free (sysconfig_keymap
);
784 g_free (share_keymap
);
786 return keymap_config
;
789 /* --------------------------------------------------------------------------------------------- */
791 static panel_view_mode_t
792 setup__load_panel_state (const char *section
)
796 panel_view_mode_t mode
= view_listing
;
798 /* Load the display mode */
799 buffer
= mc_config_get_string (mc_panels_config
, section
, "display", "listing");
801 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
802 if (g_ascii_strcasecmp (panel_types
[i
].opt_name
, buffer
) == 0)
804 mode
= panel_types
[i
].opt_type
;
813 /* --------------------------------------------------------------------------------------------- */
816 panel_save_type (const char *section
, panel_view_mode_t type
)
820 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
821 if (panel_types
[i
].opt_type
== type
)
823 mc_config_set_string (mc_panels_config
, section
, "display", panel_types
[i
].opt_name
);
828 /* --------------------------------------------------------------------------------------------- */
830 /* save panels.ini */
832 save_panel_types (void)
834 panel_view_mode_t type
;
836 if (mc_global
.mc_run_mode
!= MC_RUN_FULL
)
839 type
= get_display_type (0);
840 panel_save_type ("New Left Panel", type
);
841 if (type
== view_listing
)
842 panel_save_setup (left_panel
, left_panel
->panel_name
);
843 type
= get_display_type (1);
844 panel_save_type ("New Right Panel", type
);
845 if (type
== view_listing
)
846 panel_save_setup (right_panel
, right_panel
->panel_name
);
851 dirs
= get_panel_dir_for (other_panel
);
852 mc_config_set_string (mc_panels_config
, "Dirs", "other_dir", dirs
);
856 if (current_panel
!= NULL
)
857 mc_config_set_bool (mc_panels_config
, "Dirs", "current_is_left", get_current_index () == 0);
859 if (mc_panels_config
->ini_path
== NULL
)
860 mc_panels_config
->ini_path
= g_strdup (panels_profile_name
);
862 mc_config_del_group (mc_panels_config
, "Temporal:New Left Panel");
863 mc_config_del_group (mc_panels_config
, "Temporal:New Right Panel");
865 mc_config_save_file (mc_panels_config
, NULL
);
868 /* --------------------------------------------------------------------------------------------- */
869 /*** public functions ****************************************************************************/
870 /* --------------------------------------------------------------------------------------------- */
878 if (profile_name
!= NULL
)
881 profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
882 if (!exist_file (profile
))
884 inifile
= mc_build_filename (mc_global
.sysconfig_dir
, "mc.ini", NULL
);
885 if (exist_file (inifile
))
893 inifile
= mc_build_filename (mc_global
.share_data_dir
, "mc.ini", NULL
);
894 if (exist_file (inifile
))
904 profile_name
= profile
;
909 /* --------------------------------------------------------------------------------------------- */
920 load_codepages_list ();
921 #endif /* HAVE_CHARSET */
923 profile
= setup_init ();
925 /* mc.lib is common for all users, but has priority lower than
926 ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */
927 global_profile_name
=
928 g_build_filename (mc_global
.sysconfig_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
929 if (!exist_file (global_profile_name
))
931 g_free (global_profile_name
);
932 global_profile_name
=
933 g_build_filename (mc_global
.share_data_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
936 panels_profile_name
= mc_config_get_full_path (MC_PANELS_FILE
);
938 mc_main_config
= mc_config_init (profile
, FALSE
);
940 if (!exist_file (panels_profile_name
))
941 setup__move_panels_config_into_separate_file (profile
);
943 mc_panels_config
= mc_config_init (panels_profile_name
, FALSE
);
945 /* Load integer boolean options */
946 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
947 *int_options
[i
].opt_addr
=
948 mc_config_get_int (mc_main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
949 *int_options
[i
].opt_addr
);
951 if (option_tab_spacing
<= 0)
952 option_tab_spacing
= DEFAULT_TAB_SPACING
;
954 #ifdef USE_INTERNAL_EDIT
955 if (option_word_wrap_line_length
<= 0)
956 option_word_wrap_line_length
= DEFAULT_WRAP_LINE_LENGTH
;
957 #endif /* USE_INTERNAL_EDIT */
959 /* overwrite old_esc_mode_timeout */
960 kt
= getenv ("KEYBOARD_KEY_TIMEOUT_US");
961 if ((kt
!= NULL
) && (kt
[0] != '\0'))
962 old_esc_mode_timeout
= atoi (kt
);
964 /* Load string options */
965 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
966 *str_options
[i
].opt_addr
=
967 mc_config_get_string (mc_main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
,
968 str_options
[i
].opt_defval
);
971 panels_load_options ();
974 startup_left_mode
= setup__load_panel_state ("New Left Panel");
975 startup_right_mode
= setup__load_panel_state ("New Right Panel");
977 /* At least one of the panels is a listing panel */
978 if (startup_left_mode
!= view_listing
&& startup_right_mode
!= view_listing
)
979 startup_left_mode
= view_listing
;
981 if (mc_run_param1
== NULL
)
984 buffer
= mc_config_get_string (mc_panels_config
, "Dirs", "other_dir", ".");
985 vpath
= vfs_path_from_str (buffer
);
986 if (vfs_file_is_local (vpath
))
987 mc_run_param1
= buffer
;
990 vfs_path_free (vpath
);
993 boot_current_is_left
= mc_config_get_bool (mc_panels_config
, "Dirs", "current_is_left", TRUE
);
995 /* Load time formats */
996 user_recent_timeformat
=
997 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "timeformat_recent", FMTTIME
);
998 user_old_timeformat
=
999 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "timeformat_old", FMTYEAR
);
1001 #ifdef ENABLE_VFS_FTP
1003 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host", "gate");
1004 ftpfs_ignore_chattr_errors
=
1005 mc_config_get_bool (mc_main_config
, CONFIG_APP_SECTION
, "ignore_ftp_chattr_errors", TRUE
);
1006 ftpfs_init_passwd ();
1007 #endif /* ENABLE_VFS_FTP */
1009 /* The default color and the terminal dependent color */
1010 mc_global
.tty
.setup_color_string
=
1011 mc_config_get_string (mc_main_config
, "Colors", "base_color", "");
1012 mc_global
.tty
.term_color_string
=
1013 mc_config_get_string (mc_main_config
, "Colors", getenv ("TERM"), "");
1014 mc_global
.tty
.color_terminal_string
=
1015 mc_config_get_string (mc_main_config
, "Colors", "color_terminals", "");
1017 /* Load the directory history */
1018 /* directory_history_load (); */
1019 /* Remove the temporal entries */
1022 if (codepages
->len
> 1)
1024 buffer
= mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "display_codepage", "");
1025 if (buffer
[0] != '\0')
1027 mc_global
.display_codepage
= get_codepage_index (buffer
);
1028 cp_display
= get_codepage_id (mc_global
.display_codepage
);
1031 buffer
= mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "source_codepage", "");
1032 if (buffer
[0] != '\0')
1034 default_source_codepage
= get_codepage_index (buffer
);
1035 mc_global
.source_codepage
= default_source_codepage
; /* May be source_codepage doesn't need this */
1036 cp_source
= get_codepage_id (mc_global
.source_codepage
);
1041 autodetect_codeset
=
1042 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset", "");
1043 if ((autodetect_codeset
[0] != '\0') && (strcmp (autodetect_codeset
, "off") != 0))
1044 is_autodetect_codeset_enabled
= TRUE
;
1046 g_free (init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
));
1047 buffer
= (char *) get_codepage_id (mc_global
.display_codepage
);
1049 mc_global
.utf8_display
= str_isutf8 (buffer
);
1050 #endif /* HAVE_CHARSET */
1052 clipboard_store_path
=
1053 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_store", "");
1054 clipboard_paste_path
=
1055 mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_paste", "");
1058 /* --------------------------------------------------------------------------------------------- */
1061 save_setup (gboolean save_options
, gboolean save_panel_options
)
1063 gboolean ret
= TRUE
;
1069 if (save_panel_options
)
1070 save_panel_types ();
1078 panels_save_options ();
1080 /* directory_history_save (); */
1082 #ifdef ENABLE_VFS_FTP
1083 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftpfs_password",
1084 ftpfs_anonymous_passwd
);
1085 if (ftpfs_proxy_host
)
1086 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host",
1088 #endif /* ENABLE_VFS_FTP */
1091 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "display_codepage",
1092 get_codepage_id (mc_global
.display_codepage
));
1093 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "source_codepage",
1094 get_codepage_id (default_source_codepage
));
1095 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset",
1096 autodetect_codeset
);
1097 #endif /* HAVE_CHARSET */
1098 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_store",
1099 clipboard_store_path
);
1100 mc_config_set_string (mc_main_config
, CONFIG_MISC_SECTION
, "clipboard_paste",
1101 clipboard_paste_path
);
1103 tmp_profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
1104 ret
= mc_config_save_to_file (mc_main_config
, tmp_profile
, NULL
);
1105 g_free (tmp_profile
);
1113 /* --------------------------------------------------------------------------------------------- */
1120 g_free (clipboard_store_path
);
1121 g_free (clipboard_paste_path
);
1122 g_free (profile_name
);
1123 g_free (global_profile_name
);
1124 g_free (mc_global
.tty
.color_terminal_string
);
1125 g_free (mc_global
.tty
.term_color_string
);
1126 g_free (mc_global
.tty
.setup_color_string
);
1127 g_free (panels_profile_name
);
1128 mc_config_deinit (mc_main_config
);
1129 mc_config_deinit (mc_panels_config
);
1131 g_free (user_recent_timeformat
);
1132 g_free (user_old_timeformat
);
1134 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1135 g_free (*str_options
[i
].opt_addr
);
1139 /* directory_history_free (); */
1142 g_free (autodetect_codeset
);
1143 free_codepages_list ();
1147 /* --------------------------------------------------------------------------------------------- */
1154 /* Save integer options */
1155 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
1156 mc_config_set_int (mc_main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
1157 *int_options
[i
].opt_addr
);
1159 /* Save string options */
1160 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1161 mc_config_set_string (mc_main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
,
1162 *str_options
[i
].opt_addr
);
1165 /* --------------------------------------------------------------------------------------------- */
1168 setup_save_config_show_error (const char *filename
, GError
** error
)
1170 if (error
!= NULL
&& *error
!= NULL
)
1172 message (D_ERROR
, MSG_ERROR
, _("Cannot save file %s:\n%s"), filename
, (*error
)->message
);
1173 g_error_free (*error
);
1178 /* --------------------------------------------------------------------------------------------- */
1185 /* Save integer options */
1186 for (i
= 0; layout
[i
].opt_name
!= NULL
; i
++)
1187 mc_config_set_int (mc_main_config
, CONFIG_LAYOUT_SECTION
, layout
[i
].opt_name
,
1188 *layout
[i
].opt_addr
);
1191 /* --------------------------------------------------------------------------------------------- */
1194 load_key_defs (void)
1197 * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1198 * definitions override global settings.
1200 mc_config_t
*mc_global_config
;
1202 mc_global_config
= mc_config_init (global_profile_name
, FALSE
);
1203 if (mc_global_config
!= NULL
)
1205 load_keys_from_section ("general", mc_global_config
);
1206 load_keys_from_section (getenv ("TERM"), mc_global_config
);
1207 mc_config_deinit (mc_global_config
);
1210 load_keys_from_section ("general", mc_main_config
);
1211 load_keys_from_section (getenv ("TERM"), mc_main_config
);
1214 /* --------------------------------------------------------------------------------------------- */
1216 #ifdef ENABLE_VFS_FTP
1218 load_anon_passwd (void)
1222 buffer
= mc_config_get_string (mc_main_config
, CONFIG_MISC_SECTION
, "ftpfs_password", "");
1224 if ((buffer
!= NULL
) && (buffer
[0] != '\0'))
1230 #endif /* ENABLE_VFS_FTP */
1232 /* --------------------------------------------------------------------------------------------- */
1235 load_keymap_defs (gboolean load_from_file
)
1238 * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
1239 * definitions override global settings.
1241 mc_config_t
*mc_global_keymap
;
1243 mc_global_keymap
= load_setup_get_keymap_profile_config (load_from_file
);
1245 if (mc_global_keymap
!= NULL
)
1247 main_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1248 load_keymap_from_section (KEYMAP_SECTION_MAIN
, main_keymap
, mc_global_keymap
);
1249 main_x_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1250 load_keymap_from_section (KEYMAP_SECTION_MAIN_EXT
, main_x_keymap
, mc_global_keymap
);
1252 panel_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1253 load_keymap_from_section (KEYMAP_SECTION_PANEL
, panel_keymap
, mc_global_keymap
);
1255 dialog_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1256 load_keymap_from_section (KEYMAP_SECTION_DIALOG
, dialog_keymap
, mc_global_keymap
);
1258 input_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1259 load_keymap_from_section (KEYMAP_SECTION_INPUT
, input_keymap
, mc_global_keymap
);
1261 listbox_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1262 load_keymap_from_section (KEYMAP_SECTION_LISTBOX
, listbox_keymap
, mc_global_keymap
);
1264 tree_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1265 load_keymap_from_section (KEYMAP_SECTION_TREE
, tree_keymap
, mc_global_keymap
);
1267 help_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1268 load_keymap_from_section (KEYMAP_SECTION_HELP
, help_keymap
, mc_global_keymap
);
1270 #ifdef USE_INTERNAL_EDIT
1271 editor_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1272 load_keymap_from_section (KEYMAP_SECTION_EDITOR
, editor_keymap
, mc_global_keymap
);
1273 editor_x_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1274 load_keymap_from_section (KEYMAP_SECTION_EDITOR_EXT
, editor_x_keymap
, mc_global_keymap
);
1277 viewer_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1278 load_keymap_from_section (KEYMAP_SECTION_VIEWER
, viewer_keymap
, mc_global_keymap
);
1279 viewer_hex_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1280 load_keymap_from_section (KEYMAP_SECTION_VIEWER_HEX
, viewer_hex_keymap
, mc_global_keymap
);
1282 #ifdef USE_DIFF_VIEW
1283 diff_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1284 load_keymap_from_section (KEYMAP_SECTION_DIFFVIEWER
, diff_keymap
, mc_global_keymap
);
1287 mc_config_deinit (mc_global_keymap
);
1290 main_map
= (global_keymap_t
*) main_keymap
->data
;
1291 main_x_map
= (global_keymap_t
*) main_x_keymap
->data
;
1292 panel_map
= (global_keymap_t
*) panel_keymap
->data
;
1293 dialog_map
= (global_keymap_t
*) dialog_keymap
->data
;
1294 input_map
= (global_keymap_t
*) input_keymap
->data
;
1295 listbox_map
= (global_keymap_t
*) listbox_keymap
->data
;
1296 tree_map
= (global_keymap_t
*) tree_keymap
->data
;
1297 help_map
= (global_keymap_t
*) help_keymap
->data
;
1298 #ifdef USE_INTERNAL_EDIT
1299 editor_map
= (global_keymap_t
*) editor_keymap
->data
;
1300 editor_x_map
= (global_keymap_t
*) editor_x_keymap
->data
;
1302 viewer_map
= (global_keymap_t
*) viewer_keymap
->data
;
1303 viewer_hex_map
= (global_keymap_t
*) viewer_hex_keymap
->data
;
1304 #ifdef USE_DIFF_VIEW
1305 diff_map
= (global_keymap_t
*) diff_keymap
->data
;
1309 /* --------------------------------------------------------------------------------------------- */
1312 free_keymap_defs (void)
1314 if (main_keymap
!= NULL
)
1315 g_array_free (main_keymap
, TRUE
);
1316 if (main_x_keymap
!= NULL
)
1317 g_array_free (main_x_keymap
, TRUE
);
1318 if (panel_keymap
!= NULL
)
1319 g_array_free (panel_keymap
, TRUE
);
1320 if (dialog_keymap
!= NULL
)
1321 g_array_free (dialog_keymap
, TRUE
);
1322 if (input_keymap
!= NULL
)
1323 g_array_free (input_keymap
, TRUE
);
1324 if (listbox_keymap
!= NULL
)
1325 g_array_free (listbox_keymap
, TRUE
);
1326 if (tree_keymap
!= NULL
)
1327 g_array_free (tree_keymap
, TRUE
);
1328 if (help_keymap
!= NULL
)
1329 g_array_free (help_keymap
, TRUE
);
1330 #ifdef USE_INTERNAL_EDIT
1331 if (editor_keymap
!= NULL
)
1332 g_array_free (editor_keymap
, TRUE
);
1333 if (editor_x_keymap
!= NULL
)
1334 g_array_free (editor_x_keymap
, TRUE
);
1336 if (viewer_keymap
!= NULL
)
1337 g_array_free (viewer_keymap
, TRUE
);
1338 if (viewer_hex_keymap
!= NULL
)
1339 g_array_free (viewer_hex_keymap
, TRUE
);
1340 #ifdef USE_DIFF_VIEW
1341 if (diff_keymap
!= NULL
)
1342 g_array_free (diff_keymap
, TRUE
);
1346 /* --------------------------------------------------------------------------------------------- */
1349 panel_load_setup (WPanel
* panel
, const char *section
)
1352 char *buffer
, buffer2
[BUF_TINY
];
1354 panel
->sort_info
.reverse
= mc_config_get_int (mc_panels_config
, section
, "reverse", 0);
1355 panel
->sort_info
.case_sensitive
=
1356 mc_config_get_int (mc_panels_config
, section
, "case_sensitive",
1357 OS_SORT_CASE_SENSITIVE_DEFAULT
);
1358 panel
->sort_info
.exec_first
= mc_config_get_int (mc_panels_config
, section
, "exec_first", 0);
1360 /* Load sort order */
1361 buffer
= mc_config_get_string (mc_panels_config
, section
, "sort_order", "name");
1362 panel
->sort_info
.sort_field
= panel_get_field_by_id (buffer
);
1363 if (panel
->sort_info
.sort_field
== NULL
)
1364 panel
->sort_info
.sort_field
= panel_get_field_by_id ("name");
1368 /* Load the listing mode */
1369 buffer
= mc_config_get_string (mc_panels_config
, section
, "list_mode", "full");
1370 panel
->list_type
= list_full
;
1371 for (i
= 0; list_types
[i
].key
!= NULL
; i
++)
1372 if (g_ascii_strcasecmp (list_types
[i
].key
, buffer
) == 0)
1374 panel
->list_type
= list_types
[i
].list_type
;
1380 g_free (panel
->user_format
);
1381 panel
->user_format
=
1382 mc_config_get_string (mc_panels_config
, section
, "user_format", DEFAULT_USER_FORMAT
);
1384 for (i
= 0; i
< LIST_TYPES
; i
++)
1386 g_free (panel
->user_status_format
[i
]);
1387 g_snprintf (buffer2
, BUF_TINY
, "user_status%lld", (long long) i
);
1388 panel
->user_status_format
[i
] =
1389 mc_config_get_string (mc_panels_config
, section
, buffer2
, DEFAULT_USER_FORMAT
);
1392 panel
->user_mini_status
= mc_config_get_int (mc_panels_config
, section
, "user_mini_status", 0);
1395 /* --------------------------------------------------------------------------------------------- */
1398 panel_save_setup (struct WPanel
*panel
, const char *section
)
1400 char buffer
[BUF_TINY
];
1403 mc_config_set_int (mc_panels_config
, section
, "reverse", panel
->sort_info
.reverse
);
1404 mc_config_set_int (mc_panels_config
, section
, "case_sensitive",
1405 panel
->sort_info
.case_sensitive
);
1406 mc_config_set_int (mc_panels_config
, section
, "exec_first", panel
->sort_info
.exec_first
);
1408 mc_config_set_string (mc_panels_config
, section
, "sort_order", panel
->sort_info
.sort_field
->id
);
1410 for (i
= 0; list_types
[i
].key
!= NULL
; i
++)
1411 if (list_types
[i
].list_type
== panel
->list_type
)
1413 mc_config_set_string (mc_panels_config
, section
, "list_mode", list_types
[i
].key
);
1417 mc_config_set_string (mc_panels_config
, section
, "user_format", panel
->user_format
);
1419 for (i
= 0; i
< LIST_TYPES
; i
++)
1421 g_snprintf (buffer
, BUF_TINY
, "user_status%lld", (long long) i
);
1422 mc_config_set_string (mc_panels_config
, section
, buffer
, panel
->user_status_format
[i
]);
1425 mc_config_set_int (mc_panels_config
, section
, "user_mini_status", panel
->user_mini_status
);
1428 /* --------------------------------------------------------------------------------------------- */
1431 Load panels options from [Panels] section.
1434 panels_load_options (void)
1436 if (mc_config_has_group (mc_main_config
, CONFIG_PANELS_SECTION
))
1441 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
1442 *panels_ini_options
[i
].opt_addr
=
1443 mc_config_get_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
1444 panels_ini_options
[i
].opt_name
,
1445 *panels_ini_options
[i
].opt_addr
);
1447 qmode
= mc_config_get_int (mc_main_config
, CONFIG_PANELS_SECTION
,
1448 "quick_search_mode", (int) panels_options
.qsearch_mode
);
1450 panels_options
.qsearch_mode
= QSEARCH_CASE_INSENSITIVE
;
1451 else if (qmode
>= QSEARCH_NUM
)
1452 panels_options
.qsearch_mode
= QSEARCH_PANEL_CASE
;
1454 panels_options
.qsearch_mode
= (qsearch_mode_t
) qmode
;
1458 /* --------------------------------------------------------------------------------------------- */
1461 Save panels options in [Panels] section.
1464 panels_save_options (void)
1468 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
1469 mc_config_set_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
1470 panels_ini_options
[i
].opt_name
, *panels_ini_options
[i
].opt_addr
);
1472 mc_config_set_int (mc_main_config
, CONFIG_PANELS_SECTION
,
1473 "quick_search_mode", (int) panels_options
.qsearch_mode
);
1476 /* --------------------------------------------------------------------------------------------- */