1 /* Setup loading/saving.
2 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2009 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 * \brief Source: setup loading/saving
28 #include <sys/types.h>
33 #include "../src/tty/tty.h"
34 #include "../src/tty/key.h"
35 #include "../src/tty/mouse.h" /* To make view.h happy */
41 #include "tree.h" /* xtree_mode */
42 #include "../src/mcconfig/mcconfig.h"
44 #include "../src/viewer/mcviewer.h" /* For the externs */
45 #include "hotlist.h" /* load/save/done hotlist */
46 #include "panelize.h" /* load/save/done panelize */
48 #include "menu.h" /* menubar_visible declaration */
50 #include "file.h" /* safe_delete */
51 #include "keybind.h" /* lookup_action */
54 #include "../vfs/gc.h"
62 # include "../vfs/ftpfs.h"
63 # include "../vfs/fish.h"
66 #ifdef USE_INTERNAL_EDIT
67 # include "../edit/edit.h"
70 #include "../src/strutil.h" /* str_isutf8 () */
73 extern char *find_ignore_dirs
;
75 extern int num_history_items_recorded
;
77 char *profile_name
; /* .mc/ini */
78 char *global_profile_name
; /* mc.lib */
79 char *panels_profile_name
; /* .mc/panels.ini */
80 char *global_keymap_name
; /* GLOBAL_KEYMAP_FILE */
82 char *setup_color_string
;
83 char *term_color_string
;
84 char *color_terminal_string
;
86 int startup_left_mode
;
87 int startup_right_mode
;
89 /* Ugly hack to allow panel_save_setup to work as a place holder for */
90 /* default panel values */
97 { "name", (sortfn
*) sort_name
},
98 { "extension", (sortfn
*) sort_ext
},
99 { "time", (sortfn
*) sort_time
},
100 { "atime", (sortfn
*) sort_atime
},
101 { "ctime", (sortfn
*) sort_ctime
},
102 { "size", (sortfn
*) sort_size
},
103 { "inode", (sortfn
*) sort_inode
},
104 { "unsorted", (sortfn
*) unsorted
},
108 static const struct {
112 { "full", list_full
},
113 { "brief", list_brief
},
114 { "long", list_long
},
115 { "user", list_user
},
119 static const struct {
120 const char *opt_name
;
123 { "listing", view_listing
},
124 { "quickview", view_quick
},
125 { "info", view_info
},
126 { "tree", view_tree
},
130 static const struct {
131 const char *opt_name
;
134 { "equal_split", &equal_split
},
135 { "first_panel_size", &first_panel_size
},
136 { "message_visible", &message_visible
},
137 { "keybar_visible", &keybar_visible
},
138 { "xterm_title", &xterm_title
},
139 { "output_lines", &output_lines
},
140 { "command_prompt", &command_prompt
},
141 { "menubar_visible", &menubar_visible
},
142 { "show_mini_info", &show_mini_info
},
143 { "permission_mode", &permission_mode
},
144 { "filetype_mode", &filetype_mode
},
145 { "free_space", &free_space
},
149 static const struct {
150 const char *opt_name
;
153 { "show_backups", &show_backups
},
154 { "kilobyte_si", &kilobyte_si
},
155 { "show_dot_files", &show_dot_files
},
156 { "verbose", &verbose
},
157 { "mark_moves_down", &mark_moves_down
},
158 { "pause_after_run", &pause_after_run
},
159 { "shell_patterns", &easy_patterns
},
160 { "auto_save_setup", &auto_save_setup
},
161 { "auto_menu", &auto_menu
},
162 { "use_internal_view", &use_internal_view
},
163 { "use_internal_edit", &use_internal_edit
},
164 { "clear_before_exec", &clear_before_exec
},
165 { "mix_all_files", &mix_all_files
},
166 { "fast_reload", &fast_reload
},
167 { "fast_reload_msg_shown", &fast_reload_w
},
168 { "confirm_delete", &confirm_delete
},
169 { "confirm_overwrite", &confirm_overwrite
},
170 { "confirm_execute", &confirm_execute
},
171 { "confirm_exit", &confirm_exit
},
172 { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete
},
173 { "safe_delete", &safe_delete
},
174 { "mouse_repeat_rate", &mou_auto_repeat
},
175 { "double_click_speed", &double_click_speed
},
177 { "eight_bit_clean", &eight_bit_clean
},
178 { "full_eight_bits", &full_eight_bits
},
179 #endif /* !HAVE_CHARSET */
180 { "use_8th_bit_as_meta", &use_8th_bit_as_meta
},
181 { "confirm_view_dir", &confirm_view_dir
},
182 { "mouse_move_pages", &mouse_move_pages
},
183 { "mouse_move_pages_viewer", &mcview_mouse_move_pages
},
184 { "mouse_close_dialog", &mouse_close_dialog
},
185 { "fast_refresh", &fast_refresh
},
186 { "navigate_with_arrows", &navigate_with_arrows
},
187 { "drop_menus", &drop_menus
},
188 { "wrap_mode", &mcview_global_wrap_mode
},
189 { "old_esc_mode", &old_esc_mode
},
190 { "cd_symlinks", &cd_symlinks
},
191 { "show_all_if_ambiguous", &show_all_if_ambiguous
},
192 { "max_dirt_limit", &mcview_max_dirt_limit
},
193 { "torben_fj_mode", &torben_fj_mode
},
194 { "use_file_to_guess_type", &use_file_to_check_type
},
195 { "alternate_plus_minus", &alternate_plus_minus
},
196 { "only_leading_plus_minus", &only_leading_plus_minus
},
197 { "show_output_starts_shell", &output_starts_shell
},
198 { "panel_scroll_pages", &panel_scroll_pages
},
199 { "xtree_mode", &xtree_mode
},
200 { "num_history_items_recorded", &num_history_items_recorded
},
201 { "file_op_compute_totals", &file_op_compute_totals
},
202 { "skip_check_codeset", &skip_check_codeset
},
204 { "vfs_timeout", &vfs_timeout
},
206 { "ftpfs_directory_timeout", &ftpfs_directory_timeout
},
207 { "use_netrc", &use_netrc
},
208 { "ftpfs_retry_seconds", &ftpfs_retry_seconds
},
209 { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy
},
210 { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections
},
211 { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options
},
212 { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls
},
213 { "fish_directory_timeout", &fish_directory_timeout
},
214 #endif /* USE_NETCODE */
216 #ifdef USE_INTERNAL_EDIT
217 { "editor_word_wrap_line_length", &option_word_wrap_line_length
},
218 { "editor_key_emulation", &edit_key_emulation
},
219 { "editor_tab_spacing", &option_tab_spacing
},
220 { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces
},
221 { "editor_return_does_auto_indent", &option_return_does_auto_indent
},
222 { "editor_backspace_through_tabs", &option_backspace_through_tabs
},
223 { "editor_fake_half_tabs", &option_fake_half_tabs
},
224 { "editor_option_save_mode", &option_save_mode
},
225 { "editor_option_save_position", &option_save_position
},
226 { "editor_option_auto_para_formatting", &option_auto_para_formatting
},
227 { "editor_option_typewriter_wrap", &option_typewriter_wrap
},
228 { "editor_edit_confirm_save", &edit_confirm_save
},
229 { "editor_syntax_highlighting", &option_syntax_highlighting
},
230 { "editor_persistent_selections", &option_persistent_selections
},
231 { "editor_cursor_beyond_eol", &option_cursor_beyond_eol
},
232 { "editor_visible_tabs", &visible_tabs
},
233 { "editor_visible_spaces", &visible_tws
},
234 { "editor_line_state", &option_line_state
},
235 { "editor_simple_statusbar", &simple_statusbar
},
236 #endif /* USE_INTERNAL_EDIT */
238 { "nice_rotating_dash", &nice_rotating_dash
},
239 { "horizontal_split", &horizontal_split
},
240 { "mcview_remember_file_position", &mcview_remember_file_position
},
241 { "auto_fill_mkdir_name", &auto_fill_mkdir_name
},
242 { "reverse_files_only", &reverse_files_only
},
246 static const struct {
247 const char *opt_name
;
249 const char *opt_defval
;
251 #ifdef USE_INTERNAL_EDIT
252 { "editor_backup_extension", &option_backup_ext
, "~" },
258 panel_save_setup (struct WPanel
*panel
, const char *section
)
263 mc_config_set_int(mc_panels_config
, section
, "reverse", panel
->reverse
);
264 mc_config_set_int(mc_panels_config
, section
, "case_sensitive", panel
->case_sensitive
);
265 mc_config_set_int(mc_panels_config
, section
, "exec_first", panel
->exec_first
);
268 for (i
= 0; sort_names
[i
].key
; i
++)
269 if (sort_names
[i
].sort_type
== (sortfn
*) panel
->sort_type
){
270 mc_config_set_string(mc_panels_config
, section
, "sort_order", sort_names
[i
].key
);
274 for (i
= 0; list_types
[i
].key
; i
++)
275 if (list_types
[i
].list_type
== panel
->list_type
){
276 mc_config_set_string(mc_panels_config
, section
, "list_mode", list_types
[i
].key
);
280 mc_config_set_string(mc_panels_config
, section
, "user_format", panel
->user_format
);
282 for (i
= 0; i
< LIST_TYPES
; i
++){
283 buffer
= g_strdup_printf("user_status%d", i
);
284 mc_config_set_string(mc_panels_config
, section
, buffer
, panel
->user_status_format
[i
]);
288 mc_config_set_int(mc_panels_config
, section
, "user_mini_status", panel
->user_mini_status
);
297 profile
= concat_dir_and_file (home_dir
, PROFILE_NAME
);
299 /* Save integer options */
300 for (i
= 0; layout
[i
].opt_name
; i
++){
301 mc_config_set_int(mc_main_config
, "Layout", layout
[i
].opt_name
, *layout
[i
].opt_addr
);
303 mc_config_save_to_file (mc_main_config
, profile
);
309 save_configure (void)
314 profile
= concat_dir_and_file (home_dir
, PROFILE_NAME
);
316 /* Save integer options */
317 for (i
= 0; int_options
[i
].opt_name
; i
++)
318 mc_config_set_int(mc_main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
, *int_options
[i
].opt_addr
);
320 /* Save string options */
321 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
322 mc_config_set_string(mc_main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
, *str_options
[i
].opt_addr
);
324 mc_config_save_to_file (mc_main_config
, profile
);
329 panel_save_type (const char *section
, int type
)
333 for (i
= 0; panel_types
[i
].opt_name
; i
++)
334 if (panel_types
[i
].opt_type
== type
){
335 mc_config_set_string(mc_panels_config
, section
,
336 "display", panel_types
[i
].opt_name
);
342 save_panel_types (void)
346 type
= get_display_type (0);
347 panel_save_type ("New Left Panel", type
);
348 if (type
== view_listing
)
349 panel_save_setup (left_panel
, left_panel
->panel_name
);
350 type
= get_display_type (1);
351 panel_save_type ("New Right Panel", type
);
352 if (type
== view_listing
)
353 panel_save_setup (right_panel
, right_panel
->panel_name
);
355 mc_config_set_string(mc_panels_config
, "Dirs" , "other_dir",
356 get_other_type () == view_listing
357 ? other_panel
->cwd
: ".");
358 if (current_panel
!= NULL
)
359 mc_config_set_string(mc_panels_config
, "Dirs" , "current_is_left",
360 get_current_index () == 0 ? "1" : "0");
362 if (mc_panels_config
->ini_path
== NULL
)
363 mc_panels_config
->ini_path
= g_strdup(panels_profile_name
);
365 mc_config_del_group (mc_panels_config
, "Temporal:New Left Panel");
366 mc_config_del_group (mc_panels_config
, "Temporal:New Right Panel");
368 mc_config_save_file (mc_panels_config
);
386 /* directory_history_save (); */
388 #if defined(USE_VFS) && defined (USE_NETCODE)
389 mc_config_set_string(mc_main_config
, "Misc" , "ftpfs_password",
390 ftpfs_anonymous_passwd
);
391 if (ftpfs_proxy_host
)
392 mc_config_set_string(mc_main_config
, "Misc" , "ftp_proxy_host",
394 #endif /* USE_VFS && USE_NETCODE */
397 mc_config_set_string(mc_main_config
, "Misc" , "display_codepage",
398 get_codepage_id( display_codepage
));
399 mc_config_set_string(mc_main_config
, "Misc" , "source_codepage",
400 get_codepage_id( source_codepage
));
401 #endif /* HAVE_CHARSET */
402 tmp_profile
= concat_dir_and_file (home_dir
, PROFILE_NAME
);
403 mc_config_save_to_file (mc_main_config
, tmp_profile
);
404 g_free (tmp_profile
);
409 panel_load_setup (WPanel
*panel
, const char *section
)
414 panel
->reverse
= mc_config_get_int(mc_panels_config
, section
, "reverse", 0);
415 panel
->case_sensitive
= mc_config_get_int(mc_panels_config
, section
, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT
);
416 panel
->exec_first
= mc_config_get_int(mc_panels_config
, section
, "exec_first", 0);
418 /* Load sort order */
419 buffer
= mc_config_get_string(mc_panels_config
, section
, "sort_order", "name");
421 panel
->sort_type
= (sortfn
*) sort_name
;
422 for (i
= 0; sort_names
[i
].key
; i
++)
423 if ( g_strcasecmp (sort_names
[i
].key
, buffer
) == 0){
424 panel
->sort_type
= sort_names
[i
].sort_type
;
428 /* Load the listing mode */
429 buffer
= mc_config_get_string(mc_panels_config
, section
, "list_mode", "full");
430 panel
->list_type
= list_full
;
431 for (i
= 0; list_types
[i
].key
; i
++)
432 if ( g_strcasecmp (list_types
[i
].key
, buffer
) == 0){
433 panel
->list_type
= list_types
[i
].list_type
;
439 g_free (panel
->user_format
);
440 panel
->user_format
= mc_config_get_string(mc_panels_config
, section
, "user_format", DEFAULT_USER_FORMAT
);
442 for (i
= 0; i
< LIST_TYPES
; i
++){
443 g_free (panel
->user_status_format
[i
]);
444 buffer
= g_strdup_printf("user_status%d",i
);
445 panel
->user_status_format
[i
] =
446 mc_config_get_string(mc_panels_config
, section
, buffer
, DEFAULT_USER_FORMAT
);
450 panel
->user_mini_status
=
451 mc_config_get_int(mc_panels_config
, section
, "user_mini_status", 0);
460 for (i
= 0; layout
[i
].opt_name
; i
++)
461 *layout
[i
].opt_addr
=
462 mc_config_get_int(mc_main_config
,"Layout", layout
[i
].opt_name
, *layout
[i
].opt_addr
);
466 setup__load_panel_state (const char *section
)
471 int mode
= view_listing
;
473 /* Load the display mode */
474 buffer
= mc_config_get_string(mc_panels_config
, section
, "display", "listing");
476 for (i
= 0; panel_types
[i
].opt_name
; i
++)
477 if ( g_strcasecmp (panel_types
[i
].opt_name
, buffer
) == 0){
478 mode
= panel_types
[i
].opt_type
;
486 setup__is_cfg_group_must_panel_config(const char *grp
)
489 ! strcasecmp("Dirs",grp
) ||
490 ! strcasecmp("Temporal:New Right Panel",grp
) ||
491 ! strcasecmp("Temporal:New Left Panel",grp
) ||
492 ! strcasecmp("New Left Panel",grp
) ||
493 ! strcasecmp("New Right Panel",grp
)
500 setup__move_panels_config_into_separate_file(const char*profile
)
502 mc_config_t
*tmp_cfg
;
503 char **groups
, **curr_grp
;
504 const char *need_grp
;
507 if (!exist_file(profile
))
510 tmp_cfg
= mc_config_init(profile
);
514 curr_grp
= groups
= mc_config_get_groups (tmp_cfg
, &groups_count
);
517 mc_config_deinit(tmp_cfg
);
522 if ( setup__is_cfg_group_must_panel_config(*curr_grp
) == NULL
)
524 mc_config_del_group (tmp_cfg
, *curr_grp
);
529 mc_config_save_to_file (tmp_cfg
, panels_profile_name
);
530 mc_config_deinit(tmp_cfg
);
532 tmp_cfg
= mc_config_init(profile
);
543 need_grp
= setup__is_cfg_group_must_panel_config(*curr_grp
);
544 if ( need_grp
!= NULL
)
546 mc_config_del_group (tmp_cfg
, need_grp
);
551 mc_config_save_file (tmp_cfg
);
552 mc_config_deinit(tmp_cfg
);
566 profile
= concat_dir_and_file (home_dir
, PROFILE_NAME
);
567 if (!exist_file (profile
)){
568 inifile
= concat_dir_and_file (mc_home
, "mc.ini");
569 if (exist_file (inifile
)){
574 inifile
= concat_dir_and_file (mc_home_alt
, "mc.ini");
575 if (exist_file (inifile
)) {
583 profile_name
= profile
;
595 profile
= setup_init ();
597 /* mc.lib is common for all users, but has priority lower than
598 ~/.mc/ini. FIXME: it's only used for keys and treestore now */
599 global_profile_name
= concat_dir_and_file (mc_home
, "mc.lib");
600 if (!exist_file(global_profile_name
)) {
601 g_free (global_profile_name
);
602 global_profile_name
= concat_dir_and_file (mc_home_alt
, "mc.lib");
605 global_keymap_name
= concat_dir_and_file (mc_home
, GLOBAL_KEYMAP_FILE
);
606 if (!exist_file(global_keymap_name
)) {
607 g_free (global_keymap_name
);
608 global_keymap_name
= concat_dir_and_file (mc_home_alt
, GLOBAL_KEYMAP_FILE
);
610 panels_profile_name
= concat_dir_and_file (home_dir
, PANELS_PROFILE_NAME
);
612 mc_main_config
= mc_config_init(profile
);
614 if (!exist_file(panels_profile_name
))
615 setup__move_panels_config_into_separate_file(profile
);
617 mc_panels_config
= mc_config_init(panels_profile_name
);
619 /* Load integer boolean options */
620 for (i
= 0; int_options
[i
].opt_name
; i
++)
621 *int_options
[i
].opt_addr
=
622 mc_config_get_int(mc_main_config
, CONFIG_APP_SECTION
, int_options
[i
].opt_name
, *int_options
[i
].opt_addr
);
624 /* Load string options */
625 for (i
= 0; str_options
[i
].opt_name
!= NULL
; i
++)
626 *str_options
[i
].opt_addr
=
627 mc_config_get_string (mc_main_config
, CONFIG_APP_SECTION
, str_options
[i
].opt_name
, str_options
[i
].opt_defval
);
633 startup_left_mode
= setup__load_panel_state ("New Left Panel");
634 startup_right_mode
= setup__load_panel_state ("New Right Panel");
636 /* At least one of the panels is a listing panel */
637 if (startup_left_mode
!= view_listing
&& startup_right_mode
!=view_listing
)
638 startup_left_mode
= view_listing
;
641 buffer
= mc_config_get_string(mc_panels_config
, "Dirs", "other_dir", ".");
642 if (vfs_file_is_local (buffer
))
648 boot_current_is_left
=
649 mc_config_get_int(mc_panels_config
, "Dirs", "current_is_left", 1);
652 ftpfs_proxy_host
= mc_config_get_string(mc_main_config
, "Misc", "ftp_proxy_host", "gate");
654 setup_color_string
= mc_config_get_string(mc_main_config
, "Misc", "find_ignore_dirs", "");
655 if (setup_color_string
[0])
656 find_ignore_dirs
= g_strconcat (":", setup_color_string
, ":", (char *) NULL
);
657 g_free(setup_color_string
);
659 /* The default color and the terminal dependent color */
660 setup_color_string
= mc_config_get_string(mc_main_config
, "Colors", "base_color", "");
661 term_color_string
= mc_config_get_string(mc_main_config
, "Colors", getenv ("TERM"), "");
662 color_terminal_string
= mc_config_get_string(mc_main_config
, "Colors", "color_terminals", "");
664 /* Load the directory history */
665 /* directory_history_load (); */
666 /* Remove the temporal entries */
667 #if defined(USE_VFS) && defined (USE_NETCODE)
668 ftpfs_init_passwd ();
669 #endif /* USE_VFS && USE_NETCODE */
672 if ( load_codepages_list() > 0 ) {
673 buffer
= mc_config_get_string(mc_main_config
, "Misc", "display_codepage", "");
674 if ( buffer
[0] != '\0' )
676 display_codepage
= get_codepage_index( buffer
);
677 cp_display
= get_codepage_id (display_codepage
);
680 buffer
= mc_config_get_string(mc_main_config
, "Misc", "source_codepage", "");
681 if ( buffer
[0] != '\0' )
683 source_codepage
= get_codepage_index( buffer
);
684 cp_source
= get_codepage_id (source_codepage
);
688 init_translation_table( source_codepage
, display_codepage
);
689 if ( get_codepage_id( display_codepage
) )
690 utf8_display
= str_isutf8 (get_codepage_id( display_codepage
));
691 #endif /* HAVE_CHARSET */
694 #if defined(USE_VFS) && defined (USE_NETCODE)
700 buffer
= mc_config_get_string(mc_main_config
, "Misc", "ftpfs_password", "");
707 #endif /* USE_VFS && USE_NETCODE */
709 void done_setup (void)
711 g_free (global_keymap_name
);
712 g_free (profile_name
);
713 g_free (global_profile_name
);
714 g_free(color_terminal_string
);
715 g_free(term_color_string
);
716 g_free(setup_color_string
);
717 mc_config_deinit(mc_main_config
);
718 mc_config_deinit(mc_panels_config
);
721 /* directory_history_free (); */
725 load_keys_from_section (const char *terminal
, mc_config_t
*cfg
)
728 gchar
**profile_keys
, **keys
;
729 gchar
**values
, **curr_values
;
730 char *valcopy
, *value
;
732 gsize len
, values_len
;
737 section_name
= g_strconcat ("terminal:", terminal
, (char *) NULL
);
738 profile_keys
= keys
= mc_config_get_keys (cfg
, section_name
, &len
);
740 while (*profile_keys
){
742 /* copy=other causes all keys from [terminal:other] to be loaded. */
743 if (g_strcasecmp (*profile_keys
, "copy") == 0) {
744 valcopy
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
745 load_keys_from_section (valcopy
, cfg
);
750 curr_values
= values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, &values_len
);
752 key_code
= lookup_key (*profile_keys
);
755 while (*curr_values
){
756 valcopy
= convert_controls (*curr_values
);
757 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
762 value
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
763 valcopy
= convert_controls (value
);
764 define_sequence (key_code
, valcopy
, MCKEY_NOACTION
);
774 g_free (section_name
);
777 void load_key_defs (void)
780 * Load keys from mc.lib before ~/.mc/ini, so that the user
781 * definitions override global settings.
783 mc_config_t
*mc_global_config
;
785 mc_global_config
= mc_config_init(global_profile_name
);
786 if (mc_global_config
!= NULL
)
788 load_keys_from_section ("general", mc_global_config
);
789 load_keys_from_section (getenv ("TERM"), mc_global_config
);
790 mc_config_deinit(mc_global_config
);
792 load_keys_from_section ("general", mc_main_config
);
793 load_keys_from_section (getenv ("TERM"), mc_main_config
);
798 load_keymap_from_section (const char *section_name
, GArray
*keymap
, mc_config_t
*cfg
)
800 gchar
**profile_keys
, **keys
;
801 gchar
**values
, **curr_values
;
802 char *valcopy
, *value
;
804 gsize len
, values_len
;
809 profile_keys
= keys
= mc_config_get_keys (cfg
, section_name
, &len
);
811 while (*profile_keys
) {
812 curr_values
= values
= mc_config_get_string_list (cfg
, section_name
, *profile_keys
, &values_len
);
813 action
= lookup_action (*profile_keys
);
814 mc_log ("section: %s, val: %s, action: %i [%s]\n", section_name
, *curr_values
, action
, *profile_keys
);
817 while (*curr_values
){
818 valcopy
= convert_controls (*curr_values
);
819 keybind_cmd_bind (keymap
, valcopy
, action
);
824 value
= mc_config_get_string (cfg
, section_name
, *profile_keys
, "");
825 valcopy
= convert_controls (value
);
826 //define_sequence (key_code, valcopy, MCKEY_NOACTION);
839 load_keymap_defs (void)
842 * Load keymap from GLOBAL_KEYMAP_FILE before ~/.mc/keymap, so that the user
843 * definitions override global settings.
845 mc_config_t
*mc_global_keymap
;
847 mc_global_keymap
= mc_config_init(global_keymap_name
);
848 if (mc_global_keymap
!= NULL
)
850 editor_keymap
= g_array_new(TRUE
, FALSE
, sizeof(global_key_map_t
));
851 load_keymap_from_section ("editor", editor_keymap
, mc_global_keymap
);
853 viewer_keymap
= g_array_new(TRUE
, FALSE
, sizeof(global_key_map_t
));
854 load_keymap_from_section ("viewer", viewer_keymap
, mc_global_keymap
);
856 viewer_keymap
= g_array_new(TRUE
, FALSE
, sizeof(global_key_map_t
));
857 load_keymap_from_section ("viewer:hex", viewer_hex_keymap
, mc_global_keymap
);
859 main_keymap
= g_array_new(TRUE
, FALSE
, sizeof(global_key_map_t
));
860 load_keymap_from_section ("main", main_keymap
, mc_global_keymap
);
862 main_x_keymap
= g_array_new(TRUE
, FALSE
, sizeof(global_key_map_t
));
863 load_keymap_from_section ("main:xmap", main_x_keymap
, mc_global_keymap
);
865 panel_keymap
= g_array_new(TRUE
, FALSE
, sizeof(global_key_map_t
));
866 load_keymap_from_section ("panel", panel_keymap
, mc_global_keymap
);
868 mc_config_deinit(mc_global_keymap
);