📄 setup.c
字号:
int i;
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
/* Save integer options */
for (i = 0; options [i].opt_name; i++)
set_int (profile, options [i].opt_name, *options [i].opt_addr);
free (profile);
}
static void panel_save_type (char *section, int type)
{
int i;
for (i = 0; panel_types [i].opt_name; i++)
if (panel_types [i].opt_type == type){
save_string (section, "display", panel_types [i].opt_name,
profile_name);
break;
}
}
#ifndef PORT_HAS_SAVE_PANEL_TYPES
void save_panel_types ()
{
int type;
type = get_display_type (0);
panel_save_type ("New Left Panel", type);
if (type == view_listing)
panel_save_setup (left_panel, left_panel->panel_name);
type = get_display_type (1);
panel_save_type ("New Right Panel", type);
if (type == view_listing)
panel_save_setup (right_panel, right_panel->panel_name);
}
#endif
void save_setup (void)
{
char *profile;
#ifdef USE_VFS
#ifdef USE_NETCODE
extern char *ftpfs_anonymous_passwd;
extern char *ftpfs_proxy_host;
#endif
#endif
saving_setup = 1;
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
save_layout ();
save_configure ();
save_string ("Dirs", "other_dir",
get_other_type () == view_listing
? opanel->cwd : ".", profile);
WritePrivateProfileString ("Dirs", "current_is_left",
get_current_index () == 0 ? "1" : "0", profile);
save_hotlist ();
save_panelize ();
save_panel_types ();
/* directory_history_save (); */
#ifdef USE_VFS
#ifdef USE_NETCODE
WritePrivateProfileString ("Misc", "ftpfs_password",
ftpfs_anonymous_passwd, profile);
if (ftpfs_proxy_host)
WritePrivateProfileString ("Misc", "ftp_proxy_host",
ftpfs_proxy_host, profile);
#endif
#endif
free (profile);
saving_setup = 0;
}
void panel_load_setup (WPanel *panel, char *section)
{
int i;
char buffer [40];
panel->reverse = load_int (section, "reverse", 0);
panel->case_sensitive = load_int (section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
/* Load sort order */
load_string (section, "sort_order", "name", buffer, sizeof (buffer));
panel->sort_type = (sortfn *) sort_name;
for (i = 0; sort_names [i].key; i++)
if (strcasecmp (sort_names [i].key, buffer) == 0){
panel->sort_type = sort_names [i].sort_type;
break;
}
/* Load the listing mode */
load_string (section, PORT_LIST_MODE_NAME, PORT_LIST_MODE_DEFAULT, buffer, sizeof (buffer));
panel->list_type = list_full;
for (i = 0; list_types [i].key; i++)
if (strcasecmp (list_types [i].key, buffer) == 0){
panel->list_type = list_types [i].list_type;
break;
}
#ifndef PORT_HAS_ICON_VIEW
if (panel->list_type == list_icons)
panel->list_type = list_full;
#endif
/* User formats */
if (panel->user_format){
free (panel->user_format);
panel->user_format = 0;
}
panel->user_format = strdup (get_profile_string (section, "user_format",
DEFAULT_USER_FORMAT,
profile_name));
for (i = 0; i < LIST_TYPES; i++){
if (panel->user_status_format [i])
free (panel->user_status_format [i]);
sprintf (buffer, "user_status%d", i);
panel->user_status_format [i] =
strdup (get_profile_string (section, buffer,
DEFAULT_USER_FORMAT, profile_name));
}
panel->user_mini_status =
load_int (section, "user_mini_status", 0);
}
static void load_layout (char *profile_name)
{
int i;
for (i = 0; layout [i].opt_name; i++)
*layout [i].opt_addr =
load_int ("Layout", layout [i].opt_name,
*layout [i].opt_addr);
}
static int load_mode (char *section)
{
char buffer [20];
int i;
int mode = view_listing;
/* Load the display mode */
load_string (section, "display", "listing", buffer, sizeof (buffer));
for (i = 0; panel_types [i].opt_name; i++)
if (strcasecmp (panel_types [i].opt_name, buffer) == 0){
mode = panel_types [i].opt_type;
break;
}
return mode;
}
char *do_load_string (char *s, char *ss, char *def)
{
char *buffer = xmalloc (128, "dls");
char *p;
load_string (s, ss, def, buffer, 128);
p = strdup (buffer);
free (buffer);
return p;
}
void load_setup (void)
{
static char *buffer;
char *profile;
char *inifile;
int i;
#ifdef USE_NETCODE
extern char *ftpfs_proxy_host;
#endif
buffer = concat_dir_and_file (home_dir, PROFILE_NAME);
inifile = concat_dir_and_file (mc_home, "mc.ini");
if (exist_file (buffer)){
profile = buffer;
} else if (exist_file (inifile)){
profile = strdup (inifile);
free (buffer);
} else {
profile = buffer;
}
free (inifile);
profile_name = profile;
/* Load integer boolean options */
for (i = 0; options [i].opt_name; i++)
*options [i].opt_addr =
get_int (profile, options [i].opt_name, *options [i].opt_addr);
load_layout (profile);
load_panelize ();
startup_left_mode = load_mode ("New Left Panel");
startup_right_mode = load_mode ("New Right Panel");
/* At least one of the panels is a listing panel */
if (startup_left_mode != view_listing && startup_right_mode!=view_listing)
startup_left_mode = view_listing;
if (!other_dir){
buffer = (char*) malloc (MC_MAXPATHLEN);
load_string ("Dirs", "other_dir", ".", buffer,
MC_MAXPATHLEN);
if (vfs_file_is_local (buffer))
other_dir = buffer;
else
free (buffer);
}
#ifdef USE_NETCODE
ftpfs_proxy_host = do_load_string ("Misc", "ftp_proxy_host", "gate");
#endif
boot_current_is_left =
GetPrivateProfileInt ("Dirs", "current_is_left", 1, profile);
load_string ("Misc", "find_ignore_dirs", "", setup_color_string,
sizeof (setup_color_string));
if (setup_color_string [0])
find_ignore_dirs = copy_strings (":", setup_color_string, ":", 0);
/* The default color and the terminal dependent color */
load_string ("Colors", "base_color", "", setup_color_string,
sizeof (setup_color_string));
load_string ("Colors", getenv ("TERM"), "",
term_color_string, sizeof (term_color_string));
load_string ("Colors", "color_terminals", "",
color_terminal_string, sizeof (color_terminal_string));
/* Load the directory history */
/* directory_history_load (); */
/* Remove the temporal entries */
profile_clean_section ("Temporal:New Left Panel", profile_name);
profile_clean_section ("Temporal:New Right Panel", profile_name);
#ifdef USE_VFS
#ifdef USE_NETCODE
ftpfs_init_passwd ();
#endif
#endif
}
#ifdef USE_VFS
#ifdef USE_NETCODE
char *load_anon_passwd ()
{
char buffer [255];
load_string ("Misc", "ftpfs_password", "", buffer, sizeof (buffer));
if (buffer [0])
return strdup (buffer);
else
return 0;
}
#endif
#endif
void done_setup (void)
{
free (profile_name);
done_hotlist ();
done_panelize ();
/* directory_history_free (); */
}
void load_keys_from_section (char *terminal, char *profile_name)
{
char *section_name;
void *profile_keys;
char *key, *value, *valcopy;
int key_code;
if (!terminal)
return;
section_name = copy_strings ("terminal:", terminal, 0);
profile_keys = profile_init_iterator (section_name, profile_name);
if (!profile_keys){
free (section_name);
return;
}
while (profile_keys){
profile_keys = profile_iterator_next (profile_keys, &key, &value);
key_code = lookup_key (key);
valcopy = convert_controls (value);
if (key_code)
define_sequence (key_code, valcopy, MCKEY_NOACTION);
free (valcopy);
}
free (section_name);
return;
}
void load_key_defs (void)
{
char *libfile = concat_dir_and_file (mc_home, "mc.lib");
load_keys_from_section (getenv ("TERM"), profile_name);
load_keys_from_section ("general", profile_name);
load_keys_from_section (getenv ("TERM"), libfile);
load_keys_from_section ("general", libfile);
/* We don't want a huge database loaded in core */
free_profile_name (libfile);
free (libfile);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -