lyrics: move code that saves lyrics to separate function

master
Andrzej Rybczak 16 years ago
parent 443516acbf
commit d7f862ce86
  1. 22
      src/lyrics.cpp
  2. 1
      src/lyrics.h

@ -229,15 +229,11 @@ void *Lyrics::Get(void *screen_void_ptr)
if (result.first == true)
{
screen->w->Clear();
*screen->w << utf_to_locale_cpy(result.second);
screen->Save(result.second);
std::ofstream output(screen->itsFilenamePath.c_str());
if (output.is_open())
{
output << result.second;
output.close();
}
utf_to_locale(result.second);
screen->w->Clear();
*screen->w << result.second;
}
else
*screen->w << "\nLyrics weren't found.";
@ -273,6 +269,16 @@ void Lyrics::Edit()
system(("nohup " + Config.external_editor + " \"" + itsFilenamePath + "\" > /dev/null 2>&1 &").c_str());
}
void Lyrics::Save(const std::string &lyrics)
{
std::ofstream output(itsFilenamePath.c_str());
if (output.is_open())
{
output << lyrics;
output.close();
}
}
void Lyrics::FetchAgain()
{
std::string path = Folder + "/" + locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";

@ -46,6 +46,7 @@ class Lyrics : public Screen<Scrollpad>
virtual List *GetList() { return 0; }
void Edit();
void Save(const std::string &lyrics);
void FetchAgain();
static bool Reload;

Loading…
Cancel
Save