new feature: support for custom prefix/suffix of now playing song

This commit is contained in:
Andrzej Rybczak
2009-09-21 01:17:54 +02:00
parent 5a887861d7
commit ead5255df1
5 changed files with 49 additions and 12 deletions

View File

@@ -115,12 +115,6 @@
#
#tag_editor_album_format = "{(%y) }%b"
#
#browser_playlist_prefix = "$2playlist$9 "
#
#selected_item_prefix = "$6"
#
#selected_item_suffix = "$9"
#
##
## Note: Below variables are for alternative version of user's interface.
## Their syntax supports all tags and colors listed above plus some extra
@@ -128,7 +122,7 @@
## After that you can put:
##
## - b - bold text
## - u - underlined text
## - u - underline text
## - r - reverse colors
## - a - use alternative character set
##
@@ -142,6 +136,21 @@
#
#alternative_header_second_line_format = "{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}"
#
##
## Note: Below variables also supports
## text attributes listed above.
##
#
#now_playing_prefix = "$b"
#
#now_playing_suffix = "$/b"
#
#browser_playlist_prefix = "$2playlist$9 "
#
#selected_item_prefix = "$6"
#
#selected_item_suffix = "$9"
#
## colors are not supported for below variable
#
#song_window_title_format = "{%a - }{%t}|{%f}"

View File

@@ -114,6 +114,12 @@ Prefix for playlists in Browser.
.B default_tag_editor_pattern = TEXT
Deafult pattern used by Tag editor's parser.
.TP
.B now_playing_prefix = TEXT
Prefix for currently playing song.
.TP
.B now_playing_suffix = TEXT
Suffix for currently playing song.
.TP
.B selected_item_prefix = TEXT
Prefix for selected items.
.TP

View File

@@ -107,7 +107,7 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
bool is_now_playing = menu == myPlaylist->Items && menu->CurrentlyDrawedPosition() == myPlaylist->NowPlaying;
if (is_now_playing)
*menu << fmtBold;
*menu << Config.now_playing_prefix;
if (Config.columns.empty())
return;
@@ -209,7 +209,7 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
if ((--it)->color != clDefault)
*menu << clEnd;
if (is_now_playing)
*menu << fmtBoldEnd;
*menu << Config.now_playing_suffix;
}
void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
@@ -219,7 +219,7 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
bool is_now_playing = menu == myPlaylist->Items && menu->CurrentlyDrawedPosition() == myPlaylist->NowPlaying;
if (is_now_playing)
*menu << fmtBold;
*menu << Config.now_playing_prefix;
std::string line = s.toString(*static_cast<std::string *>(data));
for (std::string::const_iterator it = line.begin(); it != line.end(); ++it)
@@ -235,8 +235,10 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
basic_buffer<my_char_t> buf;
buf << U(" ");
String2Buffer(TO_WSTRING(line.substr(it-line.begin()+1)), buf);
if (is_now_playing)
buf << Config.now_playing_suffix;
*menu << XY(menu->GetWidth()-buf.Str().length(), menu->Y()) << buf;
break;
return;
}
else
*menu << *it;
@@ -245,7 +247,7 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
*menu << *it;
}
if (is_now_playing)
*menu << fmtBoldEnd;
*menu << Config.now_playing_suffix;
}
void Display::Tags(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)

View File

@@ -262,6 +262,8 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.pattern = "%n - %t";
conf.selected_item_prefix << clMagenta;
conf.selected_item_suffix << clEnd;
conf.now_playing_prefix << fmtBold;
conf.now_playing_suffix << fmtBoldEnd;
conf.color1 = clWhite;
conf.color2 = clGreen;
conf.empty_tags_color = clCyan;
@@ -670,6 +672,22 @@ void ReadConfiguration(ncmpcpp_config &conf)
String2Buffer(v, conf.selected_item_suffix);
}
}
else if (cl.find("now_playing_prefix") != std::string::npos)
{
if (!v.empty())
{
conf.now_playing_prefix.Clear();
String2Buffer(v, conf.now_playing_prefix);
}
}
else if (cl.find("now_playing_suffix") != std::string::npos)
{
if (!v.empty())
{
conf.now_playing_suffix.Clear();
String2Buffer(TO_WSTRING(v), conf.now_playing_suffix);
}
}
else if (cl.find("color1") != std::string::npos)
{
if (!v.empty())

View File

@@ -150,6 +150,8 @@ struct ncmpcpp_config
Buffer browser_playlist_prefix;
Buffer selected_item_prefix;
Buffer selected_item_suffix;
Buffer now_playing_prefix;
basic_buffer<my_char_t> now_playing_suffix;
Color color1;
Color color2;