update Window::WriteXY() and related stuff
This commit is contained in:
@@ -847,6 +847,7 @@ void ShowMessage(const char *format, ...)
|
||||
block_statusbar_update = 1;
|
||||
else
|
||||
block_progressbar_update = 1;
|
||||
wFooter->GotoXY(0, Config.statusbar_visibility);
|
||||
wFooter->Bold(0);
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
|
||||
@@ -259,6 +259,11 @@ void Menu<T>::Swap(size_t one, size_t two)
|
||||
|
||||
template <class T> void Menu<T>::Refresh()
|
||||
{
|
||||
if (itsOptions.empty())
|
||||
{
|
||||
wrefresh(itsWindow);
|
||||
return;
|
||||
}
|
||||
int MaxBeginning = itsOptions.size() < itsHeight ? 0 : itsOptions.size()-itsHeight;
|
||||
if (itsBeginning < 0)
|
||||
itsBeginning = 0;
|
||||
|
||||
@@ -53,7 +53,10 @@
|
||||
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
|
||||
mLibSongs->Display(); \
|
||||
if (mLibAlbums->Empty()) \
|
||||
mLibAlbums->WriteXY(0, 0, "No albums found."); \
|
||||
{ \
|
||||
mLibAlbums->WriteXY(0, 0, 0, "No albums found."); \
|
||||
mLibAlbums->Refresh(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
||||
@@ -419,11 +422,11 @@ int main(int argc, char *argv[])
|
||||
if (title_allowed)
|
||||
{
|
||||
wHeader->Bold(1);
|
||||
wHeader->WriteXY(0, 0, max_allowed_title_length, title, 1);
|
||||
wHeader->WriteXY(0, 0, 1, "%s", title.c_str());
|
||||
wHeader->Bold(0);
|
||||
|
||||
if (current_screen == csPlaylist && !playlist_stats.empty())
|
||||
wHeader->WriteXY(title.length(), 0, max_allowed_title_length-title.length(), playlist_stats);
|
||||
wHeader->WriteXY(title.length(), 0, 0, "%s", playlist_stats.c_str());
|
||||
else if (current_screen == csBrowser)
|
||||
{
|
||||
size_t max_length_without_scroll = wHeader->GetWidth()-volume_state.length()-title.length();
|
||||
@@ -440,12 +443,12 @@ int main(int argc, char *argv[])
|
||||
my_string_t part = wbrowseddir.substr(browsed_dir_scroll_begin++, scrollsize);
|
||||
if (part.length() < scrollsize)
|
||||
part += wbrowseddir.substr(0, scrollsize-part.length());
|
||||
wHeader->WriteXY(title.length(), 0, part);
|
||||
wHeader->WriteXY(title.length(), 0, 0, UTF_S_FMT, part.c_str());
|
||||
if (browsed_dir_scroll_begin >= wbrowseddir.length())
|
||||
browsed_dir_scroll_begin = 0;
|
||||
}
|
||||
else
|
||||
wHeader->WriteXY(title.length(), 0, browsed_dir);
|
||||
wHeader->WriteXY(title.length(), 0, 0, "%s", browsed_dir.c_str());
|
||||
wHeader->Bold(0);
|
||||
}
|
||||
}
|
||||
@@ -455,16 +458,21 @@ int main(int argc, char *argv[])
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
screens += " [.b]7:[/b]Tag editor";
|
||||
# endif // HAVE_TAGLIB_H
|
||||
wHeader->WriteXY(0, 0, max_allowed_title_length, screens, 1);
|
||||
wHeader->WriteXY(0, 0, 1, "%s", screens.c_str());
|
||||
}
|
||||
|
||||
wHeader->SetColor(Config.volume_color);
|
||||
wHeader->WriteXY(max_allowed_title_length, 0, volume_state);
|
||||
wHeader->WriteXY(max_allowed_title_length, 0, 0, "%s", volume_state.c_str());
|
||||
wHeader->SetColor(Config.header_color);
|
||||
wHeader->Refresh();
|
||||
redraw_header = 0;
|
||||
}
|
||||
// header stuff end
|
||||
|
||||
if (current_screen == csHelp
|
||||
|| current_screen == csPlaylist
|
||||
|| current_screen == csBrowser);
|
||||
else
|
||||
// media library stuff
|
||||
if (current_screen == csLibrary)
|
||||
{
|
||||
@@ -531,7 +539,8 @@ int main(int argc, char *argv[])
|
||||
SongList list;
|
||||
if (mLibAlbums->Empty())
|
||||
{
|
||||
mLibAlbums->WriteXY(0, 0, "No albums found.");
|
||||
mLibAlbums->WriteXY(0, 0, 0, "No albums found.");
|
||||
mLibAlbums->Refresh();
|
||||
mLibSongs->Clear(0);
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
||||
@@ -618,7 +627,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (mPlaylistEditor->Empty())
|
||||
mPlaylistEditor->WriteXY(0, 0, "Playlist is empty.");
|
||||
{
|
||||
mPlaylistEditor->WriteXY(0, 0, 0, "Playlist is empty.");
|
||||
mPlaylistEditor->Refresh();
|
||||
}
|
||||
}
|
||||
// playlist editor end
|
||||
else
|
||||
@@ -635,7 +647,7 @@ int main(int argc, char *argv[])
|
||||
if (Config.albums_in_tag_editor)
|
||||
{
|
||||
std::map<string, string, CaseInsensitiveSorting> maplist;
|
||||
mEditorAlbums->WriteXY(0, 0, "Fetching albums' list...");
|
||||
mEditorAlbums->WriteXY(0, 0, 0, "Fetching albums' list...");
|
||||
Mpd->GetAlbums("", list);
|
||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
@@ -2427,7 +2439,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
wFooter->Bold(1);
|
||||
string tracklength = "[" + Song::ShowTime(songpos) + "/" + s.GetLength() + "]";
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, tracklength);
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, 0, "%s", tracklength.c_str());
|
||||
double progressbar_size = (double)songpos/(s.GetTotalLength());
|
||||
int howlong = wFooter->GetWidth()*progressbar_size;
|
||||
|
||||
@@ -3305,7 +3317,7 @@ int main(int argc, char *argv[])
|
||||
redraw_header = 1;
|
||||
info_title = "Artist's info - " + *artist;
|
||||
sInfo->Clear();
|
||||
sInfo->WriteXY(0, 0, "Fetching artist's info...");
|
||||
sInfo->WriteXY(0, 0, 0, "Fetching artist's info...");
|
||||
sInfo->Refresh();
|
||||
if (!artist_info_downloader)
|
||||
{
|
||||
@@ -3396,7 +3408,7 @@ int main(int argc, char *argv[])
|
||||
wCurrent->Clear();
|
||||
current_screen = csLyrics;
|
||||
lyrics_title = "Lyrics: " + s->GetArtist() + " - " + s->GetTitle();
|
||||
sLyrics->WriteXY(0, 0, "Fetching lyrics...");
|
||||
sLyrics->WriteXY(0, 0, 0, "Fetching lyrics...");
|
||||
sLyrics->Refresh();
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
if (!lyrics_downloader)
|
||||
@@ -3467,7 +3479,7 @@ int main(int argc, char *argv[])
|
||||
redraw_header = 1;
|
||||
if (!mSearcher->Back().first)
|
||||
{
|
||||
wCurrent->WriteXY(0, 0, "Updating list...");
|
||||
wCurrent->WriteXY(0, 0, 0, "Updating list...");
|
||||
UpdateFoundList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
}
|
||||
}
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
wFooter->WriteXY(0, 1, player_state, player_state.empty());
|
||||
wFooter->WriteXY(0, 1, player_state.empty(), "%s", player_state.c_str());
|
||||
}
|
||||
if (changed.SongID)
|
||||
{
|
||||
@@ -339,7 +339,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
|
||||
const size_t max_length_without_scroll = wFooter->GetWidth()-player_state.length()-tracklength.length();
|
||||
|
||||
wFooter->WriteXY(0, 1, player_state);
|
||||
wFooter->WriteXY(0, 1, 0, "%s", player_state.c_str());
|
||||
wFooter->Bold(0);
|
||||
if (playing_song.length() > max_length_without_scroll)
|
||||
{
|
||||
@@ -352,15 +352,15 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
my_string_t part = playing_song.substr(playing_song_scroll_begin++, scrollsize);
|
||||
if (part.length() < scrollsize)
|
||||
part += playing_song.substr(0, scrollsize-part.length());
|
||||
wFooter->WriteXY(player_state.length(), 1, part);
|
||||
wFooter->WriteXY(player_state.length(), 1, 0, UTF_S_FMT, part.c_str());
|
||||
if (playing_song_scroll_begin >= playing_song.length())
|
||||
playing_song_scroll_begin = 0;
|
||||
}
|
||||
else
|
||||
wFooter->WriteXY(player_state.length(), 1, s.toString(Config.song_status_format), 1);
|
||||
wFooter->WriteXY(player_state.length(), 1, 1, "%s", s.toString(Config.song_status_format).c_str());
|
||||
wFooter->Bold(1);
|
||||
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, tracklength);
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, 1, "%s", tracklength.c_str());
|
||||
}
|
||||
if (!block_progressbar_update)
|
||||
{
|
||||
@@ -379,7 +379,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
else
|
||||
{
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
wFooter->WriteXY(0, 1, "", 1);
|
||||
wFooter->WriteXY(0, 1, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,11 +431,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
mvwhline(wHeader->Raw(), 1, 0, 0, wHeader->GetWidth());
|
||||
if (!switch_state.empty())
|
||||
{
|
||||
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-3, 1, "[");
|
||||
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-3, 1, 0, "[");
|
||||
wHeader->SetColor(Config.state_flags_color);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-2, 1, switch_state);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-2, 1, 0, "%s", switch_state.c_str());
|
||||
wHeader->SetColor(Config.state_line_color);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-2, 1, "]");
|
||||
wHeader->WriteXY(wHeader->GetWidth()-2, 1, 0, "]");
|
||||
}
|
||||
wHeader->SetColor(Config.header_color);
|
||||
wHeader->Bold(0);
|
||||
@@ -446,7 +446,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||
int vol = Mpd->GetVolume();
|
||||
volume_state = " Volume: " + IntoStr(vol) + "%";
|
||||
wHeader->SetColor(Config.volume_color);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, volume_state);
|
||||
wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, 1, "%s", volume_state.c_str());
|
||||
wHeader->SetColor(Config.header_color);
|
||||
}
|
||||
wHeader->Refresh();
|
||||
|
||||
@@ -326,34 +326,27 @@ void Window::ReadKey() const
|
||||
wgetch(itsWindow);
|
||||
}
|
||||
|
||||
void Window::Write(int limit, const string &str, bool clrtoeol)
|
||||
void Window::Write(bool cte, const char *format, ...) const
|
||||
{
|
||||
waddstr(itsWindow,str.c_str());
|
||||
if (clrtoeol)
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
vw_printw(itsWindow, format, list);
|
||||
va_end(list);
|
||||
if (cte)
|
||||
wclrtoeol(itsWindow);
|
||||
}
|
||||
|
||||
#ifdef _UTF8
|
||||
void Window::Write(int limit, const wstring &str, bool clrtoeol)
|
||||
void Window::WriteXY(int x, int y, bool cte, const char *format, ...) const
|
||||
{
|
||||
wprintw(itsWindow, "%ls", str.c_str());
|
||||
if (clrtoeol)
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
wmove(itsWindow, y, x);
|
||||
vw_printw(itsWindow, format, list);
|
||||
va_end(list);
|
||||
if (cte)
|
||||
wclrtoeol(itsWindow);
|
||||
}
|
||||
|
||||
void Window::WriteXY(int x, int y, int limit, const wstring &str, bool cleartoeol)
|
||||
{
|
||||
wmove(itsWindow, y, x);
|
||||
Write(limit, str, cleartoeol);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Window::WriteXY(int x, int y, int limit, const string &str, bool cleartoeol)
|
||||
{
|
||||
wmove(itsWindow, y, x);
|
||||
Write(limit, str, cleartoeol);
|
||||
}
|
||||
|
||||
string Window::GetString(const string &base, size_t length, size_t width) const
|
||||
{
|
||||
int input;
|
||||
|
||||
14
src/window.h
14
src/window.h
@@ -37,12 +37,14 @@
|
||||
# define UNICODE 1
|
||||
# define my_char_t wchar_t
|
||||
# define my_string_t wstring
|
||||
# define UTF_S_FMT "%ls"
|
||||
# define TO_STRING(x) ToString(x)
|
||||
# define TO_WSTRING(x) ToWString(x)
|
||||
#else
|
||||
# define UNICODE 0
|
||||
# define my_char_t char
|
||||
# define my_string_t string
|
||||
# define UTF_S_FMT "%s"
|
||||
# define TO_STRING(x) x
|
||||
# define TO_WSTRING(x) x
|
||||
#endif
|
||||
@@ -126,16 +128,8 @@ class Window
|
||||
void ReadKey(int &) const;
|
||||
void ReadKey() const;
|
||||
|
||||
void Write(const string &s, bool cte = 0) { Write(0xFFFF, s, cte); }
|
||||
void Write(int, const string &, bool = 0);
|
||||
void WriteXY(int x, int y, const string &s, bool ete = 0) { WriteXY(x, y, 0xFFFF, s, ete); }
|
||||
void WriteXY(int, int, int, const string &, bool = 0);
|
||||
# ifdef _UTF8
|
||||
void Write(const wstring &s, bool cte = 0) { Write(0xFFFF, s, cte); }
|
||||
void Write(int, const wstring &, bool = 0);
|
||||
void WriteXY(int x, int y, const wstring &s, bool ete = 0) { WriteXY(x, y, 0xFFFF, s, ete); }
|
||||
void WriteXY(int, int, int, const wstring &, bool = 0);
|
||||
# endif
|
||||
void Write(bool, const char *, ...) const;
|
||||
void WriteXY(int, int, bool, const char *, ...) const;
|
||||
|
||||
void Scrollable(bool) const;
|
||||
virtual void Scroll(Where);
|
||||
|
||||
Reference in New Issue
Block a user