From d8a6993ec292019587a3c58e4aebc58501dd5b72 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 4 Mar 2009 15:34:04 +0100 Subject: [PATCH] add support for external console editor --- doc/config | 2 ++ src/lyrics.cpp | 18 +++++++++++++++++- src/settings.cpp | 5 +++++ src/settings.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/config b/doc/config index 86e95e07..fa18d7b9 100644 --- a/doc/config +++ b/doc/config @@ -169,6 +169,8 @@ # #external_editor = "" # +#use_console_editor = "no" (set to yes, if your editor is console app) +# ##### colors definitions ##### # #colors_enabled = "yes" diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 06e252de..18991e00 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -271,7 +271,23 @@ void Lyrics::Edit() } ShowMessage("Opening lyrics in external editor..."); - system(("nohup " + Config.external_editor + " \"" + Filename + "\" > /dev/null 2>&1 &").c_str()); + + if (Config.use_console_editor) + { + system(("/bin/sh -c \"" + Config.external_editor + " \\\"" + Filename + "\\\"\"").c_str()); + // below is needed as screen gets cleared, but apparently + // ncurses doesn't know about it, so we need to clear it + // for real and then restore it + clear(); + curs_set(1); + curs_set(0); + myScreen->Refresh(); + MPD::StatusChanges ch; + ch.StatusFlags = 1; + NcmpcppStatusChanged(Mpd, ch, 0); + } + else + system(("nohup " + Config.external_editor + " \"" + Filename + "\" > /dev/null 2>&1 &").c_str()); } #ifdef HAVE_CURL_CURL_H diff --git a/src/settings.cpp b/src/settings.cpp index dbf1b76a..50b3c0cf 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -268,6 +268,7 @@ void DefaultConfiguration(ncmpcpp_config &conf) conf.ignore_leading_the = false; conf.stop_after_current_song = false; conf.block_search_constraints_change = true; + conf.use_console_editor = false; conf.set_window_title = true; conf.mpd_port = 6600; conf.mpd_connection_timeout = 15; @@ -639,6 +640,10 @@ void ReadConfiguration(ncmpcpp_config &conf) { conf.ignore_leading_the = v == "yes"; } + else if (cl.find("use_console_editor") != string::npos) + { + conf.use_console_editor = v == "yes"; + } else if (cl.find("block_search_constraints_change_if_items_found") != string::npos) { conf.block_search_constraints_change = v == "yes"; diff --git a/src/settings.h b/src/settings.h index d304ba8a..e3dce65d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -160,6 +160,7 @@ struct ncmpcpp_config bool ignore_leading_the; bool stop_after_current_song; bool block_search_constraints_change; + bool use_console_editor; int mpd_port; int mpd_connection_timeout;