static inline void status_string (WEdit * edit, char *s, int w) { char byte_str[16]; /* * If we are at the end of file, print <EOF>, * otherwise print the current character as is (if printable), * as decimal and as hex. */ if (edit->curs1 < edit->last_byte) { #ifdef HAVE_CHARSET if (edit->utf8) { unsigned int cur_utf = 0; int cw = 1; cur_utf = edit_get_utf (edit, edit->curs1, &cw); if (cw > 0) { g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X", (unsigned) cur_utf, (unsigned) cur_utf); } else { cur_utf = edit_get_byte (edit, edit->curs1); g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X", (int) cur_utf, (unsigned) cur_utf); } } else #endif { unsigned char cur_byte = 0; cur_byte = edit_get_byte (edit, edit->curs1); g_snprintf (byte_str, sizeof (byte_str), "%4d 0x%03X", (int) cur_byte, (unsigned) cur_byte); } } else { strcpy (byte_str, "<EOF> "); } /* The field lengths just prevent the status line from shortening too much */ if (simple_statusbar) g_snprintf (s, w, "%c%c%c%c %3ld %5ld/%ld %6ld/%ld %s %s", edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-', edit->modified ? 'M' : '-', macro_index < 0 ? '-' : 'R', edit->overwrite == 0 ? '-' : 'O', edit->curs_col + edit->over_col, edit->curs_line + 1, edit->total_lines + 1, (long) edit->curs1, (long) edit->last_byte, byte_str, #ifdef HAVE_CHARSET mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : #endif ""); else g_snprintf (s, w, "[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb) %s %s", edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-', edit->modified ? 'M' : '-', macro_index < 0 ? '-' : 'R', edit->overwrite == 0 ? '-' : 'O', edit->curs_col + edit->over_col, edit->start_line + 1, edit->curs_row, edit->curs_line + 1, edit->total_lines + 1, (long) edit->curs1, (long) edit->last_byte, byte_str, #ifdef HAVE_CHARSET mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : #endif ""); }
void load_setup (void) { const char *profile; size_t i; const char *kt; #ifdef HAVE_CHARSET char *buffer; load_codepages_list (); #endif /* HAVE_CHARSET */ profile = setup_init (); /* mc.lib is common for all users, but has priority lower than ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */ global_profile_name = g_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL); if (!exist_file (global_profile_name)) { g_free (global_profile_name); global_profile_name = g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL); } panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE); mc_main_config = mc_config_init (profile, FALSE); if (!exist_file (panels_profile_name)) setup__move_panels_config_into_separate_file (profile); mc_panels_config = mc_config_init (panels_profile_name, FALSE); /* Load integer boolean options */ for (i = 0; int_options[i].opt_name != NULL; i++) *int_options[i].opt_addr = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name, *int_options[i].opt_addr); #ifndef USE_INTERNAL_EDIT /* reset forced in case of build without internal editor */ use_internal_edit = 0; #endif /* USE_INTERNAL_EDIT */ if (option_tab_spacing <= 0) option_tab_spacing = DEFAULT_TAB_SPACING; #ifdef USE_INTERNAL_EDIT if (option_word_wrap_line_length <= 0) option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH; #endif /* USE_INTERNAL_EDIT */ /* overwrite old_esc_mode_timeout */ kt = getenv ("KEYBOARD_KEY_TIMEOUT_US"); if ((kt != NULL) && (kt[0] != '\0')) old_esc_mode_timeout = atoi (kt); /* Load string options */ for (i = 0; str_options[i].opt_name != NULL; i++) *str_options[i].opt_addr = mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, str_options[i].opt_defval); load_layout (); panels_load_options (); load_panelize (); startup_left_mode = setup__load_panel_state ("New Left Panel"); startup_right_mode = setup__load_panel_state ("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; boot_current_is_left = mc_config_get_bool (mc_panels_config, "Dirs", "current_is_left", TRUE); /* Load time formats */ user_recent_timeformat = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_recent", FMTTIME); user_old_timeformat = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_old", FMTYEAR); #ifdef ENABLE_VFS_FTP ftpfs_proxy_host = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate"); ftpfs_ignore_chattr_errors = mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION, "ignore_ftp_chattr_errors", TRUE); ftpfs_init_passwd (); #endif /* ENABLE_VFS_FTP */ /* The default color and the terminal dependent color */ mc_global.tty.setup_color_string = mc_config_get_string (mc_main_config, "Colors", "base_color", ""); mc_global.tty.term_color_string = mc_config_get_string (mc_main_config, "Colors", getenv ("TERM"), ""); mc_global.tty.color_terminal_string = mc_config_get_string (mc_main_config, "Colors", "color_terminals", ""); /* Load the directory history */ /* directory_history_load (); */ /* Remove the temporal entries */ #ifdef HAVE_CHARSET if (codepages->len > 1) { buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage", ""); if (buffer[0] != '\0') { mc_global.display_codepage = get_codepage_index (buffer); cp_display = get_codepage_id (mc_global.display_codepage); } g_free (buffer); buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "source_codepage", ""); if (buffer[0] != '\0') { default_source_codepage = get_codepage_index (buffer); mc_global.source_codepage = default_source_codepage; /* May be source_codepage doesn't need this */ cp_source = get_codepage_id (mc_global.source_codepage); } g_free (buffer); } autodetect_codeset = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset", ""); if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0)) is_autodetect_codeset_enabled = TRUE; g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage)); buffer = (char *) get_codepage_id (mc_global.display_codepage); if (buffer != NULL) mc_global.utf8_display = str_isutf8 (buffer); #endif /* HAVE_CHARSET */ #ifdef HAVE_ASPELL spell_language = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", "en"); #endif /* HAVE_ASPELL */ clipboard_store_path = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", ""); clipboard_paste_path = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste", ""); }