4 Copyright (C) 1994-2020
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" /* num_history_items_recorded */
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/filemanager.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 */
89 gboolean safe_delete
= FALSE
;
90 /* If on, default for "No" in overwrite files */
91 gboolean safe_overwrite
= FALSE
;
93 /* Controls screen clearing before an exec */
94 gboolean clear_before_exec
= TRUE
;
96 /* Asks for confirmation before deleting a file */
97 gboolean confirm_delete
= TRUE
;
98 /* Asks for confirmation before deleting a hotlist entry */
99 gboolean confirm_directory_hotlist_delete
= FALSE
;
100 /* Asks for confirmation before overwriting a file */
101 gboolean confirm_overwrite
= TRUE
;
102 /* Asks for confirmation before executing a program by pressing enter */
103 gboolean confirm_execute
= FALSE
;
104 /* Asks for confirmation before leaving the program */
105 gboolean confirm_exit
= FALSE
;
107 /* If true, at startup the user-menu is invoked */
108 gboolean auto_menu
= FALSE
;
109 /* This flag indicates if the pull down menus by default drop down */
110 gboolean drop_menus
= FALSE
;
112 /* Asks for confirmation when using F3 to view a directory and there
114 gboolean confirm_view_dir
= FALSE
;
116 /* Ask file name before start the editor */
117 gboolean editor_ask_filename_before_edit
= FALSE
;
119 panel_view_mode_t startup_left_mode
;
120 panel_view_mode_t startup_right_mode
;
122 gboolean copymove_persistent_attr
= TRUE
;
125 int option_tab_spacing
= DEFAULT_TAB_SPACING
;
127 /* Ugly hack to allow panel_save_setup to work as a place holder for */
128 /* default panel values */
131 panels_options_t panels_options
= {
132 .show_mini_info
= TRUE
,
133 .kilobyte_si
= FALSE
,
134 .mix_all_files
= FALSE
,
135 .show_backups
= TRUE
,
136 .show_dot_files
= TRUE
,
137 .fast_reload
= FALSE
,
138 .fast_reload_msg_shown
= FALSE
,
139 .mark_moves_down
= TRUE
,
140 .reverse_files_only
= TRUE
,
141 .auto_save_setup
= FALSE
,
142 .navigate_with_arrows
= FALSE
,
143 .scroll_pages
= TRUE
,
144 .scroll_center
= FALSE
,
145 .mouse_move_pages
= TRUE
,
146 .filetype_mode
= TRUE
,
147 .permission_mode
= FALSE
,
148 .qsearch_mode
= QSEARCH_PANEL_CASE
,
149 .torben_fj_mode
= FALSE
,
150 .select_flags
= SELECT_MATCH_CASE
| SELECT_SHELL_PATTERNS
153 gboolean easy_patterns
= TRUE
;
155 /* It true saves the setup when quitting */
156 gboolean auto_save_setup
= TRUE
;
158 /* If true, then the +, - and \ keys have their special meaning only if the
159 * command line is empty, otherwise they behave like regular letters
161 gboolean only_leading_plus_minus
= TRUE
;
163 /* Automatically fills name with current selected item name on mkdir */
164 gboolean auto_fill_mkdir_name
= TRUE
;
166 /* If set and you don't have subshell support, then C-o will give you a shell */
167 gboolean output_starts_shell
= FALSE
;
169 /* If set, we execute the file command to check the file type */
170 gboolean use_file_to_check_type
= TRUE
;
172 gboolean verbose
= TRUE
;
175 * Whether the Midnight Commander tries to provide more
176 * information about copy/move sizes and bytes transferred
177 * at the expense of some speed
179 gboolean file_op_compute_totals
= TRUE
;
181 /* If true use the internal viewer */
182 gboolean use_internal_view
= TRUE
;
183 /* If set, use the builtin editor */
184 gboolean use_internal_edit
= TRUE
;
187 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
188 int default_source_codepage
= -1;
189 char *autodetect_codeset
= NULL
;
190 gboolean is_autodetect_codeset_enabled
= FALSE
;
191 #endif /* !HAVE_CHARSET */
194 char *spell_language
= NULL
;
197 /* Value of "other_dir" key in ini file */
198 char *saved_other_dir
= NULL
;
200 /* If set, then print to the given file the last directory we were at */
201 char *last_wd_string
= NULL
;
203 /* Set when main loop should be terminated */
206 /* Set to TRUE to suppress printing the last directory */
207 int print_last_revert
= FALSE
;
209 #ifdef USE_INTERNAL_EDIT
210 /* index to record_macro_buf[], -1 if not recording a macro */
211 int macro_index
= -1;
214 struct macro_action_t record_macro_buf
[MAX_MACRO_LENGTH
];
217 #endif /* USE_INTERNAL_EDIT */
219 /*** file scope macro definitions ****************************************************************/
221 /* In order to use everywhere the same setup for the locale we use defines */
222 #define FMTYEAR _("%b %e %Y")
223 #define FMTTIME _("%b %e %H:%M")
225 /*** file scope type declarations ****************************************************************/
227 /*** file scope variables ************************************************************************/
229 static char *profile_name
= NULL
; /* ${XDG_CONFIG_HOME}/mc/ini */
230 static char *panels_profile_name
= NULL
; /* ${XDG_CACHE_HOME}/mc/panels.ini */
237 } list_formats
[] = {
238 { "full", list_full
},
239 { "brief", list_brief
},
240 { "long", list_long
},
241 { "user", list_user
},
247 const char *opt_name
;
248 panel_view_mode_t opt_type
;
250 { "listing", view_listing
},
251 { "quickview", view_quick
},
252 { "info", view_info
},
253 { "tree", view_tree
},
254 { NULL
, view_listing
}
259 const char *opt_name
;
261 } layout_int_options
[] = {
262 { "output_lines", &output_lines
},
263 { "left_panel_size", &panels_layout
.left_panel_size
},
264 { "top_panel_size", &panels_layout
.top_panel_size
},
270 const char *opt_name
;
272 } layout_bool_options
[] = {
273 { "message_visible", &mc_global
.message_visible
},
274 { "keybar_visible", &mc_global
.keybar_visible
},
275 { "xterm_title", &xterm_title
},
276 { "command_prompt", &command_prompt
},
277 { "menubar_visible", &menubar_visible
},
278 { "free_space", &free_space
},
279 { "horizontal_split", &panels_layout
.horizontal_split
},
280 { "vertical_equal", &panels_layout
.vertical_equal
},
281 { "horizontal_equal", &panels_layout
.horizontal_equal
},
287 const char *opt_name
;
289 } bool_options
[] = {
290 { "verbose", &verbose
},
291 { "shell_patterns", &easy_patterns
},
292 { "auto_save_setup", &auto_save_setup
},
293 { "preallocate_space", &mc_global
.vfs
.preallocate_space
},
294 { "auto_menu", &auto_menu
},
295 { "use_internal_view", &use_internal_view
},
296 { "use_internal_edit", &use_internal_edit
},
297 { "clear_before_exec", &clear_before_exec
},
298 { "confirm_delete", &confirm_delete
},
299 { "confirm_overwrite", &confirm_overwrite
},
300 { "confirm_execute", &confirm_execute
},
301 { "confirm_history_cleanup", &mc_global
.widget
.confirm_history_cleanup
},
302 { "confirm_exit", &confirm_exit
},
303 { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete
},
304 { "confirm_view_dir", &confirm_view_dir
},
305 { "safe_delete", &safe_delete
},
306 { "safe_overwrite", &safe_overwrite
},
308 { "eight_bit_clean", &mc_global
.eight_bit_clean
},
309 { "full_eight_bits", &mc_global
.full_eight_bits
},
310 #endif /* !HAVE_CHARSET */
311 { "use_8th_bit_as_meta", &use_8th_bit_as_meta
},
312 { "mouse_move_pages_viewer", &mcview_mouse_move_pages
},
313 { "mouse_close_dialog", &mouse_close_dialog
},
314 { "fast_refresh", &fast_refresh
},
315 { "drop_menus", &drop_menus
},
316 { "wrap_mode", &mcview_global_flags
.wrap
},
317 { "old_esc_mode", &old_esc_mode
},
318 { "cd_symlinks", &mc_global
.vfs
.cd_symlinks
},
319 { "show_all_if_ambiguous", &mc_global
.widget
.show_all_if_ambiguous
},
320 { "use_file_to_guess_type", &use_file_to_check_type
},
321 { "alternate_plus_minus", &mc_global
.tty
.alternate_plus_minus
},
322 { "only_leading_plus_minus", &only_leading_plus_minus
},
323 { "show_output_starts_shell", &output_starts_shell
},
324 { "xtree_mode", &xtree_mode
},
325 { "file_op_compute_totals", &file_op_compute_totals
},
326 { "classic_progressbar", &classic_progressbar
},
328 #ifdef ENABLE_VFS_FTP
329 { "use_netrc", &ftpfs_use_netrc
},
330 { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy
},
331 { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections
},
332 { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy
},
333 { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options
},
334 { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls
},
335 { "ignore_ftp_chattr_errors", & ftpfs_ignore_chattr_errors
} ,
336 #endif /* ENABLE_VFS_FTP */
337 #endif /* ENABLE_VFS */
338 #ifdef USE_INTERNAL_EDIT
339 { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces
},
340 { "editor_return_does_auto_indent", &option_return_does_auto_indent
},
341 { "editor_backspace_through_tabs", &option_backspace_through_tabs
},
342 { "editor_fake_half_tabs", &option_fake_half_tabs
},
343 { "editor_option_save_position", &option_save_position
},
344 { "editor_option_auto_para_formatting", &option_auto_para_formatting
},
345 { "editor_option_typewriter_wrap", &option_typewriter_wrap
},
346 { "editor_edit_confirm_save", &edit_confirm_save
},
347 { "editor_syntax_highlighting", &option_syntax_highlighting
},
348 { "editor_persistent_selections", &option_persistent_selections
},
349 { "editor_drop_selection_on_copy", &option_drop_selection_on_copy
},
350 { "editor_cursor_beyond_eol", &option_cursor_beyond_eol
},
351 { "editor_cursor_after_inserted_block", &option_cursor_after_inserted_block
},
352 { "editor_visible_tabs", &visible_tabs
},
353 { "editor_visible_spaces", &visible_tws
},
354 { "editor_line_state", &option_line_state
},
355 { "editor_simple_statusbar", &simple_statusbar
},
356 { "editor_check_new_line", &option_check_nl_at_eof
},
357 { "editor_show_right_margin", &show_right_margin
},
358 { "editor_group_undo", &option_group_undo
},
359 { "editor_state_full_filename", &option_state_full_filename
},
360 #endif /* USE_INTERNAL_EDIT */
361 { "editor_ask_filename_before_edit", &editor_ask_filename_before_edit
},
362 { "nice_rotating_dash", &nice_rotating_dash
},
363 { "shadows", &mc_global
.tty
.shadows
},
364 { "mcview_remember_file_position", &mcview_remember_file_position
},
365 { "auto_fill_mkdir_name", &auto_fill_mkdir_name
},
366 { "copymove_persistent_attr", ©move_persistent_attr
},
372 const char *opt_name
;
375 { "pause_after_run", &pause_after_run
},
376 { "mouse_repeat_rate", &mou_auto_repeat
},
377 { "double_click_speed", &double_click_speed
},
378 { "old_esc_mode_timeout", &old_esc_mode_timeout
},
379 { "max_dirt_limit", &mcview_max_dirt_limit
},
380 { "num_history_items_recorded", &num_history_items_recorded
},
382 { "vfs_timeout", &vfs_timeout
},
383 #ifdef ENABLE_VFS_FTP
384 { "ftpfs_directory_timeout", &ftpfs_directory_timeout
},
385 { "ftpfs_retry_seconds", &ftpfs_retry_seconds
},
386 #endif /* ENABLE_VFS_FTP */
387 #ifdef ENABLE_VFS_FISH
388 { "fish_directory_timeout", &fish_directory_timeout
},
389 #endif /* ENABLE_VFS_FISH */
390 #endif /* ENABLE_VFS */
391 /* option_tab_spacing is used in internal viewer */
392 { "editor_tab_spacing", &option_tab_spacing
},
393 #ifdef USE_INTERNAL_EDIT
394 { "editor_word_wrap_line_length", &option_word_wrap_line_length
},
395 { "editor_option_save_mode", &option_save_mode
},
396 #endif /* USE_INTERNAL_EDIT */
402 const char *opt_name
;
404 const char *opt_defval
;
406 #ifdef USE_INTERNAL_EDIT
407 { "editor_backup_extension", &option_backup_ext
, "~" },
408 { "editor_filesize_threshold", &option_filesize_threshold
, "64M" },
409 { "editor_stop_format_chars", &option_stop_format_chars
, "-+*\\,.;:&>" },
411 { "mcview_eof", &mcview_show_eof
, "" },
417 const char *opt_name
;
419 } panels_ini_options
[] = {
420 { "show_mini_info", &panels_options
.show_mini_info
},
421 { "kilobyte_si", &panels_options
.kilobyte_si
},
422 { "mix_all_files", &panels_options
.mix_all_files
},
423 { "show_backups", &panels_options
.show_backups
},
424 { "show_dot_files", &panels_options
.show_dot_files
},
425 { "fast_reload", &panels_options
.fast_reload
},
426 { "fast_reload_msg_shown", &panels_options
.fast_reload_msg_shown
},
427 { "mark_moves_down", &panels_options
.mark_moves_down
},
428 { "reverse_files_only", &panels_options
.reverse_files_only
},
429 { "auto_save_setup_panels", &panels_options
.auto_save_setup
},
430 { "navigate_with_arrows", &panels_options
.navigate_with_arrows
},
431 { "panel_scroll_pages", &panels_options
.scroll_pages
},
432 { "panel_scroll_center", &panels_options
.scroll_center
},
433 { "mouse_move_pages", &panels_options
.mouse_move_pages
},
434 { "filetype_mode", &panels_options
.filetype_mode
},
435 { "permission_mode", &panels_options
.permission_mode
},
436 { "torben_fj_mode", &panels_options
.torben_fj_mode
},
441 /*** file scope functions ************************************************************************/
442 /* --------------------------------------------------------------------------------------------- */
445 * Get name of config file.
447 * @param subdir If not NULL, config is also searched in specified subdir.
448 * @param config_file_name If relative, file if searched in standard paths.
450 * @return newly allocated string with config name or NULL if file is not found.
454 load_setup_get_full_config_name (const char *subdir
, const char *config_file_name
)
457 TODO: IMHO, in future, this function shall be placed in mcconfig module.
459 char *lc_basename
, *ret
;
462 if (config_file_name
== NULL
)
465 /* check for .keymap suffix */
466 if (g_str_has_suffix (config_file_name
, ".keymap"))
467 file_name
= g_strdup (config_file_name
);
469 file_name
= g_strconcat (config_file_name
, ".keymap", (char *) NULL
);
471 canonicalize_pathname (file_name
);
473 if (g_path_is_absolute (file_name
))
476 lc_basename
= g_path_get_basename (file_name
);
479 if (lc_basename
== NULL
)
483 ret
= g_build_filename (mc_config_get_path (), subdir
, lc_basename
, (char *) NULL
);
485 ret
= g_build_filename (mc_config_get_path (), lc_basename
, (char *) NULL
);
487 if (exist_file (ret
))
489 g_free (lc_basename
);
490 canonicalize_pathname (ret
);
496 ret
= g_build_filename (mc_global
.sysconfig_dir
, subdir
, lc_basename
, (char *) NULL
);
498 ret
= g_build_filename (mc_global
.sysconfig_dir
, lc_basename
, (char *) NULL
);
500 if (exist_file (ret
))
502 g_free (lc_basename
);
503 canonicalize_pathname (ret
);
509 ret
= g_build_filename (mc_global
.share_data_dir
, subdir
, lc_basename
, (char *) NULL
);
511 ret
= g_build_filename (mc_global
.share_data_dir
, lc_basename
, (char *) NULL
);
513 g_free (lc_basename
);
515 if (exist_file (ret
))
517 canonicalize_pathname (ret
);
525 /* --------------------------------------------------------------------------------------------- */
528 setup__is_cfg_group_must_panel_config (const char *grp
)
530 return (!strcasecmp ("Dirs", grp
) ||
531 !strcasecmp ("Temporal:New Right Panel", grp
) ||
532 !strcasecmp ("Temporal:New Left Panel", grp
) ||
533 !strcasecmp ("New Left Panel", grp
) || !strcasecmp ("New Right Panel", grp
))
537 /* --------------------------------------------------------------------------------------------- */
540 setup__move_panels_config_into_separate_file (const char *profile
)
542 mc_config_t
*tmp_cfg
;
543 char **groups
, **curr_grp
;
545 if (!exist_file (profile
))
548 tmp_cfg
= mc_config_init (profile
, FALSE
);
552 groups
= mc_config_get_groups (tmp_cfg
, NULL
);
556 mc_config_deinit (tmp_cfg
);
560 for (curr_grp
= groups
; *curr_grp
!= NULL
; curr_grp
++)
561 if (setup__is_cfg_group_must_panel_config (*curr_grp
) == NULL
)
562 mc_config_del_group (tmp_cfg
, *curr_grp
);
564 mc_config_save_to_file (tmp_cfg
, panels_profile_name
, NULL
);
565 mc_config_deinit (tmp_cfg
);
567 tmp_cfg
= mc_config_init (profile
, FALSE
);
574 for (curr_grp
= groups
; *curr_grp
!= NULL
; curr_grp
++)
576 const char *need_grp
;
578 need_grp
= setup__is_cfg_group_must_panel_config (*curr_grp
);
579 if (need_grp
!= NULL
)
580 mc_config_del_group (tmp_cfg
, need_grp
);
584 mc_config_save_file (tmp_cfg
, NULL
);
585 mc_config_deinit (tmp_cfg
);
588 /* --------------------------------------------------------------------------------------------- */
590 Create new mc_config object from specified ini-file or
591 append data to existing mc_config object from ini-file
595 load_setup_init_config_from_file (mc_config_t
** config
, const char *fname
, gboolean read_only
)
598 TODO: IMHO, in future, this function shall be placed in mcconfig module.
600 if (exist_file (fname
))
603 mc_config_read_file (*config
, fname
, read_only
, TRUE
);
605 *config
= mc_config_init (fname
, read_only
);
609 /* --------------------------------------------------------------------------------------------- */
617 /* Load boolean options */
618 for (i
= 0; bool_options
[i
].opt_name
!= NULL
; i
++)
619 *bool_options
[i
].opt_addr
=
620 mc_config_get_bool (mc_global
.main_config
, CONFIG_APP_SECTION
, bool_options
[i
].opt_name
,
621 *bool_options
[i
].opt_addr
);
623 /* Load integer options */
624 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
625 *int_options
[i
].opt_addr
=
626 mc_config_get_int (mc_global
.main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
627 *int_options
[i
].opt_addr
);
629 /* Load string options */
630 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
631 *str_options
[i
].opt_addr
=
632 mc_config_get_string (mc_global
.main_config
, CONFIG_APP_SECTION
,
633 str_options
[i
].opt_name
, str_options
[i
].opt_defval
);
635 /* Overwrite some options */
636 #ifdef USE_INTERNAL_EDIT
637 if (option_word_wrap_line_length
<= 0)
638 option_word_wrap_line_length
= DEFAULT_WRAP_LINE_LENGTH
;
640 /* Reset forced in case of build without internal editor */
641 use_internal_edit
= FALSE
;
642 #endif /* USE_INTERNAL_EDIT */
644 if (option_tab_spacing
<= 0)
645 option_tab_spacing
= DEFAULT_TAB_SPACING
;
647 kt
= getenv ("KEYBOARD_KEY_TIMEOUT_US");
648 if (kt
!= NULL
&& kt
[0] != '\0')
649 old_esc_mode_timeout
= atoi (kt
);
652 /* --------------------------------------------------------------------------------------------- */
654 static panel_view_mode_t
655 setup__load_panel_state (const char *section
)
659 panel_view_mode_t mode
= view_listing
;
661 /* Load the display mode */
662 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "display", "listing");
664 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
665 if (g_ascii_strcasecmp (panel_types
[i
].opt_name
, buffer
) == 0)
667 mode
= panel_types
[i
].opt_type
;
676 /* --------------------------------------------------------------------------------------------- */
683 /* actual options override legacy ones */
684 for (i
= 0; layout_int_options
[i
].opt_name
!= NULL
; i
++)
685 *layout_int_options
[i
].opt_addr
=
686 mc_config_get_int (mc_global
.main_config
, CONFIG_LAYOUT_SECTION
,
687 layout_int_options
[i
].opt_name
, *layout_int_options
[i
].opt_addr
);
689 for (i
= 0; layout_bool_options
[i
].opt_name
!= NULL
; i
++)
690 *layout_bool_options
[i
].opt_addr
=
691 mc_config_get_bool (mc_global
.main_config
, CONFIG_LAYOUT_SECTION
,
692 layout_bool_options
[i
].opt_name
, *layout_bool_options
[i
].opt_addr
);
694 startup_left_mode
= setup__load_panel_state ("New Left Panel");
695 startup_right_mode
= setup__load_panel_state ("New Right Panel");
697 /* At least one of the panels is a listing panel */
698 if (startup_left_mode
!= view_listing
&& startup_right_mode
!= view_listing
)
699 startup_left_mode
= view_listing
;
701 boot_current_is_left
=
702 mc_config_get_bool (mc_global
.panels_config
, "Dirs", "current_is_left", TRUE
);
705 /* --------------------------------------------------------------------------------------------- */
708 load_keys_from_section (const char *terminal
, mc_config_t
* cfg
)
711 gchar
**profile_keys
, **keys
;
712 char *valcopy
, *value
;
715 if (terminal
== NULL
)
718 section_name
= g_strconcat ("terminal:", terminal
, (char *) NULL
);
719 keys
= mc_config_get_keys (cfg
, section_name
, NULL
);
721 for (profile_keys
= keys
; *profile_keys
!= NULL
; profile_keys
++)
723 /* copy=other causes all keys from [terminal:other] to be loaded. */
724 if (g_ascii_strcasecmp (*profile_keys
, "copy") == 0)
726 valcopy
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
727 load_keys_from_section (valcopy
, cfg
);
732 key_code
= lookup_key (*profile_keys
, NULL
);
737 values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, NULL
);
742 for (curr_values
= values
; *curr_values
!= NULL
; curr_values
++)
744 valcopy
= convert_controls (*curr_values
);
745 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
753 value
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
754 valcopy
= convert_controls (value
);
755 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
762 g_free (section_name
);
765 /* --------------------------------------------------------------------------------------------- */
768 load_keymap_from_section (const char *section_name
, GArray
* keymap
, mc_config_t
* cfg
)
770 gchar
**profile_keys
, **keys
;
772 if (section_name
== NULL
)
775 keys
= mc_config_get_keys (cfg
, section_name
, NULL
);
777 for (profile_keys
= keys
; *profile_keys
!= NULL
; profile_keys
++)
781 values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, NULL
);
786 action
= keybind_lookup_action (*profile_keys
);
791 for (curr_values
= values
; *curr_values
!= NULL
; curr_values
++)
792 keybind_cmd_bind (keymap
, *curr_values
, action
);
802 /* --------------------------------------------------------------------------------------------- */
805 load_setup_get_keymap_profile_config (gboolean load_from_file
)
808 TODO: IMHO, in future, this function shall be placed in mcconfig module.
810 mc_config_t
*keymap_config
;
811 char *share_keymap
, *sysconfig_keymap
;
812 char *fname
, *fname2
;
814 /* 0) Create default keymap */
815 keymap_config
= create_default_keymap ();
817 return keymap_config
;
819 /* load and merge global keymaps */
821 /* 1) /usr/share/mc (mc_global.share_data_dir) */
822 share_keymap
= g_build_filename (mc_global
.share_data_dir
, GLOBAL_KEYMAP_FILE
, (char *) NULL
);
823 load_setup_init_config_from_file (&keymap_config
, share_keymap
, TRUE
);
825 /* 2) /etc/mc (mc_global.sysconfig_dir) */
827 g_build_filename (mc_global
.sysconfig_dir
, GLOBAL_KEYMAP_FILE
, (char *) NULL
);
828 load_setup_init_config_from_file (&keymap_config
, sysconfig_keymap
, TRUE
);
830 /* then load and merge one of user-defined keymap */
832 /* 3) --keymap=<keymap> */
833 fname
= load_setup_get_full_config_name (NULL
, mc_args__keymap_file
);
834 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
836 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
841 /* 4) getenv("MC_KEYMAP") */
842 fname
= load_setup_get_full_config_name (NULL
, g_getenv ("MC_KEYMAP"));
843 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
845 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
851 /* 5) main config; [Midnight Commander] -> keymap */
852 fname2
= mc_config_get_string (mc_global
.main_config
, CONFIG_APP_SECTION
, "keymap", NULL
);
853 if (fname2
!= NULL
&& *fname2
!= '\0')
854 fname
= load_setup_get_full_config_name (NULL
, fname2
);
856 if (fname
!= NULL
&& strcmp (fname
, sysconfig_keymap
) != 0 && strcmp (fname
, share_keymap
) != 0)
858 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
863 /* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
864 fname
= mc_config_get_full_path (GLOBAL_KEYMAP_FILE
);
865 load_setup_init_config_from_file (&keymap_config
, fname
, TRUE
);
869 g_free (sysconfig_keymap
);
870 g_free (share_keymap
);
872 return keymap_config
;
875 /* --------------------------------------------------------------------------------------------- */
878 panel_save_type (const char *section
, panel_view_mode_t type
)
882 for (i
= 0; panel_types
[i
].opt_name
!= NULL
; i
++)
883 if (panel_types
[i
].opt_type
== type
)
885 mc_config_set_string (mc_global
.panels_config
, section
, "display",
886 panel_types
[i
].opt_name
);
891 /* --------------------------------------------------------------------------------------------- */
894 * Load panels options from [Panels] section.
897 panels_load_options (void)
899 if (mc_config_has_group (mc_global
.main_config
, CONFIG_PANELS_SECTION
))
904 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
905 *panels_ini_options
[i
].opt_addr
=
906 mc_config_get_bool (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
907 panels_ini_options
[i
].opt_name
,
908 *panels_ini_options
[i
].opt_addr
);
910 qmode
= mc_config_get_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
911 "quick_search_mode", (int) panels_options
.qsearch_mode
);
913 panels_options
.qsearch_mode
= QSEARCH_CASE_INSENSITIVE
;
914 else if (qmode
>= QSEARCH_NUM
)
915 panels_options
.qsearch_mode
= QSEARCH_PANEL_CASE
;
917 panels_options
.qsearch_mode
= (qsearch_mode_t
) qmode
;
919 panels_options
.select_flags
=
920 mc_config_get_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
, "select_flags",
921 (int) panels_options
.select_flags
);
925 /* --------------------------------------------------------------------------------------------- */
928 * Save panels options in [Panels] section.
931 panels_save_options (void)
935 for (i
= 0; panels_ini_options
[i
].opt_name
!= NULL
; i
++)
936 mc_config_set_bool (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
937 panels_ini_options
[i
].opt_name
, *panels_ini_options
[i
].opt_addr
);
939 mc_config_set_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
940 "quick_search_mode", (int) panels_options
.qsearch_mode
);
941 mc_config_set_int (mc_global
.main_config
, CONFIG_PANELS_SECTION
,
942 "select_flags", (int) panels_options
.select_flags
);
945 /* --------------------------------------------------------------------------------------------- */
952 /* Save boolean options */
953 for (i
= 0; bool_options
[i
].opt_name
!= NULL
; i
++)
954 mc_config_set_bool (mc_global
.main_config
, CONFIG_APP_SECTION
, bool_options
[i
].opt_name
,
955 *bool_options
[i
].opt_addr
);
957 /* Save integer options */
958 for (i
= 0; int_options
[i
].opt_name
!= NULL
; i
++)
959 mc_config_set_int (mc_global
.main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
,
960 *int_options
[i
].opt_addr
);
962 /* Save string options */
963 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
964 mc_config_set_string (mc_global
.main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
,
965 *str_options
[i
].opt_addr
);
968 /* --------------------------------------------------------------------------------------------- */
975 /* Save integer options */
976 for (i
= 0; layout_int_options
[i
].opt_name
!= NULL
; i
++)
977 mc_config_set_int (mc_global
.main_config
, CONFIG_LAYOUT_SECTION
,
978 layout_int_options
[i
].opt_name
, *layout_int_options
[i
].opt_addr
);
980 /* Save boolean options */
981 for (i
= 0; layout_bool_options
[i
].opt_name
!= NULL
; i
++)
982 mc_config_set_bool (mc_global
.main_config
, CONFIG_LAYOUT_SECTION
,
983 layout_bool_options
[i
].opt_name
, *layout_bool_options
[i
].opt_addr
);
986 /* --------------------------------------------------------------------------------------------- */
988 /* save panels.ini */
990 save_panel_types (void)
992 panel_view_mode_t type
;
994 if (mc_global
.mc_run_mode
!= MC_RUN_FULL
)
997 type
= get_panel_type (0);
998 panel_save_type ("New Left Panel", type
);
999 if (type
== view_listing
)
1000 panel_save_setup (left_panel
, left_panel
->name
);
1001 type
= get_panel_type (1);
1002 panel_save_type ("New Right Panel", type
);
1003 if (type
== view_listing
)
1004 panel_save_setup (right_panel
, right_panel
->name
);
1009 dirs
= get_panel_dir_for (other_panel
);
1010 mc_config_set_string (mc_global
.panels_config
, "Dirs", "other_dir", dirs
);
1014 if (current_panel
!= NULL
)
1015 mc_config_set_bool (mc_global
.panels_config
, "Dirs", "current_is_left",
1016 get_current_index () == 0);
1018 if (mc_global
.panels_config
->ini_path
== NULL
)
1019 mc_global
.panels_config
->ini_path
= g_strdup (panels_profile_name
);
1021 mc_config_del_group (mc_global
.panels_config
, "Temporal:New Left Panel");
1022 mc_config_del_group (mc_global
.panels_config
, "Temporal:New Right Panel");
1024 mc_config_save_file (mc_global
.panels_config
, NULL
);
1027 /* --------------------------------------------------------------------------------------------- */
1028 /*** public functions ****************************************************************************/
1029 /* --------------------------------------------------------------------------------------------- */
1034 if (profile_name
== NULL
)
1038 profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
1039 if (!exist_file (profile
))
1043 inifile
= mc_build_filename (mc_global
.sysconfig_dir
, "mc.ini", (char *) NULL
);
1044 if (exist_file (inifile
))
1052 inifile
= mc_build_filename (mc_global
.share_data_dir
, "mc.ini", (char *) NULL
);
1053 if (!exist_file (inifile
))
1063 profile_name
= profile
;
1066 return profile_name
;
1069 /* --------------------------------------------------------------------------------------------- */
1074 const char *profile
;
1077 const char *cbuffer
;
1079 load_codepages_list ();
1080 #endif /* HAVE_CHARSET */
1082 profile
= setup_init ();
1084 /* mc.lib is common for all users, but has priority lower than
1085 ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */
1086 global_profile_name
=
1087 g_build_filename (mc_global
.sysconfig_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
1088 if (!exist_file (global_profile_name
))
1090 g_free (global_profile_name
);
1091 global_profile_name
=
1092 g_build_filename (mc_global
.share_data_dir
, MC_GLOBAL_CONFIG_FILE
, (char *) NULL
);
1095 panels_profile_name
= mc_config_get_full_path (MC_PANELS_FILE
);
1097 mc_global
.main_config
= mc_config_init (profile
, FALSE
);
1099 if (!exist_file (panels_profile_name
))
1100 setup__move_panels_config_into_separate_file (profile
);
1102 mc_global
.panels_config
= mc_config_init (panels_profile_name
, FALSE
);
1106 panels_load_options ();
1109 /* Load time formats */
1110 user_recent_timeformat
=
1111 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "timeformat_recent",
1113 user_old_timeformat
=
1114 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "timeformat_old",
1117 #ifdef ENABLE_VFS_FTP
1119 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host", "gate");
1120 ftpfs_init_passwd ();
1121 #endif /* ENABLE_VFS_FTP */
1123 /* The default color and the terminal dependent color */
1124 mc_global
.tty
.setup_color_string
=
1125 mc_config_get_string (mc_global
.main_config
, "Colors", "base_color", "");
1126 mc_global
.tty
.term_color_string
=
1127 mc_config_get_string (mc_global
.main_config
, "Colors", getenv ("TERM"), "");
1128 mc_global
.tty
.color_terminal_string
=
1129 mc_config_get_string (mc_global
.main_config
, "Colors", "color_terminals", "");
1131 /* Load the directory history */
1132 /* directory_history_load (); */
1133 /* Remove the temporal entries */
1136 if (codepages
->len
> 1)
1141 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "display_codepage",
1143 if (buffer
[0] != '\0')
1145 mc_global
.display_codepage
= get_codepage_index (buffer
);
1146 cp_display
= get_codepage_id (mc_global
.display_codepage
);
1150 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "source_codepage",
1152 if (buffer
[0] != '\0')
1154 default_source_codepage
= get_codepage_index (buffer
);
1155 mc_global
.source_codepage
= default_source_codepage
; /* May be source_codepage doesn't need this */
1156 cp_source
= get_codepage_id (mc_global
.source_codepage
);
1161 autodetect_codeset
=
1162 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset", "");
1163 if ((autodetect_codeset
[0] != '\0') && (strcmp (autodetect_codeset
, "off") != 0))
1164 is_autodetect_codeset_enabled
= TRUE
;
1166 g_free (init_translation_table (mc_global
.source_codepage
, mc_global
.display_codepage
));
1167 cbuffer
= get_codepage_id (mc_global
.display_codepage
);
1168 if (cbuffer
!= NULL
)
1169 mc_global
.utf8_display
= str_isutf8 (cbuffer
);
1170 #endif /* HAVE_CHARSET */
1174 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "spell_language", "en");
1175 #endif /* HAVE_ASPELL */
1177 clipboard_store_path
=
1178 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_store", "");
1179 clipboard_paste_path
=
1180 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_paste", "");
1183 /* --------------------------------------------------------------------------------------------- */
1186 save_setup (gboolean save_options
, gboolean save_panel_options
)
1188 gboolean ret
= TRUE
;
1194 if (save_panel_options
)
1195 save_panel_types ();
1203 panels_save_options ();
1205 /* directory_history_save (); */
1207 #ifdef ENABLE_VFS_FTP
1208 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftpfs_password",
1209 ftpfs_anonymous_passwd
);
1210 if (ftpfs_proxy_host
)
1211 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftp_proxy_host",
1213 #endif /* ENABLE_VFS_FTP */
1216 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "display_codepage",
1217 get_codepage_id (mc_global
.display_codepage
));
1218 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "source_codepage",
1219 get_codepage_id (default_source_codepage
));
1220 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "autodetect_codeset",
1221 autodetect_codeset
);
1222 #endif /* HAVE_CHARSET */
1225 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "spell_language",
1227 #endif /* HAVE_ASPELL */
1229 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_store",
1230 clipboard_store_path
);
1231 mc_config_set_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "clipboard_paste",
1232 clipboard_paste_path
);
1234 tmp_profile
= mc_config_get_full_path (MC_CONFIG_FILE
);
1235 ret
= mc_config_save_to_file (mc_global
.main_config
, tmp_profile
, NULL
);
1236 g_free (tmp_profile
);
1244 /* --------------------------------------------------------------------------------------------- */
1251 g_free (clipboard_store_path
);
1252 g_free (clipboard_paste_path
);
1253 g_free (global_profile_name
);
1254 g_free (mc_global
.tty
.color_terminal_string
);
1255 g_free (mc_global
.tty
.term_color_string
);
1256 g_free (mc_global
.tty
.setup_color_string
);
1257 g_free (profile_name
);
1258 g_free (panels_profile_name
);
1259 mc_config_deinit (mc_global
.main_config
);
1260 mc_config_deinit (mc_global
.panels_config
);
1262 g_free (user_recent_timeformat
);
1263 g_free (user_old_timeformat
);
1265 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
1266 g_free (*str_options
[i
].opt_addr
);
1270 /* directory_history_free (); */
1273 g_free (autodetect_codeset
);
1274 free_codepages_list ();
1278 g_free (spell_language
);
1279 #endif /* HAVE_ASPELL */
1283 /* --------------------------------------------------------------------------------------------- */
1286 setup_save_config_show_error (const char *filename
, GError
** mcerror
)
1288 if (mcerror
!= NULL
&& *mcerror
!= NULL
)
1290 message (D_ERROR
, MSG_ERROR
, _("Cannot save file %s:\n%s"), filename
, (*mcerror
)->message
);
1291 g_error_free (*mcerror
);
1297 /* --------------------------------------------------------------------------------------------- */
1300 load_key_defs (void)
1303 * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1304 * definitions override global settings.
1306 mc_config_t
*mc_global_config
;
1308 mc_global_config
= mc_config_init (global_profile_name
, FALSE
);
1309 if (mc_global_config
!= NULL
)
1311 load_keys_from_section ("general", mc_global_config
);
1312 load_keys_from_section (getenv ("TERM"), mc_global_config
);
1313 mc_config_deinit (mc_global_config
);
1316 load_keys_from_section ("general", mc_global
.main_config
);
1317 load_keys_from_section (getenv ("TERM"), mc_global
.main_config
);
1320 /* --------------------------------------------------------------------------------------------- */
1322 #ifdef ENABLE_VFS_FTP
1324 load_anon_passwd (void)
1329 mc_config_get_string (mc_global
.main_config
, CONFIG_MISC_SECTION
, "ftpfs_password", "");
1331 if ((buffer
!= NULL
) && (buffer
[0] != '\0'))
1337 #endif /* ENABLE_VFS_FTP */
1339 /* --------------------------------------------------------------------------------------------- */
1342 load_keymap_defs (gboolean load_from_file
)
1345 * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
1346 * definitions override global settings.
1348 mc_config_t
*mc_global_keymap
;
1350 mc_global_keymap
= load_setup_get_keymap_profile_config (load_from_file
);
1352 if (mc_global_keymap
!= NULL
)
1354 #define LOAD_KEYMAP(s,km) \
1355 km##_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t)); \
1356 load_keymap_from_section (KEYMAP_SECTION_##s, km##_keymap, mc_global_keymap)
1358 LOAD_KEYMAP (FILEMANAGER
, filemanager
);
1359 LOAD_KEYMAP (FILEMANAGER_EXT
, filemanager_x
);
1360 LOAD_KEYMAP (PANEL
, panel
);
1361 LOAD_KEYMAP (DIALOG
, dialog
);
1362 LOAD_KEYMAP (MENU
, menu
);
1363 LOAD_KEYMAP (INPUT
, input
);
1364 LOAD_KEYMAP (LISTBOX
, listbox
);
1365 LOAD_KEYMAP (RADIO
, radio
);
1366 LOAD_KEYMAP (TREE
, tree
);
1367 LOAD_KEYMAP (HELP
, help
);
1368 #ifdef ENABLE_EXT2FS_ATTR
1369 LOAD_KEYMAP (CHATTR
, chattr
);
1371 #ifdef USE_INTERNAL_EDIT
1372 LOAD_KEYMAP (EDITOR
, editor
);
1373 LOAD_KEYMAP (EDITOR_EXT
, editor_x
);
1375 LOAD_KEYMAP (VIEWER
, viewer
);
1376 LOAD_KEYMAP (VIEWER_HEX
, viewer_hex
);
1377 #ifdef USE_DIFF_VIEW
1378 LOAD_KEYMAP (DIFFVIEWER
, diff
);
1382 mc_config_deinit (mc_global_keymap
);
1385 #define SET_MAP(m) \
1386 m##_map = (global_keymap_t *) m##_keymap->data
1388 SET_MAP (filemanager
);
1389 SET_MAP (filemanager_x
);
1398 #ifdef ENABLE_EXT2FS_ATTR
1401 #ifdef USE_INTERNAL_EDIT
1406 SET_MAP (viewer_hex
);
1407 #ifdef USE_DIFF_VIEW
1414 /* --------------------------------------------------------------------------------------------- */
1417 free_keymap_defs (void)
1419 #define FREE_KEYMAP(km) \
1420 if (km##_keymap != NULL) \
1421 g_array_free (km##_keymap, TRUE)
1423 FREE_KEYMAP (filemanager
);
1424 FREE_KEYMAP (filemanager_x
);
1425 FREE_KEYMAP (panel
);
1426 FREE_KEYMAP (dialog
);
1428 FREE_KEYMAP (input
);
1429 FREE_KEYMAP (listbox
);
1430 FREE_KEYMAP (radio
);
1433 #ifdef ENABLE_EXT2FS_ATTR
1434 FREE_KEYMAP (chattr
);
1436 #ifdef USE_INTERNAL_EDIT
1437 FREE_KEYMAP (editor
);
1438 FREE_KEYMAP (editor_x
);
1440 FREE_KEYMAP (viewer
);
1441 FREE_KEYMAP (viewer_hex
);
1442 #ifdef USE_DIFF_VIEW
1449 /* --------------------------------------------------------------------------------------------- */
1452 panel_load_setup (WPanel
* panel
, const char *section
)
1455 char *buffer
, buffer2
[BUF_TINY
];
1457 panel
->sort_info
.reverse
=
1458 mc_config_get_bool (mc_global
.panels_config
, section
, "reverse", FALSE
);
1459 panel
->sort_info
.case_sensitive
=
1460 mc_config_get_bool (mc_global
.panels_config
, section
, "case_sensitive",
1461 OS_SORT_CASE_SENSITIVE_DEFAULT
);
1462 panel
->sort_info
.exec_first
=
1463 mc_config_get_bool (mc_global
.panels_config
, section
, "exec_first", FALSE
);
1465 /* Load sort order */
1466 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "sort_order", "name");
1467 panel
->sort_field
= panel_get_field_by_id (buffer
);
1468 if (panel
->sort_field
== NULL
)
1469 panel
->sort_field
= panel_get_field_by_id ("name");
1473 /* Load the listing format */
1474 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "list_format", NULL
);
1477 /* fallback to old option */
1478 buffer
= mc_config_get_string (mc_global
.panels_config
, section
, "list_mode", "full");
1480 panel
->list_format
= list_full
;
1481 for (i
= 0; list_formats
[i
].key
!= NULL
; i
++)
1482 if (g_ascii_strcasecmp (list_formats
[i
].key
, buffer
) == 0)
1484 panel
->list_format
= list_formats
[i
].list_format
;
1489 panel
->brief_cols
= mc_config_get_int (mc_global
.panels_config
, section
, "brief_cols", 2);
1492 g_free (panel
->user_format
);
1493 panel
->user_format
=
1494 mc_config_get_string (mc_global
.panels_config
, section
, "user_format", DEFAULT_USER_FORMAT
);
1496 for (i
= 0; i
< LIST_FORMATS
; i
++)
1498 g_free (panel
->user_status_format
[i
]);
1499 g_snprintf (buffer2
, sizeof (buffer2
), "user_status%lld", (long long) i
);
1500 panel
->user_status_format
[i
] =
1501 mc_config_get_string (mc_global
.panels_config
, section
, buffer2
, DEFAULT_USER_FORMAT
);
1504 panel
->user_mini_status
=
1505 mc_config_get_bool (mc_global
.panels_config
, section
, "user_mini_status", FALSE
);
1508 /* --------------------------------------------------------------------------------------------- */
1511 panel_save_setup (WPanel
* panel
, const char *section
)
1513 char buffer
[BUF_TINY
];
1516 mc_config_set_bool (mc_global
.panels_config
, section
, "reverse", panel
->sort_info
.reverse
);
1517 mc_config_set_bool (mc_global
.panels_config
, section
, "case_sensitive",
1518 panel
->sort_info
.case_sensitive
);
1519 mc_config_set_bool (mc_global
.panels_config
, section
, "exec_first",
1520 panel
->sort_info
.exec_first
);
1522 mc_config_set_string (mc_global
.panels_config
, section
, "sort_order", panel
->sort_field
->id
);
1524 for (i
= 0; list_formats
[i
].key
!= NULL
; i
++)
1525 if (list_formats
[i
].list_format
== (int) panel
->list_format
)
1527 mc_config_set_string (mc_global
.panels_config
, section
, "list_format",
1528 list_formats
[i
].key
);
1532 mc_config_set_int (mc_global
.panels_config
, section
, "brief_cols", panel
->brief_cols
);
1534 mc_config_set_string (mc_global
.panels_config
, section
, "user_format", panel
->user_format
);
1536 for (i
= 0; i
< LIST_FORMATS
; i
++)
1538 g_snprintf (buffer
, sizeof (buffer
), "user_status%lld", (long long) i
);
1539 mc_config_set_string (mc_global
.panels_config
, section
, buffer
,
1540 panel
->user_status_format
[i
]);
1543 mc_config_set_bool (mc_global
.panels_config
, section
, "user_mini_status",
1544 panel
->user_mini_status
);
1547 /* --------------------------------------------------------------------------------------------- */