4 Copyright (C) 1994-2016
5 Free Software Foundation, Inc.
7 This file is part of the Midnight Commander.
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.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * \brief Source: setup loading/saving
32 #include <sys/types.h>
35 #include "lib/global.h"
37 #include "lib/tty/tty.h"
38 #include "lib/tty/key.h"
39 #include "lib/mcconfig.h"
40 #include "lib/fileloc.h"
41 #include "lib/timefmt.h"
43 #include "lib/widget.h"
46 #include "src/vfs/ftpfs/ftpfs.h"
48 #ifdef ENABLE_VFS_FISH
49 #include "src/vfs/fish/fish.h"
53 #include "lib/charsets.h"
56 #include "filemanager/dir.h"
57 #include "filemanager/midnight.h"
58 #include "filemanager/tree.h" /* xtree_mode */
59 #include "filemanager/hotlist.h" /* load/save/done hotlist */
60 #include "filemanager/panelize.h" /* load/save/done panelize */
61 #include "filemanager/layout.h"
62 #include "filemanager/cmd.h"
65 #include "execute.h" /* pause_after_run */
66 #include "clipboard.h"
67 #include "keybind-defaults.h" /* keybind_lookup_action */
70 #include "selcodepage.h"
73 #ifdef USE_INTERNAL_EDIT
74 #include "src/editor/edit.h"
77 #include "src/viewer/mcviewer.h" /* For the externs */
81 /*** global variables ****************************************************************************/
83 char *global_profile_name
; /* mc.lib */
85 /* Only used at program boot */
86 gboolean boot_current_is_left
= TRUE
;
88 /* If on, default for "No" in delete operations */
91 /* Controls screen clearing before an exec */
92 int clear_before_exec
= 1;
94 /* Asks for confirmation before deleting a file */
95 int confirm_delete
= 1;
96 /* Asks for confirmation before deleting a hotlist entry */
97 int confirm_directory_hotlist_delete
= 1;
98 /* Asks for confirmation before overwriting a file */
99 int confirm_overwrite
= 1;
100 /* Asks for confirmation before executing a program by pressing enter */
101 int confirm_execute
= 0;
102 /* Asks for confirmation before leaving the program */
103 int confirm_exit
= 0;
105 /* If true, at startup the user-menu is invoked */
107 /* This flag indicates if the pull down menus by default drop down */
110 /* Asks for confirmation when using F3 to view a directory and there
112 int confirm_view_dir
= 0;
114 /* Ask file name before start the editor */
115 int editor_ask_filename_before_edit
= 0;
117 panel_view_mode_t startup_left_mode
;
118 panel_view_mode_t startup_right_mode
;
120 int setup_copymove_persistent_attr
= 1;
123 int option_tab_spacing
= DEFAULT_TAB_SPACING
;
125 /* Ugly hack to allow panel_save_setup to work as a place holder for */
126 /* default panel values */
129 panels_options_t panels_options
= {
130 .show_mini_info
= TRUE
,
131 .kilobyte_si
= FALSE
,
132 .mix_all_files
= FALSE
,
133 .show_backups
= TRUE
,
134 .show_dot_files
= TRUE
,
135 .fast_reload
= FALSE
,
136 .fast_reload_msg_shown
= FALSE
,
137 .mark_moves_down
= TRUE
,
138 .reverse_files_only
= TRUE
,
139 .auto_save_setup
= FALSE
,
140 .navigate_with_arrows
= FALSE
,
141 .scroll_pages
= TRUE
,
142 .scroll_center
= FALSE
,
143 .mouse_move_pages
= TRUE
,
144 .filetype_mode
= TRUE
,
145 .permission_mode
= FALSE
,
146 .qsearch_mode
= QSEARCH_PANEL_CASE
,
147 .torben_fj_mode
= FALSE
,
148 .select_flags
= SELECT_MATCH_CASE
| SELECT_SHELL_PATTERNS
151 int easy_patterns
= 1;
153 /* It true saves the setup when quitting */
154 int auto_save_setup
= 1;
156 /* If true, then the +, - and \ keys have their special meaning only if the
157 * command line is emtpy, otherwise they behave like regular letters
159 int only_leading_plus_minus
= 1;
161 /* Automatically fills name with current selected item name on mkdir */
162 int auto_fill_mkdir_name
= 1;
164 /* If set and you don't have subshell support,then C-o will give you a shell */
165 int output_starts_shell
= 0;
167 /* If set, we execute the file command to check the file type */
168 int use_file_to_check_type
= 1;
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
177 int file_op_compute_totals
= 1;
179 /* If true use the internal viewer */
180 int use_internal_view
= 1;
181 /* If set, use the builtin editor */
182 int use_internal_edit
= 1;
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 /* !HAVE_CHARSET */
192 char *spell_language
= NULL
;
195 /* Value of "other_dir" key in ini file */
196 char *saved_other_dir
= NULL
;
198 /* If set, then print to the given file the last directory we were at */
199 char *last_wd_string
= NULL
;
201 /* Set when main loop should be terminated */
204 /* Set to TRUE to suppress printing the last directory */
205 int print_last_revert
= FALSE
;
207 #ifdef USE_INTERNAL_EDIT
208 /* index to record_macro_buf[], -1 if not recording a macro */
209 int macro_index
= -1;
212 struct macro_action_t record_macro_buf
[MAX_MACRO_LENGTH
];
215 #endif /* USE_INTERNAL_EDIT */
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 *profile_name
= NULL
; /* ${XDG_CONFIG_HOME}/mc/ini */
228 static char *panels_profile_name
= NULL
; /* ${XDG_CACHE_HOME}/mc/panels.ini */
236 { "full", list_full
},
237 { "brief", list_brief
},
238 { "long", list_long
},
239 { "user", list_user
},
245 const char *opt_name
;
246 panel_view_mode_t opt_type
;
248 { "listing", view_listing
},
249 { "quickview", view_quick
},
250 { "info", view_info
},
251 { "tree", view_tree
},
252 { NULL
, view_listing
}
257 const char *opt_name
;
260 { "message_visible", &mc_global
.message_visible
},
261 { "keybar_visible", &mc_global
.keybar_visible
},
262 { "xterm_title", &xterm_title
},
263 { "output_lines", &output_lines
},
264 { "command_prompt", &command_prompt
},
265 { "menubar_visible", &menubar_visible
},
266 { "free_space", &free_space
},
267 { "horizontal_split", &panels_layout
.horizontal_split
},
268 { "vertical_equal", &panels_layout
.vertical_equal
},
269 { "left_panel_size", &panels_layout
.left_panel_size
},
270 { "horizontal_equal", &panels_layout
.horizontal_equal
},
271 { "top_panel_size", &panels_layout
.top_panel_size
},
277 const char *opt_name
;
280 { "verbose", &verbose
},
281 { "pause_after_run", &pause_after_run
},
282 { "shell_patterns", &easy_patterns
},
283 { "auto_save_setup", &auto_save_setup
},
284 { "preallocate_space", &mc_global
.vfs
.preallocate_space
},
285 { "auto_menu", &auto_menu
},
286 { "use_internal_view", &use_internal_view
},
287 { "use_internal_edit", &use_internal_edit
},
288 { "clear_before_exec", &clear_before_exec
},
289 { "confirm_delete", &confirm_delete
},
290 { "confirm_overwrite", &confirm_overwrite
},
291 { "confirm_execute", &confirm_execute
},
292 { "confirm_history_cleanup", &mc_global
.widget
.confirm_history_cleanup
},
293 { "confirm_exit", &confirm_exit
},
294 { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete
},
295 { "safe_delete", &safe_delete
},
296 { "mouse_repeat_rate", &mou_auto_repeat
},
297 { "double_click_speed", &double_click_speed
},
299 { "eight_bit_clean", &mc_global
.eight_bit_clean
},
300 { "full_eight_bits", &mc_global
.full_eight_bits
},
301 #endif /* !HAVE_CHARSET */
302 { "use_8th_bit_as_meta", &use_8th_bit_as_meta
},
303 { "confirm_view_dir", &confirm_view_dir
},
304 { "mouse_move_pages_viewer", &mcview_mouse_move_pages
},
305 { "mouse_close_dialog", &mouse_close_dialog
},
306 { "fast_refresh", &fast_refresh
},
307 { "drop_menus", &drop_menus
},
308 { "wrap_mode", &mcview_global_wrap_mode
},
309 { "old_esc_mode", &old_esc_mode
},
310 { "old_esc_mode_timeout", &old_esc_mode_timeout
},
311 { "cd_symlinks", &mc_global
.vfs
.cd_symlinks
},
312 { "show_all_if_ambiguous", &mc_global
.widget
.show_all_if_ambiguous
},
313 { "max_dirt_limit", &mcview_max_dirt_limit
},
314 { "use_file_to_guess_type", &use_file_to_check_type
},
315 { "alternate_plus_minus", &mc_global
.tty
.alternate_plus_minus
},
316 { "only_leading_plus_minus", &only_leading_plus_minus
},
317 { "show_output_starts_shell", &output_starts_shell
},
318 { "xtree_mode", &xtree_mode
},
319 { "num_history_items_recorded", &num_history_items_recorded
},
320 { "file_op_compute_totals", &file_op_compute_totals
},
321 { "classic_progressbar", &classic_progressbar
},
323 { "vfs_timeout", &vfs_timeout
},
324 #ifdef ENABLE_VFS_FTP
325 { "ftpfs_directory_timeout", &ftpfs_directory_timeout
},
326 { "use_netrc", &ftpfs_use_netrc
},
327 { "ftpfs_retry_seconds", &ftpfs_retry_seconds
},
328 { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy
},
329 { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections
},
330 { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy
},
331 { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options
},
332 { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls
},
333 #endif /* ENABLE_VFS_FTP */
334 #ifdef ENABLE_VFS_FISH
335 { "fish_directory_timeout", &fish_directory_timeout
},
336 #endif /* ENABLE_VFS_FISH */
337 #endif /* ENABLE_VFS */
338 /* option_tab_spacing is used in internal viewer */
339 { "editor_tab_spacing", &option_tab_spacing
},
340 #ifdef USE_INTERNAL_EDIT
341 { "editor_word_wrap_line_length", &option_word_wrap_line_length
},
342 { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces
},
343 { "editor_return_does_auto_indent", &option_return_does_auto_indent
},
344 { "editor_backspace_through_tabs", &option_backspace_through_tabs
},
345 { "editor_fake_half_tabs", &option_fake_half_tabs
},
346 { "editor_option_save_mode", &option_save_mode
},
347 { "editor_option_save_position", &option_save_position
},
348 { "editor_option_auto_para_formatting", &option_auto_para_formatting
},
349 { "editor_option_typewriter_wrap", &option_typewriter_wrap
},
350 { "editor_edit_confirm_save", &edit_confirm_save
},
351 { "editor_syntax_highlighting", &option_syntax_highlighting
},
352 { "editor_persistent_selections", &option_persistent_selections
},
353 { "editor_drop_selection_on_copy", &option_drop_selection_on_copy
},
354 { "editor_cursor_beyond_eol", &option_cursor_beyond_eol
},
355 { "editor_cursor_after_inserted_block", &option_cursor_after_inserted_block
},
356 { "editor_visible_tabs", &visible_tabs
},
357 { "editor_visible_spaces", &visible_tws
},
358 { "editor_line_state", &option_line_state
},
359 { "editor_simple_statusbar", &simple_statusbar
},
360 { "editor_check_new_line", &option_check_nl_at_eof
},
361 { "editor_show_right_margin", &show_right_margin
},
362 { "editor_group_undo", &option_group_undo
},
363 { "editor_state_full_filename", &option_state_full_filename
},
364 #endif /* USE_INTERNAL_EDIT */
365 { "editor_ask_filename_before_edit", &editor_ask_filename_before_edit
},
366 { "nice_rotating_dash", &nice_rotating_dash
},
367 { "mcview_remember_file_position", &mcview_remember_file_position
},
368 { "auto_fill_mkdir_name", &auto_fill_mkdir_name
},
369 { "copymove_persistent_attr", &setup_copymove_persistent_attr
},
375 const char *opt_name
;
377 const char *opt_defval
;
379 #ifdef USE_INTERNAL_EDIT
380 { "editor_backup_extension", &option_backup_ext
, "~" },
381 { "editor_filesize_threshold", &option_filesize_threshold
, "64M" },
382 { "editor_stop_format_chars", &option_stop_format_chars
, "-+*\\,.;:&>" },
384 { "mcview_eof", &mcview_show_eof
, "" },
390 const char *opt_name
;
392 } panels_ini_options
[] = {
393 { "show_mini_info", &panels_options
.show_mini_info
},
394 { "kilobyte_si", &panels_options
.kilobyte_si
},
395 { "mix_all_files", &panels_options
.mix_all_files
},
396 { "show_backups", &panels_options
.show_backups
},
397 { "show_dot_files", &panels_options
.show_dot_files
},
398 { "fast_reload", &panels_options
.fast_reload
},
399 { "fast_reload_msg_shown", &panels_options
.fast_reload_msg_shown
},
400 { "mark_moves_down", &panels_options
.mark_moves_down
},
401 { "reverse_files_only", &panels_options
.reverse_files_only
},
402 { "auto_save_setup_panels", &panels_options
.auto_save_setup
},
403 { "navigate_with_arrows", &panels_options
.navigate_with_arrows
},
404 { "panel_scroll_pages", &panels_options
.scroll_pages
},
405 { "panel_scroll_center", &panels_options
.scroll_center
},
406 { "mouse_move_pages", &panels_options
.mouse_move_pages
},
407 { "filetype_mode", &panels_options
.filetype_mode
},
408 { "permission_mode", &panels_options
.permission_mode
},
409 { "torben_fj_mode", &panels_options
.torben_fj_mode
},
414 /*** file scope functions ************************************************************************/
415 /* --------------------------------------------------------------------------------------------- */
418 * Get name of config file.
420 * @param subdir If not NULL, config is also searched in specified subdir.
421 * @param config_file_name If relative, file if searched in standard paths.
423 * @return newly allocated string with config name or NULL if file is not found.
427 load_setup_get_full_config_name (const char *subdir
, const char *config_file_name
)
430 TODO: IMHO, in future, this function shall be placed in mcconfig module.
432 char *lc_basename
, *ret
;
435 if (config_file_name
== NULL
)
438 /* check for .keymap suffix */
439 if (g_str_has_suffix (config_file_name
, ".keymap"))
440 file_name
= g_strdup (config_file_name
);
442 file_name
= g_strconcat (config_file_name
, ".keymap", (char *) NULL
);
444 canonicalize_pathname (file_name
);
446 if (g_path_is_absolute (file_name
))
449 lc_basename
= g_path_get_basename (file_name
);
452 if (lc_basename
== NULL
)
456 ret
= g_build_filename (mc_config_get_path (), subdir
, lc_basename
, (char *) NULL
);
458 ret
= g_build_filename (mc_config_get_path (), lc_basename
, (char *) NULL
);
460 if (exist_file (ret
))
462 g_free (lc_basename
);
463 canonicalize_pathname (ret
);
469 ret
= g_build_filename (mc_global
.sysconfig_dir
, subdir
, lc_basename
, (char *) NULL
);
471 ret
= g_build_filename (mc_global
.sysconfig_dir
, lc_basename
, (char *) NULL
);
473 if (exist_file (ret
))
475 g_free (lc_basename
);
476 canonicalize_pathname (ret
);
482 ret
= g_build_filename (mc_global
.share_data_dir
, subdir
, lc_basename
, (char *) NULL
);
484 ret
= g_build_filename (mc_global
.share_data_dir
, lc_basename
, (char *) NULL
);
486 g_free (lc_basename
);
488 if (exist_file (ret
))
490 canonicalize_pathname (ret
);
498 /* --------------------------------------------------------------------------------------------- */
501 setup__is_cfg_group_must_panel_config (const char *grp
)
503 return (!strcasecmp ("Dirs", grp
) ||
504 !strcasecmp ("Temporal:New Right Panel", grp
) ||
505 !strcasecmp ("Temporal:New Left Panel", grp
) ||
506 !strcasecmp ("New Left Panel", grp
) || !strcasecmp ("New Right Panel", grp
))
510 /* --------------------------------------------------------------------------------------------- */
513 setup__move_panels_config_into_separate_file (const char *profile
)
515 mc_config_t
*tmp_cfg
;
516 char **groups
, **curr_grp
;
518 if (!exist_file (profile
))
521 tmp_cfg
= mc_config_init (profile
, FALSE
);
525 groups
= mc_config_get_groups (tmp_cfg
, NULL
);
529 mc_config_deinit (tmp_cfg
);
533 for (curr_grp
= groups
; *curr_grp
!= NULL
; curr_grp
++)
534 if (setup__is_cfg_group_must_panel_config (*curr_grp
) == NULL
)
535 mc_config_del_group (tmp_cfg
, *curr_grp
);
537 mc_config_save_to_file (tmp_cfg
, panels_profile_name
, NULL
);
538 mc_config_deinit (tmp_cfg
);
540 tmp_cfg
= mc_config_init (profile
, FALSE
);
547 for (curr_grp
= groups
; *curr_grp
!= NULL
; curr_grp
++)
549 const char *need_grp
;
551 need_grp
= setup__is_cfg_group_must_panel_config (*curr_grp
);
552 if (need_grp
!= NULL
)
553 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_global
.main_config
, CONFIG_APP_SECTION
,
593 "horizontal_split", 0);
594 equal_split
= mc_config_get_int (mc_global
.main_config
, "Layout", "equal_split", 1);
595 first_panel_size
= mc_config_get_int (mc_global
.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_global
.main_config
, CONFIG_LAYOUT_SECTION
,
610 layout
[i
].opt_name
, *layout
[i
].opt_addr
);
612 /* remove legacy options */
613 mc_config_del_key (mc_global
.main_config
, CONFIG_APP_SECTION
, "horizontal_split");
614 mc_config_del_key (mc_global
.main_config
, "Layout", "equal_split");
615 mc_config_del_key (mc_global
.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 char *valcopy
, *value
;
628 if (terminal
== NULL
)
631 section_name
= g_strconcat ("terminal:", terminal
, (char *) NULL
);
632 keys
= mc_config_get_keys (cfg
, section_name
, NULL
);
634 for (profile_keys
= keys
; *profile_keys
!= NULL
; profile_keys
++)
636 /* copy=other causes all keys from [terminal:other] to be loaded. */
637 if (g_ascii_strcasecmp (*profile_keys
, "copy") == 0)
639 valcopy
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
640 load_keys_from_section (valcopy
, cfg
);
645 key_code
= lookup_key (*profile_keys
, NULL
);
650 values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, NULL
);
655 for (curr_values
= values
; *curr_values
!= NULL
; curr_values
++)
657 valcopy
= convert_controls (*curr_values
);
658 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
666 value
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
667 valcopy
= convert_controls (value
);
668 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
;
685 if (section_name
== NULL
)
688 keys
= mc_config_get_keys (cfg
, section_name
, NULL
);
690 for (profile_keys
= keys
; *profile_keys
!= NULL
; profile_keys
++)
694 values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, NULL
);
699 action
= keybind_lookup_action (*profile_keys
);
704 for (curr_values
= values
; *curr_values
!= NULL
; curr_values
++)
705 keybind_cmd_bind (keymap
, *curr_values
, action
);
715 /* --------------------------------------------------------------------------------------------- */
718 load_setup_get_keymap_profile_config (gboolean load_from_file
)
721 TODO: IMHO, in future, this function shall be placed in mcconfig module.
723 mc_config_t
*keymap_config
;
724 char *share_keymap
, *sysconfig_keymap
;
725 char *fname
, *fname2
;
727 /* 0) Create default keymap */
728 keymap_config
= create_default_keymap ();
730 return keymap_config
;
732 /* load and merge global keymaps */
734 /* 1) /usr/share/mc (mc_global.share_data_dir) */
735 share_keymap
= g_build_filename (mc_global
.share_data_dir
, GLOBAL_KEYMAP_FILE
, (char *) NULL
);
736 load_setup_init_config_from_file (&keymap_config
, share_keymap
, TRUE
);
738 /* 2) /etc/mc (mc_global.sysconfig_dir) */
740 g_build_filename (mc_global
.sysconfig_dir
, GLOBAL_KEYMAP_FILE
, (char *) NULL
);
741 load_setup_init_config_from_file (&keymap_config
, sysconfig_keymap
, TRUE
);
743 /* then load and merge one of user-defined keymap */
745 /* 3) --keymap=<keymap> */
746 fname
= load_setup_get_full_config_name (NULL
, mc_args__keymap_file
);
747 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
749 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
754 /* 4) getenv("MC_KEYMAP") */
755 fname
= load_setup_get_full_config_name (NULL
, g_getenv ("MC_KEYMAP"));
756 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
758 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
763 /* 5) main config; [Midnight Commander] -> keymap */
764 fname2
= mc_config_get_string (mc_global
.main_config
, CONFIG_APP_SECTION
, "keymap", NULL
);
765 if (fname2
!= NULL
&& *fname2
!= '\0')
766 fname
= load_setup_get_full_config_name (NULL
, fname2
);
768 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
770 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
775 /* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
776 fname
= mc_config_get_full_path (GLOBAL_KEYMAP_FILE
);
777 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
781 g_free (sysconfig_keymap
);
782 g_free (share_keymap
);
784 return keymap_config
;
787 /* --------------------------------------------------------------------------------------------- */
789 static panel_view_mode_t
790 setup__load_panel_state (const char *section
)
794 panel_view_mode_t mode
= view_listing
;
796 /* Load the display mode */
797 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "display", "listing");
799 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
800 if (g_ascii_strcasecmp (panel_types
[i
].opt_name
, buffer
) == 0)
802 mode
= panel_types
[i
].opt_type
;
811 /* --------------------------------------------------------------------------------------------- */
814 panel_save_type (const char *section
, panel_view_mode_t type
)
818 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
819 if (panel_types
[i
].opt_type
== type
)
821 mc_config_set_string (mc_global
.panels_config
, section
, "display",
822 panel_types
[i
].opt_name
);
827 /* --------------------------------------------------------------------------------------------- */
830 * Load panels options from [Panels] section.
833 panels_load_options (void)
835 if (mc_config_has_group (mc_global
.main_config
, CONFIG_PANELS_SECTION
))
840 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
841 *panels_ini_options
[i
].opt_addr
=
842 mc_config_get_bool (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
843 panels_ini_options
[i
].opt_name
,
844 *panels_ini_options
[i
].opt_addr
);
846 qmode
= mc_config_get_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
847 "quick_search_mode", (int) panels_options
.qsearch_mode
);
849 panels_options
.qsearch_mode
= QSEARCH_CASE_INSENSITIVE
;
850 else if (qmode
>= QSEARCH_NUM
)
851 panels_options
.qsearch_mode
= QSEARCH_PANEL_CASE
;
853 panels_options
.qsearch_mode
= (qsearch_mode_t
) qmode
;
855 panels_options
.select_flags
=
856 mc_config_get_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
, "select_flags",
857 (int) panels_options
.select_flags
);
861 /* --------------------------------------------------------------------------------------------- */
864 * Save panels options in [Panels] section.
867 panels_save_options (void)
871 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
872 mc_config_set_bool (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
873 panels_ini_options
[i
].opt_name
, *panels_ini_options
[i
].opt_addr
);
875 mc_config_set_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
876 "quick_search_mode", (int) panels_options
.qsearch_mode
);
877 mc_config_set_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
878 "select_flags", (int) panels_options
.select_flags
);
881 /* --------------------------------------------------------------------------------------------- */
888 /* Save integer options */
889 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
890 mc_config_set_int (mc_global
.main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
891 *int_options
[i
].opt_addr
);
893 /* Save string options */
894 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
895 mc_config_set_string (mc_global
.main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
,
896 *str_options
[i
].opt_addr
);
899 /* --------------------------------------------------------------------------------------------- */
906 /* Save integer options */
907 for (i
= 0; layout
[i
].opt_name
!= NULL
; i
++)
908 mc_config_set_int (mc_global
.main_config
, CONFIG_LAYOUT_SECTION
, layout
[i
].opt_name
,
909 *layout
[i
].opt_addr
);
912 /* --------------------------------------------------------------------------------------------- */
914 /* save panels.ini */
916 save_panel_types (void)
918 panel_view_mode_t type
;
920 if (mc_global
.mc_run_mode
!= MC_RUN_FULL
)
923 type
= get_display_type (0);
924 panel_save_type ("New Left Panel", type
);
925 if (type
== view_listing
)
926 panel_save_setup (left_panel
, left_panel
->panel_name
);
927 type
= get_display_type (1);
928 panel_save_type ("New Right Panel", type
);
929 if (type
== view_listing
)
930 panel_save_setup (right_panel
, right_panel
->panel_name
);
935 dirs
= get_panel_dir_for (other_panel
);
936 mc_config_set_string (mc_global
.panels_config
, "Dirs", "other_dir", dirs
);
940 if (current_panel
!= NULL
)
941 mc_config_set_bool (mc_global
.panels_config
, "Dirs", "current_is_left",
942 get_current_index () == 0);
944 if (mc_global
.panels_config
->ini_path
== NULL
)
945 mc_global
.panels_config
->ini_path
= g_strdup (panels_profile_name
);
947 mc_config_del_group (mc_global
.panels_config
, "Temporal:New Left Panel");
948 mc_config_del_group (mc_global
.panels_config
, "Temporal:New Right Panel");
950 mc_config_save_file (mc_global
.panels_config
, NULL
);
953 /* --------------------------------------------------------------------------------------------- */
954 /*** public functions ****************************************************************************/
955 /* --------------------------------------------------------------------------------------------- */
960 if (profile_name
== NULL
)
964 profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
965 if (!exist_file (profile
))
969 inifile
= mc_build_filename (mc_global
.sysconfig_dir
, "mc.ini", (char *) NULL
);
970 if (exist_file (inifile
))
978 inifile
= mc_build_filename (mc_global
.share_data_dir
, "mc.ini", (char *) NULL
);
979 if (!exist_file (inifile
))
989 profile_name
= profile
;
995 /* --------------------------------------------------------------------------------------------- */
1000 const char *profile
;
1006 const char *cbuffer
;
1008 load_codepages_list ();
1009 #endif /* HAVE_CHARSET */
1011 profile
= setup_init ();
1013 /* mc.lib is common for all users, but has priority lower than
1014 ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */
1015 global_profile_name
=
1016 g_build_filename (mc_global
.sysconfig_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
1017 if (!exist_file (global_profile_name
))
1019 g_free (global_profile_name
);
1020 global_profile_name
=
1021 g_build_filename (mc_global
.share_data_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
1024 panels_profile_name
= mc_config_get_full_path (MC_PANELS_FILE
);
1026 mc_global
.main_config
= mc_config_init (profile
, FALSE
);
1028 if (!exist_file (panels_profile_name
))
1029 setup__move_panels_config_into_separate_file (profile
);
1031 mc_global
.panels_config
= mc_config_init (panels_profile_name
, FALSE
);
1033 /* Load integer boolean options */
1034 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
1035 *int_options
[i
].opt_addr
=
1036 mc_config_get_int (mc_global
.main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
1037 *int_options
[i
].opt_addr
);
1038 #ifndef USE_INTERNAL_EDIT
1039 /* reset forced in case of build without internal editor */
1040 use_internal_edit
= 0;
1041 #endif /* USE_INTERNAL_EDIT */
1043 if (option_tab_spacing
<= 0)
1044 option_tab_spacing
= DEFAULT_TAB_SPACING
;
1046 #ifdef USE_INTERNAL_EDIT
1047 if (option_word_wrap_line_length
<= 0)
1048 option_word_wrap_line_length
= DEFAULT_WRAP_LINE_LENGTH
;
1049 #endif /* USE_INTERNAL_EDIT */
1051 /* overwrite old_esc_mode_timeout */
1052 kt
= getenv ("KEYBOARD_KEY_TIMEOUT_US");
1053 if ((kt
!= NULL
) && (kt
[0] != '\0'))
1054 old_esc_mode_timeout
= atoi (kt
);
1056 /* Load string options */
1057 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1058 *str_options
[i
].opt_addr
=
1059 mc_config_get_string (mc_global
.main_config
, CONFIG_APP_SECTION
,
1060 str_options
[i
].opt_name
, str_options
[i
].opt_defval
);
1063 panels_load_options ();
1066 startup_left_mode
= setup__load_panel_state ("New Left Panel");
1067 startup_right_mode
= setup__load_panel_state ("New Right Panel");
1069 /* At least one of the panels is a listing panel */
1070 if (startup_left_mode
!= view_listing
&& startup_right_mode
!= view_listing
)
1071 startup_left_mode
= view_listing
;
1073 boot_current_is_left
=
1074 mc_config_get_bool (mc_global
.panels_config
, "Dirs", "current_is_left", TRUE
);
1076 /* Load time formats */
1077 user_recent_timeformat
=
1078 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "timeformat_recent",
1080 user_old_timeformat
=
1081 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "timeformat_old",
1084 #ifdef ENABLE_VFS_FTP
1086 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host", "gate");
1087 ftpfs_ignore_chattr_errors
=
1088 mc_config_get_bool (mc_global
.main_config
, CONFIG_APP_SECTION
, "ignore_ftp_chattr_errors",
1090 ftpfs_init_passwd ();
1091 #endif /* ENABLE_VFS_FTP */
1093 /* The default color and the terminal dependent color */
1094 mc_global
.tty
.setup_color_string
=
1095 mc_config_get_string (mc_global
.main_config
, "Colors", "base_color", "");
1096 mc_global
.tty
.term_color_string
=
1097 mc_config_get_string (mc_global
.main_config
, "Colors", getenv ("TERM"), "");
1098 mc_global
.tty
.color_terminal_string
=
1099 mc_config_get_string (mc_global
.main_config
, "Colors", "color_terminals", "");
1101 /* Load the directory history */
1102 /* directory_history_load (); */
1103 /* Remove the temporal entries */
1106 if (codepages
->len
> 1)
1109 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "display_codepage",
1111 if (buffer
[0] != '\0')
1113 mc_global
.display_codepage
= get_codepage_index (buffer
);
1114 cp_display
= get_codepage_id (mc_global
.display_codepage
);
1118 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "source_codepage",
1120 if (buffer
[0] != '\0')
1122 default_source_codepage
= get_codepage_index (buffer
);
1123 mc_global
.source_codepage
= default_source_codepage
; /* May be source_codepage doesn't need this */
1124 cp_source
= get_codepage_id (mc_global
.source_codepage
);
1129 autodetect_codeset
=
1130 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset", "");
1131 if ((autodetect_codeset
[0] != '\0') && (strcmp (autodetect_codeset
, "off") != 0))
1132 is_autodetect_codeset_enabled
= TRUE
;
1134 g_free (init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
));
1135 cbuffer
= get_codepage_id (mc_global
.display_codepage
);
1136 if (cbuffer
!= NULL
)
1137 mc_global
.utf8_display
= str_isutf8 (cbuffer
);
1138 #endif /* HAVE_CHARSET */
1142 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "spell_language", "en");
1143 #endif /* HAVE_ASPELL */
1145 clipboard_store_path
=
1146 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_store", "");
1147 clipboard_paste_path
=
1148 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_paste", "");
1151 /* --------------------------------------------------------------------------------------------- */
1154 save_setup (gboolean save_options
, gboolean save_panel_options
)
1156 gboolean ret
= TRUE
;
1162 if (save_panel_options
)
1163 save_panel_types ();
1171 panels_save_options ();
1173 /* directory_history_save (); */
1175 #ifdef ENABLE_VFS_FTP
1176 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftpfs_password",
1177 ftpfs_anonymous_passwd
);
1178 if (ftpfs_proxy_host
)
1179 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host",
1181 #endif /* ENABLE_VFS_FTP */
1184 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "display_codepage",
1185 get_codepage_id (mc_global
.display_codepage
));
1186 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "source_codepage",
1187 get_codepage_id (default_source_codepage
));
1188 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset",
1189 autodetect_codeset
);
1190 #endif /* HAVE_CHARSET */
1193 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "spell_language",
1195 #endif /* HAVE_ASPELL */
1197 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_store",
1198 clipboard_store_path
);
1199 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_paste",
1200 clipboard_paste_path
);
1202 tmp_profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
1203 ret
= mc_config_save_to_file (mc_global
.main_config
, tmp_profile
, NULL
);
1204 g_free (tmp_profile
);
1212 /* --------------------------------------------------------------------------------------------- */
1219 g_free (clipboard_store_path
);
1220 g_free (clipboard_paste_path
);
1221 g_free (global_profile_name
);
1222 g_free (mc_global
.tty
.color_terminal_string
);
1223 g_free (mc_global
.tty
.term_color_string
);
1224 g_free (mc_global
.tty
.setup_color_string
);
1225 g_free (profile_name
);
1226 g_free (panels_profile_name
);
1227 mc_config_deinit (mc_global
.main_config
);
1228 mc_config_deinit (mc_global
.panels_config
);
1230 g_free (user_recent_timeformat
);
1231 g_free (user_old_timeformat
);
1233 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1234 g_free (*str_options
[i
].opt_addr
);
1238 /* directory_history_free (); */
1241 g_free (autodetect_codeset
);
1242 free_codepages_list ();
1246 g_free (spell_language
);
1247 #endif /* HAVE_ASPELL */
1251 /* --------------------------------------------------------------------------------------------- */
1254 setup_save_config_show_error (const char *filename
, GError
** mcerror
)
1256 if (mcerror
!= NULL
&& *mcerror
!= NULL
)
1258 message (D_ERROR
, MSG_ERROR
, _("Cannot save file %s:\n%s"), filename
, (*mcerror
)->message
);
1259 g_error_free (*mcerror
);
1265 /* --------------------------------------------------------------------------------------------- */
1268 load_key_defs (void)
1271 * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1272 * definitions override global settings.
1274 mc_config_t
*mc_global_config
;
1276 mc_global_config
= mc_config_init (global_profile_name
, FALSE
);
1277 if (mc_global_config
!= NULL
)
1279 load_keys_from_section ("general", mc_global_config
);
1280 load_keys_from_section (getenv ("TERM"), mc_global_config
);
1281 mc_config_deinit (mc_global_config
);
1284 load_keys_from_section ("general", mc_global
.main_config
);
1285 load_keys_from_section (getenv ("TERM"), mc_global
.main_config
);
1288 /* --------------------------------------------------------------------------------------------- */
1290 #ifdef ENABLE_VFS_FTP
1292 load_anon_passwd (void)
1297 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftpfs_password", "");
1299 if ((buffer
!= NULL
) && (buffer
[0] != '\0'))
1305 #endif /* ENABLE_VFS_FTP */
1307 /* --------------------------------------------------------------------------------------------- */
1310 load_keymap_defs (gboolean load_from_file
)
1313 * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
1314 * definitions override global settings.
1316 mc_config_t
*mc_global_keymap
;
1318 mc_global_keymap
= load_setup_get_keymap_profile_config (load_from_file
);
1320 if (mc_global_keymap
!= NULL
)
1322 main_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1323 load_keymap_from_section (KEYMAP_SECTION_MAIN
, main_keymap
, mc_global_keymap
);
1324 main_x_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1325 load_keymap_from_section (KEYMAP_SECTION_MAIN_EXT
, main_x_keymap
, mc_global_keymap
);
1327 panel_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1328 load_keymap_from_section (KEYMAP_SECTION_PANEL
, panel_keymap
, mc_global_keymap
);
1330 dialog_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1331 load_keymap_from_section (KEYMAP_SECTION_DIALOG
, dialog_keymap
, mc_global_keymap
);
1333 input_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1334 load_keymap_from_section (KEYMAP_SECTION_INPUT
, input_keymap
, mc_global_keymap
);
1336 listbox_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1337 load_keymap_from_section (KEYMAP_SECTION_LISTBOX
, listbox_keymap
, mc_global_keymap
);
1339 tree_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1340 load_keymap_from_section (KEYMAP_SECTION_TREE
, tree_keymap
, mc_global_keymap
);
1342 help_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1343 load_keymap_from_section (KEYMAP_SECTION_HELP
, help_keymap
, mc_global_keymap
);
1345 #ifdef USE_INTERNAL_EDIT
1346 editor_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1347 load_keymap_from_section (KEYMAP_SECTION_EDITOR
, editor_keymap
, mc_global_keymap
);
1348 editor_x_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1349 load_keymap_from_section (KEYMAP_SECTION_EDITOR_EXT
, editor_x_keymap
, mc_global_keymap
);
1352 viewer_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1353 load_keymap_from_section (KEYMAP_SECTION_VIEWER
, viewer_keymap
, mc_global_keymap
);
1354 viewer_hex_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1355 load_keymap_from_section (KEYMAP_SECTION_VIEWER_HEX
, viewer_hex_keymap
, mc_global_keymap
);
1357 #ifdef USE_DIFF_VIEW
1358 diff_keymap
= g_array_new (TRUE
, FALSE
, sizeof (global_keymap_t
));
1359 load_keymap_from_section (KEYMAP_SECTION_DIFFVIEWER
, diff_keymap
, mc_global_keymap
);
1362 mc_config_deinit (mc_global_keymap
);
1365 main_map
= (global_keymap_t
*) main_keymap
->data
;
1366 main_x_map
= (global_keymap_t
*) main_x_keymap
->data
;
1367 panel_map
= (global_keymap_t
*) panel_keymap
->data
;
1368 dialog_map
= (global_keymap_t
*) dialog_keymap
->data
;
1369 input_map
= (global_keymap_t
*) input_keymap
->data
;
1370 listbox_map
= (global_keymap_t
*) listbox_keymap
->data
;
1371 tree_map
= (global_keymap_t
*) tree_keymap
->data
;
1372 help_map
= (global_keymap_t
*) help_keymap
->data
;
1373 #ifdef USE_INTERNAL_EDIT
1374 editor_map
= (global_keymap_t
*) editor_keymap
->data
;
1375 editor_x_map
= (global_keymap_t
*) editor_x_keymap
->data
;
1377 viewer_map
= (global_keymap_t
*) viewer_keymap
->data
;
1378 viewer_hex_map
= (global_keymap_t
*) viewer_hex_keymap
->data
;
1379 #ifdef USE_DIFF_VIEW
1380 diff_map
= (global_keymap_t
*) diff_keymap
->data
;
1384 /* --------------------------------------------------------------------------------------------- */
1387 free_keymap_defs (void)
1389 if (main_keymap
!= NULL
)
1390 g_array_free (main_keymap
, TRUE
);
1391 if (main_x_keymap
!= NULL
)
1392 g_array_free (main_x_keymap
, TRUE
);
1393 if (panel_keymap
!= NULL
)
1394 g_array_free (panel_keymap
, TRUE
);
1395 if (dialog_keymap
!= NULL
)
1396 g_array_free (dialog_keymap
, TRUE
);
1397 if (input_keymap
!= NULL
)
1398 g_array_free (input_keymap
, TRUE
);
1399 if (listbox_keymap
!= NULL
)
1400 g_array_free (listbox_keymap
, TRUE
);
1401 if (tree_keymap
!= NULL
)
1402 g_array_free (tree_keymap
, TRUE
);
1403 if (help_keymap
!= NULL
)
1404 g_array_free (help_keymap
, TRUE
);
1405 #ifdef USE_INTERNAL_EDIT
1406 if (editor_keymap
!= NULL
)
1407 g_array_free (editor_keymap
, TRUE
);
1408 if (editor_x_keymap
!= NULL
)
1409 g_array_free (editor_x_keymap
, TRUE
);
1411 if (viewer_keymap
!= NULL
)
1412 g_array_free (viewer_keymap
, TRUE
);
1413 if (viewer_hex_keymap
!= NULL
)
1414 g_array_free (viewer_hex_keymap
, TRUE
);
1415 #ifdef USE_DIFF_VIEW
1416 if (diff_keymap
!= NULL
)
1417 g_array_free (diff_keymap
, TRUE
);
1421 /* --------------------------------------------------------------------------------------------- */
1424 panel_load_setup (WPanel
* panel
, const char *section
)
1427 char *buffer
, buffer2
[BUF_TINY
];
1429 panel
->sort_info
.reverse
= mc_config_get_int (mc_global
.panels_config
, section
, "reverse", 0);
1430 panel
->sort_info
.case_sensitive
=
1431 mc_config_get_int (mc_global
.panels_config
, section
, "case_sensitive",
1432 OS_SORT_CASE_SENSITIVE_DEFAULT
);
1433 panel
->sort_info
.exec_first
=
1434 mc_config_get_int (mc_global
.panels_config
, section
, "exec_first", 0);
1436 /* Load sort order */
1437 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "sort_order", "name");
1438 panel
->sort_field
= panel_get_field_by_id (buffer
);
1439 if (panel
->sort_field
== NULL
)
1440 panel
->sort_field
= panel_get_field_by_id ("name");
1444 /* Load the listing mode */
1445 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "list_mode", "full");
1446 panel
->list_type
= list_full
;
1447 for (i
= 0; list_types
[i
].key
!= NULL
; i
++)
1448 if (g_ascii_strcasecmp (list_types
[i
].key
, buffer
) == 0)
1450 panel
->list_type
= list_types
[i
].list_type
;
1455 panel
->brief_cols
= mc_config_get_int (mc_global
.panels_config
, section
, "brief_cols", 2);
1458 g_free (panel
->user_format
);
1459 panel
->user_format
=
1460 mc_config_get_string (mc_global
.panels_config
, section
, "user_format", DEFAULT_USER_FORMAT
);
1462 for (i
= 0; i
< LIST_TYPES
; i
++)
1464 g_free (panel
->user_status_format
[i
]);
1465 g_snprintf (buffer2
, sizeof (buffer2
), "user_status%lld", (long long) i
);
1466 panel
->user_status_format
[i
] =
1467 mc_config_get_string (mc_global
.panels_config
, section
, buffer2
, DEFAULT_USER_FORMAT
);
1470 panel
->user_mini_status
=
1471 mc_config_get_int (mc_global
.panels_config
, section
, "user_mini_status", 0);
1474 /* --------------------------------------------------------------------------------------------- */
1477 panel_save_setup (WPanel
* panel
, const char *section
)
1479 char buffer
[BUF_TINY
];
1482 mc_config_set_int (mc_global
.panels_config
, section
, "reverse", panel
->sort_info
.reverse
);
1483 mc_config_set_int (mc_global
.panels_config
, section
, "case_sensitive",
1484 panel
->sort_info
.case_sensitive
);
1485 mc_config_set_int (mc_global
.panels_config
, section
, "exec_first", panel
->sort_info
.exec_first
);
1487 mc_config_set_string (mc_global
.panels_config
, section
, "sort_order", panel
->sort_field
->id
);
1489 for (i
= 0; list_types
[i
].key
!= NULL
; i
++)
1490 if (list_types
[i
].list_type
== (int) panel
->list_type
)
1492 mc_config_set_string (mc_global
.panels_config
, section
, "list_mode", list_types
[i
].key
);
1496 mc_config_set_int (mc_global
.panels_config
, section
, "brief_cols", panel
->brief_cols
);
1498 mc_config_set_string (mc_global
.panels_config
, section
, "user_format", panel
->user_format
);
1500 for (i
= 0; i
< LIST_TYPES
; i
++)
1502 g_snprintf (buffer
, sizeof (buffer
), "user_status%lld", (long long) i
);
1503 mc_config_set_string (mc_global
.panels_config
, section
, buffer
,
1504 panel
->user_status_format
[i
]);
1507 mc_config_set_int (mc_global
.panels_config
, section
, "user_mini_status",
1508 panel
->user_mini_status
);
1512 /* --------------------------------------------------------------------------------------------- */