From 09123c9fc9dfb5ca4b5198dc37b177d39b637436 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 1 Sep 2011 16:40:40 +0400 Subject: [PATCH] Refactoring of TTY layer shutdown. Unification of tty_shutdown() function as for S-Lang as for NCurses. Added do_exit_ca_mode() call to the NCurses-based tty_shutdown(). Signed-off-by: Andrew Borodin --- lib/tty/tty-ncurses.c | 7 ++++++- lib/tty/tty-slang.c | 5 ++++- src/filemanager/midnight.c | 30 ++++++++---------------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c index 0dfa9950d..5abb14d65 100644 --- a/lib/tty/tty-ncurses.c +++ b/lib/tty/tty-ncurses.c @@ -182,7 +182,12 @@ tty_init (gboolean slow, gboolean ugly_lines, gboolean mouse_enable, gboolean is void tty_shutdown (void) { - endwin (); + disable_mouse (); + tty_reset_shell_mode (); + tty_noraw_mode (); + tty_keypad (FALSE); + tty_reset_screen (); + do_exit_ca_mode (); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/tty/tty-slang.c b/lib/tty/tty-slang.c index fb2da0466..1653068c7 100644 --- a/lib/tty/tty-slang.c +++ b/lib/tty/tty-slang.c @@ -327,8 +327,11 @@ tty_shutdown (void) { char *op_cap; - SLsmg_reset_smg (); + disable_mouse (); tty_reset_shell_mode (); + tty_noraw_mode (); + tty_keypad (FALSE); + tty_reset_screen (); do_exit_ca_mode (); SLang_reset_tty (); diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index fbecf4c82..7f92ea0e5 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -42,8 +42,7 @@ #include "lib/global.h" #include "lib/tty/tty.h" -#include "lib/tty/mouse.h" -#include "lib/tty/key.h" /* For init_key() */ +#include "lib/tty/key.h" /* KEY_M_* masks */ #include "lib/tty/win.h" /* xterm_flag */ #include "lib/skin.h" #include "lib/util.h" @@ -851,37 +850,21 @@ setup_dummy_mc (void) /* --------------------------------------------------------------------------------------------- */ -static void -done_screen (void) -{ - if ((quit & SUBSHELL_EXIT) == 0) - clr_scr (); - tty_reset_shell_mode (); - tty_noraw_mode (); - tty_keypad (FALSE); -} - -/* --------------------------------------------------------------------------------------------- */ - static void done_mc (void) { - disable_mouse (); - /* Setup shutdown * * We sync the profiles since the hotlist may have changed, while * we only change the setup data if we have the auto save feature set */ + char *curr_dir; save_setup (auto_save_setup, panels_options.auto_save_setup); - done_screen (); - { - char *curr_dir = vfs_get_current_dir (); - vfs_stamp_path (curr_dir); - g_free (curr_dir); - } + curr_dir = vfs_get_current_dir (); + vfs_stamp_path (curr_dir); + g_free (curr_dir); if ((current_panel != NULL) && (get_current_type () == view_listing)) vfs_stamp_path (current_panel->cwd); @@ -1686,6 +1669,9 @@ do_nc (void) #ifdef USE_INTERNAL_EDIT edit_stack_free (); #endif + + if ((quit & SUBSHELL_EXIT) == 0) + clr_scr (); } /* --------------------------------------------------------------------------------------------- */