mc_fhl_t * mc_fhl_new (gboolean need_auto_fill) { mc_fhl_t *fhl; fhl = g_try_new0 (mc_fhl_t, 1); if (fhl == NULL) return NULL; if (!need_auto_fill) return fhl; if (!mc_fhl_init_from_standard_files (fhl)) { g_free (fhl); return NULL; } if (!mc_fhl_parse_ini_file (fhl)) { mc_fhl_free (&fhl); return NULL; } return fhl; }
static void skin_apply (const gchar * skin_override) { GError *mcerror = NULL; mc_skin_deinit (); mc_skin_init (skin_override, &mcerror); mc_fhl_free (&mc_filehighlight); mc_filehighlight = mc_fhl_new (TRUE); dlg_set_default_colors (); input_set_default_colors (); if (mc_global.mc_run_mode == MC_RUN_FULL) command_set_default_colors (); panel_deinit (); panel_init (); repaint_screen (); mc_error_message (&mcerror, NULL); }
void edit_fhl_cmd (void) { vfs_path_t *fhlfile_vpath = NULL; int dir; dir = 0; if (geteuid () == 0) { dir = query_dialog (_("Highlighting groups file edit"), _("Which highlighting file you want to edit?"), D_NORMAL, 2, _("&User"), _("&System Wide")); } fhlfile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, NULL); if (dir == 0) { vfs_path_t *buffer_vpath; buffer_vpath = mc_config_get_full_vpath (MC_FHL_INI_FILE); check_for_default (fhlfile_vpath, buffer_vpath); do_edit (buffer_vpath); vfs_path_free (buffer_vpath); } else if (dir == 1) { if (!exist_file (vfs_path_get_last_path_str (fhlfile_vpath))) { vfs_path_free (fhlfile_vpath); fhlfile_vpath = vfs_path_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, NULL); } do_edit (fhlfile_vpath); } vfs_path_free (fhlfile_vpath); /* refresh highlighting rules */ mc_fhl_free (&mc_filehighlight); mc_filehighlight = mc_fhl_new (TRUE); }
void edit_fhl_cmd (void) { char *buffer = NULL; char *fhlfile = NULL; int dir; dir = 0; if (geteuid () == 0) { dir = query_dialog (_("Highlighting groups file edit"), _("Which highlighting file you want to edit?"), D_NORMAL, 2, _("&User"), _("&System Wide")); } fhlfile = concat_dir_and_file (mc_global.sysconfig_dir, MC_FHL_INI_FILE); if (dir == 0) { buffer = mc_config_get_full_path (MC_FHL_INI_FILE); check_for_default (fhlfile, buffer); do_edit (buffer); g_free (buffer); } else if (dir == 1) { if (!exist_file (fhlfile)) { g_free (fhlfile); fhlfile = concat_dir_and_file (mc_global.sysconfig_dir, MC_FHL_INI_FILE); } do_edit (fhlfile); } g_free (fhlfile); /* refresh highlighting rules */ mc_fhl_free (&mc_filehighlight); mc_filehighlight = mc_fhl_new (TRUE); }
static void skin_apply (const gchar * skin_override) { GError *error = NULL; mc_skin_deinit (); mc_skin_init (skin_override, &error); mc_fhl_free (&mc_filehighlight); mc_filehighlight = mc_fhl_new (TRUE); dlg_set_default_colors (); input_set_default_colors (); if (mc_global.mc_run_mode == MC_RUN_FULL) command_set_default_colors (); panel_deinit (); panel_init (); repaint_screen (); if (error != NULL) { message (D_ERROR, _("Warning"), "%s", error->message); g_error_free (error); } }
int main (int argc, char *argv[]) { GError *error = NULL; int exit_code = EXIT_FAILURE; /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ (void) setlocale (LC_ALL, ""); (void) bindtextdomain ("mc", LOCALEDIR); (void) textdomain ("mc"); /* do this before args parsing */ str_init_strings (NULL); if (!mc_args_parse (&argc, &argv, "mc", &error)) { startup_exit_falure: fprintf (stderr, _("Failed to run:\n%s\n"), error->message); g_error_free (error); g_free (shell); startup_exit_ok: str_uninit_strings (); return exit_code; } /* do this before mc_args_show_info () to view paths in the --datadir-info output */ OS_Setup (); if (!g_path_is_absolute (mc_config_get_home_dir ())) { error = g_error_new (MC_ERROR, 0, "%s: %s", _("Home directory path is not absolute"), mc_config_get_home_dir ()); mc_event_deinit (NULL); goto startup_exit_falure; } if (!mc_args_show_info ()) { exit_code = EXIT_SUCCESS; goto startup_exit_ok; } if (!events_init (&error)) goto startup_exit_falure; mc_config_init_config_paths (&error); if (error == NULL && mc_config_deprecated_dir_present ()) mc_config_migrate_from_old_place (&error); if (error != NULL) { mc_event_deinit (NULL); goto startup_exit_falure; } vfs_init (); vfs_plugins_init (); vfs_setup_work_dir (); /* do this after vfs initialization due to mc_setctl() call in mc_setup_by_args() */ if (!mc_setup_by_args (argc, argv, &error)) { vfs_shut (); mc_event_deinit (NULL); goto startup_exit_falure; } /* check terminal type * $TEMR must be set and not empty * mc_global.tty.xterm_flag is used in init_key() and tty_init() * Do this after mc_args_handle() where mc_args__force_xterm is set up. */ mc_global.tty.xterm_flag = tty_check_term (mc_args__force_xterm); /* NOTE: This has to be called before tty_init or whatever routine calls any define_sequence */ init_key (); /* Must be done before installing the SIGCHLD handler [[FIXME]] */ handle_console (CONSOLE_INIT); #ifdef HAVE_SUBSHELL_SUPPORT /* Don't use subshell when invoked as viewer or editor */ if (mc_global.mc_run_mode != MC_RUN_FULL) mc_global.tty.use_subshell = FALSE; if (mc_global.tty.use_subshell) subshell_get_console_attributes (); #endif /* HAVE_SUBSHELL_SUPPORT */ /* Install the SIGCHLD handler; must be done before init_subshell() */ init_sigchld (); /* We need this, since ncurses endwin () doesn't restore the signals */ save_stop_handler (); /* Must be done before init_subshell, to set up the terminal size: */ /* FIXME: Should be removed and LINES and COLS computed on subshell */ tty_init (!mc_args__nomouse, mc_global.tty.xterm_flag); load_setup (); /* start check mc_global.display_codepage and mc_global.source_codepage */ check_codeset (); /* Removing this from the X code let's us type C-c */ load_key_defs (); load_keymap_defs (!mc_args__nokeymap); macros_list = g_array_new (TRUE, FALSE, sizeof (macros_t)); tty_init_colors (mc_global.tty.disable_colors, mc_args__force_colors); mc_skin_init (&error); if (error != NULL) { message (D_ERROR, _("Warning"), "%s", error->message); g_error_free (error); error = NULL; } mc_filehighlight = mc_fhl_new (TRUE); dlg_set_default_colors (); #ifdef HAVE_SUBSHELL_SUPPORT /* Done here to ensure that the subshell doesn't */ /* inherit the file descriptors opened below, etc */ if (mc_global.tty.use_subshell) init_subshell (); #endif /* HAVE_SUBSHELL_SUPPORT */ /* Also done after init_subshell, to save any shell init file messages */ if (mc_global.tty.console_flag != '\0') handle_console (CONSOLE_SAVE); if (mc_global.tty.alternate_plus_minus) application_keypad_mode (); #ifdef HAVE_SUBSHELL_SUPPORT if (mc_global.tty.use_subshell) { mc_prompt = strip_ctrl_codes (subshell_prompt); if (mc_prompt == NULL) mc_prompt = (geteuid () == 0) ? "# " : "$ "; } else #endif /* HAVE_SUBSHELL_SUPPORT */ mc_prompt = (geteuid () == 0) ? "# " : "$ "; /* Program main loop */ if (mc_global.midnight_shutdown) exit_code = EXIT_SUCCESS; else exit_code = do_nc ()? EXIT_SUCCESS : EXIT_FAILURE; /* Save the tree store */ (void) tree_store_save (); free_keymap_defs (); /* Virtual File System shutdown */ vfs_shut (); flush_extension_file (); /* does only free memory */ mc_fhl_free (&mc_filehighlight); mc_skin_deinit (); tty_colors_done (); tty_shutdown (); done_setup (); if (mc_global.tty.console_flag != '\0' && (quit & SUBSHELL_EXIT) == 0) handle_console (CONSOLE_RESTORE); if (mc_global.tty.alternate_plus_minus) numeric_keypad_mode (); (void) signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */ if (mc_global.tty.console_flag != '\0') handle_console (CONSOLE_DONE); if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL && last_wd_string != NULL && !print_last_revert) { int last_wd_fd; last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR); if (last_wd_fd != -1) { ssize_t ret1; int ret2; ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string)); ret2 = close (last_wd_fd); } } g_free (last_wd_string); g_free (shell); done_key (); if (macros_list != NULL) { guint i; macros_t *macros; for (i = 0; i < macros_list->len; i++) { macros = &g_array_index (macros_list, struct macros_t, i); if (macros != NULL && macros->macro != NULL) (void) g_array_free (macros->macro, FALSE); } (void) g_array_free (macros_list, TRUE); }