use streams instead of Window::WriteXY()
This commit is contained in:
@@ -287,13 +287,6 @@ string GetLineValue(string &line, char a, char b, bool once)
|
||||
return "";
|
||||
}
|
||||
|
||||
Window &Statusbar()
|
||||
{
|
||||
wFooter->GotoXY(0, Config.statusbar_visibility);
|
||||
wclrtoeol(wFooter->Raw());
|
||||
return *wFooter;
|
||||
}
|
||||
|
||||
const Buffer &ShowTag(const string &tag)
|
||||
{
|
||||
static Buffer result;
|
||||
|
||||
@@ -46,8 +46,6 @@ std::string FindSharedDir(const std::string &, const std::string &);
|
||||
|
||||
std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0);
|
||||
|
||||
Window &Statusbar();
|
||||
|
||||
const Buffer &ShowTag(const std::string &);
|
||||
|
||||
const std::basic_string<my_char_t> &Scroller(const std::string &, size_t, size_t &);
|
||||
|
||||
@@ -142,7 +142,7 @@ void Info::GetArtist()
|
||||
redraw_header = 1;
|
||||
itsTitle = "Artist's info - " + *artist;
|
||||
w->Clear();
|
||||
w->WriteXY(0, 0, 0, "Fetching artist's info...");
|
||||
static_cast<Window &>(*w) << "Fetching artist's info...";
|
||||
if (!Downloader)
|
||||
{
|
||||
pthread_create(&Downloader, NULL, PrepareArtist, artist);
|
||||
|
||||
@@ -121,7 +121,7 @@ void Lyrics::SwitchTo()
|
||||
redraw_header = 1;
|
||||
w->Clear();
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
w->WriteXY(0, 0, 0, "Fetching lyrics...");
|
||||
static_cast<Window &>(*w) << "Fetching lyrics...";
|
||||
if (!Downloader)
|
||||
{
|
||||
pthread_create(&Downloader, NULL, Get, &itsSong);
|
||||
|
||||
@@ -98,8 +98,7 @@ void MediaLibrary::Refresh()
|
||||
Songs->Display();
|
||||
if (Albums->Empty())
|
||||
{
|
||||
Albums->WriteXY(0, 0, 0, "No albums found.");
|
||||
Albums->Refresh();
|
||||
*Albums << XY(0, 0) << "No albums found." << wrefresh;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,8 +212,7 @@ void MediaLibrary::Update()
|
||||
Mpd->AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(Artists->Current()));
|
||||
if (Albums->Empty()) // left for compatibility with <mpd-0.14
|
||||
{
|
||||
Albums->WriteXY(0, 0, 0, "No albums found.");
|
||||
Albums->Refresh();
|
||||
*Albums << XY(0, 0) << "No albums found." << wrefresh;
|
||||
}
|
||||
else
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, locale_to_utf_cpy(Albums->Current().second));
|
||||
|
||||
@@ -218,9 +218,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (title_allowed)
|
||||
{
|
||||
wHeader->Bold(1);
|
||||
wHeader->WriteXY(0, 0, 1, "%s", myScreen->Title().c_str());
|
||||
wHeader->Bold(0);
|
||||
*wHeader << XY(0, 0) << wclrtoeol << fmtBold << myScreen->Title() << fmtBoldEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -240,7 +238,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
wHeader->SetColor(Config.volume_color);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, 0, "%s", volume_state.c_str());
|
||||
*wHeader << XY(wHeader->GetWidth()-volume_state.length(), 0) << volume_state;
|
||||
wHeader->SetColor(Config.header_color);
|
||||
wHeader->Refresh();
|
||||
redraw_header = 0;
|
||||
@@ -873,7 +871,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
wFooter->Bold(1);
|
||||
string tracklength = "[" + Song::ShowTime(songpos) + "/" + s.GetLength() + "]";
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, 0, "%s", tracklength.c_str());
|
||||
*wFooter << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength;
|
||||
double progressbar_size = (double)songpos/(s.GetTotalLength());
|
||||
int howlong = wFooter->GetWidth()*progressbar_size;
|
||||
|
||||
|
||||
@@ -157,8 +157,7 @@ void PlaylistEditor::Update()
|
||||
|
||||
if (Content->Empty())
|
||||
{
|
||||
Content->WriteXY(0, 0, 0, "Playlist is empty.");
|
||||
Content->Refresh();
|
||||
*Content << XY(0, 0) << "Playlist is empty." << wrefresh;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ void SearchEngine::SwitchTo()
|
||||
|
||||
if (!w->Back().first)
|
||||
{
|
||||
w->WriteXY(0, 0, 0, "Updating list...");
|
||||
*w << XY(0, 0) << "Updating list...";
|
||||
UpdateFoundList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,13 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
}
|
||||
}
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
wFooter->WriteXY(0, 1, player_state.empty(), "%s", player_state.c_str());
|
||||
{
|
||||
*wFooter << XY(0, 1);
|
||||
if (player_state.empty())
|
||||
*wFooter << wclrtoeol;
|
||||
else
|
||||
*wFooter << player_state;
|
||||
}
|
||||
}
|
||||
if (changed.SongID)
|
||||
{
|
||||
@@ -357,12 +363,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
tracklength += Song::ShowTime(elapsed);
|
||||
tracklength += "]";
|
||||
}
|
||||
wFooter->WriteXY(0, 1, 1, "%s", player_state.c_str());
|
||||
wFooter->Bold(0);
|
||||
*wFooter << Scroller(utf_to_locale_cpy(s.toString(Config.song_status_format)), wFooter->GetWidth()-player_state.length()-tracklength.length(), playing_song_scroll_begin);
|
||||
wFooter->Bold(1);
|
||||
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, 1, "%s", tracklength.c_str());
|
||||
*wFooter << XY(0, 1) << wclrtoeol << player_state
|
||||
<< fmtBoldEnd
|
||||
<< Scroller(utf_to_locale_cpy(s.toString(Config.song_status_format)), wFooter->GetWidth()-player_state.length()-tracklength.length(), playing_song_scroll_begin)
|
||||
<< fmtBold
|
||||
<< XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength;
|
||||
}
|
||||
if (!block_progressbar_update)
|
||||
{
|
||||
@@ -381,7 +386,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
else
|
||||
{
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
wFooter->WriteXY(0, 1, 1, "");
|
||||
*wFooter << XY(0, 1) << wclrtoeol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +450,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
volume_state += IntoStr(Mpd->GetVolume());
|
||||
volume_state += "%";
|
||||
wHeader->SetColor(Config.volume_color);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, 1, "%s", volume_state.c_str());
|
||||
*wHeader << XY(wHeader->GetWidth()-volume_state.length(), 0) << volume_state;
|
||||
wHeader->SetColor(Config.header_color);
|
||||
wHeader->Refresh();
|
||||
}
|
||||
@@ -456,6 +461,12 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
wFooter->Refresh();
|
||||
}
|
||||
|
||||
Window &Statusbar()
|
||||
{
|
||||
*wFooter << XY(0, Config.statusbar_visibility) << wclrtoeol;
|
||||
return *wFooter;
|
||||
}
|
||||
|
||||
void ShowMessage(const char *format, ...)
|
||||
{
|
||||
if (messages_allowed)
|
||||
|
||||
@@ -31,6 +31,7 @@ void TraceMpdStatus();
|
||||
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges, void *);
|
||||
void NcmpcppErrorCallback(MPD::Connection *, int, const char *, void *);
|
||||
|
||||
Window &Statusbar();
|
||||
void ShowMessage(const char *, ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -409,7 +409,7 @@ void TagEditor::Update()
|
||||
if (Config.albums_in_tag_editor)
|
||||
{
|
||||
std::map<string, string, CaseInsensitiveSorting> maplist;
|
||||
Albums->WriteXY(0, 0, 0, "Fetching albums' list...");
|
||||
*Albums << XY(0, 0) << "Fetching albums' list...";
|
||||
Mpd->GetAlbums("", list);
|
||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
|
||||
@@ -332,7 +332,7 @@ void Window::ReadKey() const
|
||||
wgetch(itsWindow);
|
||||
}
|
||||
|
||||
void Window::Write(bool cte, const char *format, ...) const
|
||||
/*void Window::Write(bool cte, const char *format, ...) const
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
@@ -351,7 +351,7 @@ void Window::WriteXY(int x, int y, bool cte, const char *format, ...) const
|
||||
va_end(list);
|
||||
if (cte)
|
||||
wclrtoeol(itsWindow);
|
||||
}
|
||||
}*/
|
||||
|
||||
string Window::GetString(const string &base, size_t length, size_t width, bool encrypted) const
|
||||
{
|
||||
@@ -703,6 +703,12 @@ Window &Window::operator<<(const Format &format)
|
||||
return *this;
|
||||
}
|
||||
|
||||
Window &Window::operator<<(int (*f)(WINDOW *))
|
||||
{
|
||||
f(itsWindow);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Window &Window::operator<<(const XY &coords)
|
||||
{
|
||||
GotoXY(coords.x, coords.y);
|
||||
|
||||
@@ -122,12 +122,13 @@ class Window
|
||||
void ReadKey(int &) const;
|
||||
void ReadKey() const;
|
||||
|
||||
void Write(bool, const char *, ...) const;
|
||||
void WriteXY(int, int, bool, const char *, ...) const;
|
||||
//void Write(bool, const char *, ...) const;
|
||||
//void WriteXY(int, int, bool, const char *, ...) const;
|
||||
|
||||
void Scrollable(bool) const;
|
||||
virtual void Scroll(Where);
|
||||
|
||||
Window &operator<<(int (*)(WINDOW *));
|
||||
Window &operator<<(const Colors &);
|
||||
Window &operator<<(const Color &);
|
||||
Window &operator<<(const Format &);
|
||||
|
||||
Reference in New Issue
Block a user