support for opening lyrics in external editor
This commit is contained in:
@@ -163,6 +163,8 @@
|
|||||||
#
|
#
|
||||||
#lyrics_database = "1"
|
#lyrics_database = "1"
|
||||||
#
|
#
|
||||||
|
#external_editor = ""
|
||||||
|
#
|
||||||
##### colors definitions #####
|
##### colors definitions #####
|
||||||
#
|
#
|
||||||
#colors_enabled = "yes"
|
#colors_enabled = "yes"
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ const std::string Lyrics::Folder = home_folder + "/.lyrics";
|
|||||||
|
|
||||||
bool Lyrics::Reload = 0;
|
bool Lyrics::Reload = 0;
|
||||||
|
|
||||||
|
std::string Lyrics::Filename;
|
||||||
|
|
||||||
#ifdef HAVE_CURL_CURL_H
|
#ifdef HAVE_CURL_CURL_H
|
||||||
pthread_mutex_t Global::curl = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t Global::curl = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
@@ -157,11 +159,11 @@ void *Lyrics::Get(void *song)
|
|||||||
|
|
||||||
string filename = artist + " - " + title + ".txt";
|
string filename = artist + " - " + title + ".txt";
|
||||||
EscapeUnallowedChars(filename);
|
EscapeUnallowedChars(filename);
|
||||||
const string fullpath = Folder + "/" + filename;
|
Filename = Folder + "/" + filename;
|
||||||
|
|
||||||
mkdir(Folder.c_str(), 0755);
|
mkdir(Folder.c_str(), 0755);
|
||||||
|
|
||||||
std::ifstream input(fullpath.c_str());
|
std::ifstream input(Filename.c_str());
|
||||||
|
|
||||||
if (input.is_open())
|
if (input.is_open())
|
||||||
{
|
{
|
||||||
@@ -237,7 +239,7 @@ void *Lyrics::Get(void *song)
|
|||||||
|
|
||||||
*myLyrics->Main() << utf_to_locale_cpy(result);
|
*myLyrics->Main() << utf_to_locale_cpy(result);
|
||||||
|
|
||||||
std::ofstream output(fullpath.c_str());
|
std::ofstream output(Filename.c_str());
|
||||||
if (output.is_open())
|
if (output.is_open())
|
||||||
{
|
{
|
||||||
output << result;
|
output << result;
|
||||||
@@ -252,6 +254,21 @@ void *Lyrics::Get(void *song)
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lyrics::Edit()
|
||||||
|
{
|
||||||
|
if (myScreen != this)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Config.external_editor.empty())
|
||||||
|
{
|
||||||
|
ShowMessage("External editor is not set!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowMessage("Opening lyrics in external editor...");
|
||||||
|
system(("nohup " + Config.external_editor + " \"" + Filename + "\" > /dev/null 2>&1 &").c_str());
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_CURL_CURL_H
|
#ifdef HAVE_CURL_CURL_H
|
||||||
|
|
||||||
void Lyrics::Take()
|
void Lyrics::Take()
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
|
|
||||||
virtual List *GetList() { return 0; }
|
virtual List *GetList() { return 0; }
|
||||||
|
|
||||||
|
void Edit();
|
||||||
|
|
||||||
static bool Reload;
|
static bool Reload;
|
||||||
|
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
@@ -67,6 +69,7 @@ class Lyrics : public Screen<Scrollpad>
|
|||||||
protected:
|
protected:
|
||||||
static void *Get(void *);
|
static void *Get(void *);
|
||||||
|
|
||||||
|
static std::string Filename;
|
||||||
static const std::string Folder;
|
static const std::string Folder;
|
||||||
|
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
|
|||||||
@@ -1126,6 +1126,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
|
if (myScreen == myLyrics)
|
||||||
|
{
|
||||||
|
myLyrics->Edit();
|
||||||
|
}
|
||||||
if (myScreen == myBrowser && myBrowser->Main()->Current().type == itDirectory)
|
if (myScreen == myBrowser && myBrowser->Main()->Current().type == itDirectory)
|
||||||
{
|
{
|
||||||
string old_dir = myBrowser->Main()->Current().name;
|
string old_dir = myBrowser->Main()->Current().name;
|
||||||
|
|||||||
@@ -508,6 +508,11 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.tag_editor_album_format = v;
|
conf.tag_editor_album_format = v;
|
||||||
}
|
}
|
||||||
|
else if (cl.find("external_editor") != string::npos)
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
conf.external_editor = v;
|
||||||
|
}
|
||||||
else if (cl.find("browser_playlist_prefix") != string::npos)
|
else if (cl.find("browser_playlist_prefix") != string::npos)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ struct ncmpcpp_config
|
|||||||
std::string song_library_format;
|
std::string song_library_format;
|
||||||
std::string media_lib_album_format;
|
std::string media_lib_album_format;
|
||||||
std::string tag_editor_album_format;
|
std::string tag_editor_album_format;
|
||||||
|
std::string external_editor;
|
||||||
|
|
||||||
std::string pattern;
|
std::string pattern;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user