Restore curses after running external command
This allows running TUI tools like vim via run_external_command without destroying the ncmpcpp curses output.
This commit is contained in:
committed by
Andrzej Rybczak
parent
1ef061a87c
commit
81cb7a4f85
1
NEWS
1
NEWS
@@ -1,4 +1,5 @@
|
|||||||
ncmpcpp-0.9 (????-??-??)
|
ncmpcpp-0.9 (????-??-??)
|
||||||
|
* Restore curses window after running external command
|
||||||
|
|
||||||
ncmpcpp-0.8.2 (2018-04-11)
|
ncmpcpp-0.8.2 (2018-04-11)
|
||||||
* Help screen: fixed display of EoF keycode
|
* Help screen: fixed display of EoF keycode
|
||||||
|
|||||||
@@ -443,6 +443,17 @@ void initScreen(bool enable_colors, bool enable_mouse)
|
|||||||
rl_startup_hook = rl::add_base;
|
rl_startup_hook = rl::add_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pauseScreen()
|
||||||
|
{
|
||||||
|
def_prog_mode();
|
||||||
|
endwin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void unpauseScreen()
|
||||||
|
{
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
void destroyScreen()
|
void destroyScreen()
|
||||||
{
|
{
|
||||||
Mouse::disable();
|
Mouse::disable();
|
||||||
|
|||||||
@@ -219,6 +219,12 @@ void disable();
|
|||||||
/// @param enable_colors enables colors
|
/// @param enable_colors enables colors
|
||||||
void initScreen(bool enable_colors, bool enable_mouse);
|
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
|
/// Destroys the screen
|
||||||
void destroyScreen();
|
void destroyScreen();
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "bindings.h"
|
#include "bindings.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "macro_utilities.h"
|
#include "macro_utilities.h"
|
||||||
|
#include "curses/window.h"
|
||||||
#include "utility/string.h"
|
#include "utility/string.h"
|
||||||
#include "utility/wide_string.h"
|
#include "utility/wide_string.h"
|
||||||
|
|
||||||
@@ -87,7 +88,10 @@ RunExternalCommand::RunExternalCommand(std::string &&command)
|
|||||||
void RunExternalCommand::run()
|
void RunExternalCommand::run()
|
||||||
{
|
{
|
||||||
GNUC_UNUSED int res;
|
GNUC_UNUSED int res;
|
||||||
|
|
||||||
|
NC::pauseScreen();
|
||||||
res = std::system(m_command.c_str());
|
res = std::system(m_command.c_str());
|
||||||
|
NC::unpauseScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,12 +329,10 @@ void Lyrics::edit()
|
|||||||
if (Config.use_console_editor)
|
if (Config.use_console_editor)
|
||||||
{
|
{
|
||||||
command = "/bin/sh -c \"" + Config.external_editor + " \\\"" + filename + "\\\"\"";
|
command = "/bin/sh -c \"" + Config.external_editor + " \\\"" + filename + "\\\"\"";
|
||||||
|
NC::pauseScreen();
|
||||||
res = system(command.c_str());
|
res = system(command.c_str());
|
||||||
|
NC::unpauseScreen();
|
||||||
fetch(m_song);
|
fetch(m_song);
|
||||||
// Reset ncurses state to refresh the screen.
|
|
||||||
endwin();
|
|
||||||
initscr();
|
|
||||||
curs_set(0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user