diff --git a/NEWS b/NEWS index a88b1b2b..280604dc 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ncmpcpp-0.9 (????-??-??) +* Restore curses window after running external command ncmpcpp-0.8.2 (2018-04-11) * Help screen: fixed display of EoF keycode diff --git a/src/curses/window.cpp b/src/curses/window.cpp index 0222888d..d9feebad 100644 --- a/src/curses/window.cpp +++ b/src/curses/window.cpp @@ -443,6 +443,17 @@ void initScreen(bool enable_colors, bool enable_mouse) rl_startup_hook = rl::add_base; } +void pauseScreen() +{ + def_prog_mode(); + endwin(); +} + +void unpauseScreen() +{ + refresh(); +} + void destroyScreen() { Mouse::disable(); diff --git a/src/curses/window.h b/src/curses/window.h index f53fc4b2..220f84d3 100644 --- a/src/curses/window.h +++ b/src/curses/window.h @@ -219,6 +219,12 @@ void disable(); /// @param enable_colors enables colors void initScreen(bool enable_colors, bool enable_mouse); +/// Pauses the screen (e.g. for running an external command) +void pauseScreen(); + +/// Unpauses the screen +void unpauseScreen(); + /// Destroys the screen void destroyScreen(); diff --git a/src/macro_utilities.cpp b/src/macro_utilities.cpp index 070f6b66..aeb0c1b1 100644 --- a/src/macro_utilities.cpp +++ b/src/macro_utilities.cpp @@ -21,6 +21,7 @@ #include "bindings.h" #include "global.h" #include "macro_utilities.h" +#include "curses/window.h" #include "utility/string.h" #include "utility/wide_string.h" @@ -87,7 +88,10 @@ RunExternalCommand::RunExternalCommand(std::string &&command) void RunExternalCommand::run() { GNUC_UNUSED int res; + + NC::pauseScreen(); res = std::system(m_command.c_str()); + NC::unpauseScreen(); } } diff --git a/src/screens/lyrics.cpp b/src/screens/lyrics.cpp index 047e55f8..c4552610 100644 --- a/src/screens/lyrics.cpp +++ b/src/screens/lyrics.cpp @@ -329,12 +329,10 @@ void Lyrics::edit() if (Config.use_console_editor) { command = "/bin/sh -c \"" + Config.external_editor + " \\\"" + filename + "\\\"\""; + NC::pauseScreen(); res = system(command.c_str()); + NC::unpauseScreen(); fetch(m_song); - // Reset ncurses state to refresh the screen. - endwin(); - initscr(); - curs_set(0); } else {