diff --git a/src/helpers.cpp b/src/helpers.cpp index 810ca30d..995cd194 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -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; diff --git a/src/helpers.h b/src/helpers.h index db6c9aa6..4014ec27 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -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 &Scroller(const std::string &, size_t, size_t &); diff --git a/src/info.cpp b/src/info.cpp index d1f65026..0c5a5f54 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -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(*w) << "Fetching artist's info..."; if (!Downloader) { pthread_create(&Downloader, NULL, PrepareArtist, artist); diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 4b5da927..a8b0abf8 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -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(*w) << "Fetching lyrics..."; if (!Downloader) { pthread_create(&Downloader, NULL, Get, &itsSong); diff --git a/src/media_library.cpp b/src/media_library.cpp index 4481f00a..112327ae 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -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 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)); diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 8bb91776..88d2a606 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -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; diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index c312cecd..92fdc8ed 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -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; } } diff --git a/src/search_engine.cpp b/src/search_engine.cpp index 5c665488..d7018edb 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -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(); } } diff --git a/src/status.cpp b/src/status.cpp index 52e128d2..9add06ea 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -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) diff --git a/src/status.h b/src/status.h index c509d49d..f11ed02f 100644 --- a/src/status.h +++ b/src/status.h @@ -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 diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 5882583b..b812fdbc 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -409,7 +409,7 @@ void TagEditor::Update() if (Config.albums_in_tag_editor) { std::map 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++) { diff --git a/src/window.cpp b/src/window.cpp index 080f9825..78cd0f61 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -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); diff --git a/src/window.h b/src/window.h index 7406fe76..e6e1eab2 100644 --- a/src/window.h +++ b/src/window.h @@ -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 &);