display: improve showSongs a bit
This commit is contained in:
@@ -108,12 +108,14 @@ void showSongs(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen, const st
|
||||
bool separate_albums, is_now_playing, is_selected, discard_colors;
|
||||
setProperties(menu, s, screen, separate_albums, is_now_playing, is_selected, discard_colors);
|
||||
|
||||
size_t y = menu.getY();
|
||||
std::string line = s.toString(format, "$");
|
||||
for (auto it = line.begin(); it != line.end(); ++it)
|
||||
{
|
||||
if (*it == '$')
|
||||
{
|
||||
if (++it == line.end()) // end of format
|
||||
++it;
|
||||
if (it == line.end()) // end of format
|
||||
{
|
||||
menu << '$';
|
||||
break;
|
||||
@@ -125,25 +127,27 @@ void showSongs(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen, const st
|
||||
}
|
||||
else if (*it == 'R') // right align
|
||||
{
|
||||
NC::WBuffer buf;
|
||||
buf << L" ";
|
||||
String2Buffer(ToWString(line.substr(it-line.begin()+1)), buf);
|
||||
NC::Buffer buf;
|
||||
buf << " ";
|
||||
stringToBuffer(++it, line.end(), buf);
|
||||
if (discard_colors)
|
||||
buf.removeFormatting();
|
||||
size_t x_off = menu.getWidth() - wideLength(ToWString(buf.str()));
|
||||
if (is_now_playing)
|
||||
buf << Config.now_playing_suffix;
|
||||
menu << NC::XY(menu.getWidth()-buf.str().length()-(is_selected ? Config.selected_item_suffix_length : 0), menu.getY()) << buf;
|
||||
if (separate_albums)
|
||||
menu << NC::fmtUnderlineEnd;
|
||||
return;
|
||||
x_off -= Config.now_playing_suffix_length;
|
||||
if (is_selected)
|
||||
x_off -= Config.selected_item_suffix_length;
|
||||
menu << NC::XY(x_off, y) << buf;
|
||||
break;
|
||||
}
|
||||
else // not a color nor right align, just a random character
|
||||
menu << *--it;
|
||||
}
|
||||
else if (*it == MPD::Song::FormatEscapeCharacter)
|
||||
{
|
||||
++it;
|
||||
// treat '$' as a normal character if song format escape char is prepended to it
|
||||
if (++it == line.end() || *it != '$')
|
||||
if (it == line.end() || *it != '$')
|
||||
--it;
|
||||
menu << *it;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user