diff --git a/src/main.c b/src/main.c index 95d80d5a4..5a362ee4c 100644 --- a/src/main.c +++ b/src/main.c @@ -46,9 +46,10 @@ #include "lib/tty/win.h" /* xterm_flag */ #include "lib/skin.h" #include "lib/filehighlight.h" +#include "lib/fileloc.h" #include "lib/strutil.h" #include "lib/util.h" -#include "lib/vfs/mc-vfs/vfs.h" /* vfs_translate_url() */ +#include "lib/vfs/mc-vfs/vfs.h" /* vfs_init(), vfs_shut() */ #include "args.h" #include "midnight.h" /* current_panel */ @@ -58,11 +59,6 @@ #include "layout.h" /* command_prompt */ #include "ext.h" /* flush_extension_file() */ #include "command.h" /* cmdline */ -#include "clipboard.h" /* clipboard_store_path, clipboard_store_path */ - -#ifdef USE_INTERNAL_EDIT -#include "src/editor/edit.h" /* edit_stack_init(), edit_stack_free() */ -#endif #ifdef HAVE_CHARSET #include "lib/charsets.h" @@ -213,7 +209,7 @@ OS_Setup (void) /* This variable is used by the subshell */ home_dir = getenv ("HOME"); - if (!home_dir) + if (home_dir == NULL) home_dir = mc_home; } @@ -440,10 +436,6 @@ main (int argc, char *argv[]) vfs_init (); -#ifdef USE_INTERNAL_EDIT - edit_stack_init (); -#endif - if (!mc_args_handle (argc, argv, "mc")) exit (EXIT_FAILURE); @@ -484,11 +476,8 @@ main (int argc, char *argv[]) load_keymap_defs (); tty_init_colors (mc_args__disable_colors, mc_args__force_colors); - isInitialized = mc_skin_init (&error); - mc_filehighlight = mc_fhl_new (TRUE); - dlg_set_default_colors (); if (!isInitialized) @@ -500,7 +489,7 @@ main (int argc, char *argv[]) /* create home directory */ /* do it after the screen library initialization to show the error message */ - mc_dir = concat_dir_and_file (home_dir, MC_USERCONF_DIR); + mc_dir = g_build_filename (home_dir, MC_USERCONF_DIR, (char *) NULL); canonicalize_pathname (mc_dir); if ((stat (mc_dir, &s) != 0) && (errno == ENOENT) && mkdir (mc_dir, 0700) != 0) message (D_ERROR, _("Warning"), _("Cannot create %s directory"), mc_dir); @@ -548,9 +537,12 @@ main (int argc, char *argv[]) mc_fhl_free (&mc_filehighlight); mc_skin_deinit (); + tty_colors_done (); tty_shutdown (); + done_setup (); + if (console_flag && (quit & SUBSHELL_EXIT) == 0) handle_console (CONSOLE_RESTORE); if (alternate_plus_minus) @@ -560,7 +552,6 @@ main (int argc, char *argv[]) if (console_flag) handle_console (CONSOLE_DONE); - putchar ('\n'); /* Hack to make shell's prompt start at left of screen */ if (mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL && last_wd_string != NULL && !print_last_revert) @@ -584,21 +575,13 @@ main (int argc, char *argv[]) g_free (shell); done_key (); -#ifdef HAVE_CHARSET - free_codepages_list (); - g_free (autodetect_codeset); -#endif - g_free (clipboard_store_path); - g_free (clipboard_paste_path); str_uninit_strings (); g_free (mc_run_param0); g_free (mc_run_param1); -#ifdef USE_INTERNAL_EDIT - edit_stack_free (); -#endif + putchar ('\n'); /* Hack to make shell's prompt start at left of screen */ return 0; } diff --git a/src/midnight.c b/src/midnight.c index 1e88f9190..9f1981e1c 100644 --- a/src/midnight.c +++ b/src/midnight.c @@ -44,6 +44,7 @@ #include "lib/tty/tty.h" #include "lib/tty/key.h" /* For init_key() */ +#include "lib/tty/mouse.h" #include "lib/tty/win.h" /* xterm_flag */ #include "lib/skin.h" #include "lib/util.h" @@ -821,7 +822,6 @@ done_screen (void) tty_reset_shell_mode (); tty_noraw_mode (); tty_keypad (FALSE); - tty_colors_done (); } /* --------------------------------------------------------------------------------------------- */ @@ -934,7 +934,6 @@ mc_maybe_editor_or_viewer (void) default: break; } - midnight_shutdown = 1; } /* --------------------------------------------------------------------------------------------- */ @@ -1284,6 +1283,7 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void switch (msg) { case DLG_INIT: + panel_init (); setup_panels (); return MSG_HANDLED; @@ -1464,6 +1464,10 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void } return MSG_HANDLED; + case DLG_END: + panel_deinit (); + return MSG_HANDLED; + default: return default_dlg_callback (h, sender, msg, parm, data); } @@ -1574,13 +1578,16 @@ void do_nc (void) { dlg_colors_t midnight_colors; + midnight_colors[DLG_COLOR_NORMAL] = mc_skin_color_get ("dialog", "_default_"); midnight_colors[DLG_COLOR_FOCUS] = mc_skin_color_get ("dialog", "focus"); midnight_colors[DLG_COLOR_HOT_NORMAL] = mc_skin_color_get ("dialog", "hotnormal"); midnight_colors[DLG_COLOR_HOT_FOCUS] = mc_skin_color_get ("dialog", "hotfocus"); midnight_colors[DLG_COLOR_TITLE] = mc_skin_color_get ("dialog", "title"); - panel_init (); +#ifdef USE_INTERNAL_EDIT + edit_stack_init (); +#endif midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback, "[main]", NULL, DLG_WANT_IDLE); @@ -1597,20 +1604,21 @@ do_nc (void) { create_panels_and_run_mc (); - /* Program end */ - midnight_shutdown = 1; - /* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */ if (mc_args__last_wd_file != NULL && vfs_current_is_local ()) last_wd_string = g_strdup (current_panel->cwd); } + /* Program end */ + midnight_shutdown = 1; dialog_switch_shutdown (); done_mc (); destroy_dlg (midnight_dlg); - panel_deinit (); - current_panel = 0; - done_setup (); + current_panel = NULL; + +#ifdef USE_INTERNAL_EDIT + edit_stack_free (); +#endif } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/setup.c b/src/setup.c index 9b30ff909..85446a4a8 100644 --- a/src/setup.c +++ b/src/setup.c @@ -990,6 +990,8 @@ done_setup (void) { size_t i; + g_free (clipboard_store_path); + g_free (clipboard_paste_path); g_free (profile_name); g_free (global_profile_name); g_free (color_terminal_string); @@ -1008,6 +1010,11 @@ done_setup (void) done_hotlist (); done_panelize (); /* directory_history_free (); */ + +#ifdef HAVE_CHARSET + g_free (autodetect_codeset); + free_codepages_list (); +#endif } /* --------------------------------------------------------------------------------------------- */