new attribute for a columns view: do not display empty tag marker
This commit is contained in:
10
doc/config
10
doc/config
@@ -131,9 +131,13 @@
|
|||||||
##
|
##
|
||||||
## - color is optional (if you want the default one, type [])
|
## - color is optional (if you want the default one, type [])
|
||||||
##
|
##
|
||||||
## Note: If you want a column to be right aligned, put 'r' character
|
## Note: You can give a column additional attributes by putting appropriate
|
||||||
## after displayed tag character, e.g. {lr} will give you right aligned
|
## character after displayed tag character. Available attributes are:
|
||||||
## column of lengths.
|
##
|
||||||
|
## - r - column will be right aligned
|
||||||
|
## - E - if tag is empty, empty tag marker won't be displayed
|
||||||
|
##
|
||||||
|
## E.g. {lr} will give you right aligned column of lengths.
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
#song_columns_list_format = "(7f)[green]{l} (25)[cyan]{a} (40)[]{t} (30)[red]{b}"
|
#song_columns_list_format = "(7f)[green]{l} (25)[cyan]{a} (40)[]{t} (30)[red]{b}"
|
||||||
|
|||||||
@@ -180,17 +180,20 @@ void Display::SongsInColumns(const MPD::Song &s, void *, Menu<MPD::Song> *menu)
|
|||||||
whline(menu->Raw(), 32, menu->GetWidth()-where);
|
whline(menu->Raw(), 32, menu->GetWidth()-where);
|
||||||
std::string tag = (s.*get)();
|
std::string tag = (s.*get)();
|
||||||
if (it->right_alignment)
|
if (it->right_alignment)
|
||||||
|
{
|
||||||
|
if (!tag.empty() || it->display_empty_tag)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
menu->GetXY(x, y);
|
menu->GetXY(x, y);
|
||||||
std::basic_string<my_char_t> wtag = TO_WSTRING(tag.empty() ? Config.empty_tag : tag).substr(0, width-!!x);
|
std::basic_string<my_char_t> wtag = TO_WSTRING(tag.empty() ? Config.empty_tag : tag).substr(0, width-!!x);
|
||||||
*menu << XY(x+width-Window::Length(wtag)-!!x, y) << wtag;
|
*menu << XY(x+width-Window::Length(wtag)-!!x, y) << wtag;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!tag.empty())
|
if (!tag.empty())
|
||||||
*menu << tag;
|
*menu << tag;
|
||||||
else
|
else if (it->display_empty_tag)
|
||||||
*menu << Config.empty_tag;
|
*menu << Config.empty_tag;
|
||||||
}
|
}
|
||||||
where += width;
|
where += width;
|
||||||
|
|||||||
@@ -881,7 +881,18 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
std::string tag_type = GetLineValue(conf.song_list_columns_format, '{', '}', 1);
|
std::string tag_type = GetLineValue(conf.song_list_columns_format, '{', '}', 1);
|
||||||
col.type = tag_type.at(0);
|
col.type = tag_type.at(0);
|
||||||
col.fixed = *width.rbegin() == 'f';
|
col.fixed = *width.rbegin() == 'f';
|
||||||
col.right_alignment = tag_type.length() > 1 && tag_type[1] == 'r';
|
for (std::string::const_iterator it = ++tag_type.begin(); it != tag_type.end(); ++it)
|
||||||
|
{
|
||||||
|
switch (*it)
|
||||||
|
{
|
||||||
|
case 'r':
|
||||||
|
col.right_alignment = 1;
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
col.display_empty_tag = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
col.width = StrToInt(width);
|
col.width = StrToInt(width);
|
||||||
conf.columns.push_back(col);
|
conf.columns.push_back(col);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,14 @@ const int null_key = std::numeric_limits<int>::max();
|
|||||||
|
|
||||||
struct Column
|
struct Column
|
||||||
{
|
{
|
||||||
|
Column() : right_alignment(0), display_empty_tag(1) { }
|
||||||
|
|
||||||
unsigned width;
|
unsigned width;
|
||||||
Color color;
|
Color color;
|
||||||
char type;
|
char type;
|
||||||
bool fixed;
|
bool fixed;
|
||||||
bool right_alignment;
|
bool right_alignment;
|
||||||
|
bool display_empty_tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ncmpcpp_keys
|
struct ncmpcpp_keys
|
||||||
|
|||||||
Reference in New Issue
Block a user