update displaying playlist in column view
This commit is contained in:
168
src/helpers.cpp
168
src/helpers.cpp
@@ -416,179 +416,151 @@ void DisplayStringPair(const StringPair &pair, void *, Menu<StringPair> *menu)
|
||||
*menu << pair.first;
|
||||
}
|
||||
|
||||
string DisplayColumns(string song_template)
|
||||
string DisplayColumns(string st)
|
||||
{
|
||||
vector<string> cols;
|
||||
for (size_t i = song_template.find(" "); i != string::npos; i = song_template.find(" "))
|
||||
string result;
|
||||
size_t where = 0;
|
||||
|
||||
for (int width = StrToInt(GetLineValue(st, '(', ')', 1)); width; width = StrToInt(GetLineValue(st, '(', ')', 1)))
|
||||
{
|
||||
cols.push_back(song_template.substr(0, i));
|
||||
song_template = song_template.substr(i+1);
|
||||
}
|
||||
cols.push_back(song_template);
|
||||
|
||||
string result, v;
|
||||
|
||||
for (vector<string>::const_iterator it = cols.begin(); it != cols.end(); it++)
|
||||
{
|
||||
int width = StrToInt(GetLineValue(*it, '(', ')'));
|
||||
char type = GetLineValue(*it, '{', '}')[0];
|
||||
|
||||
width *= COLS/100.0;
|
||||
char type = GetLineValue(st, '{', '}', 1)[0];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 'l':
|
||||
v = "Time";
|
||||
result += "Time";
|
||||
break;
|
||||
case 'f':
|
||||
v = "Filename";
|
||||
result += "Filename";
|
||||
break;
|
||||
case 'F':
|
||||
v = "Full filename";
|
||||
result += "Full filename";
|
||||
break;
|
||||
case 'a':
|
||||
v = "Artist";
|
||||
result += "Artist";
|
||||
break;
|
||||
case 't':
|
||||
v = "Title";
|
||||
result += "Title";
|
||||
break;
|
||||
case 'b':
|
||||
v = "Album";
|
||||
result += "Album";
|
||||
break;
|
||||
case 'y':
|
||||
v = "Year";
|
||||
result += "Year";
|
||||
break;
|
||||
case 'n':
|
||||
v = "Track";
|
||||
result += "Track";
|
||||
break;
|
||||
case 'g':
|
||||
v = "Genre";
|
||||
result += "Genre";
|
||||
break;
|
||||
case 'c':
|
||||
v = "Composer";
|
||||
result += "Composer";
|
||||
break;
|
||||
case 'p':
|
||||
v = "Performer";
|
||||
result += "Performer";
|
||||
break;
|
||||
case 'd':
|
||||
v = "Disc";
|
||||
result += "Disc";
|
||||
break;
|
||||
case 'C':
|
||||
v = "Comment";
|
||||
result += "Comment";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
where += width;
|
||||
|
||||
v = v.substr(0, width-1);
|
||||
for (int i = v.length(); i < width; i++, v += " ") { }
|
||||
result += v;
|
||||
if (result.length() > where)
|
||||
result = result.substr(0, where);
|
||||
else
|
||||
for (int i = result.length(); i <= where && i < COLS; i++, result += ' ') { }
|
||||
}
|
||||
|
||||
return result.substr(0, COLS);
|
||||
return result;
|
||||
}
|
||||
|
||||
void DisplaySongInColumns(const Song &s, void *s_template, Menu<Song> *menu)
|
||||
{
|
||||
/*string song_template = s_template ? *static_cast<string *>(s_template) : "";
|
||||
string st = s_template ? *static_cast<string *>(s_template) : "";
|
||||
size_t where = 0;
|
||||
Color color;
|
||||
|
||||
vector<string> cols;
|
||||
for (size_t i = song_template.find(" "); i != string::npos; i = song_template.find(" "))
|
||||
for (int width = StrToInt(GetLineValue(st, '(', ')', 1)); width; width = StrToInt(GetLineValue(st, '(', ')', 1)))
|
||||
{
|
||||
cols.push_back(song_template.substr(0, i));
|
||||
song_template = song_template.substr(i+1);
|
||||
if (where)
|
||||
{
|
||||
menu->GotoXY(where, menu->Y());
|
||||
*menu << ' ';
|
||||
if (color != clDefault)
|
||||
*menu << clEnd;
|
||||
}
|
||||
cols.push_back(song_template);
|
||||
|
||||
my_string_t result, v;
|
||||
|
||||
# ifdef _UTF8
|
||||
const wstring space = L" ";
|
||||
const wstring open_col = L"[.";
|
||||
const wstring close_col = L"]";
|
||||
const wstring close_col2 = L"[/red]";
|
||||
# else
|
||||
const string space = " ";
|
||||
const string open_col = "[.";
|
||||
const string close_col = "]";
|
||||
const string close_col2 = "[/red]";
|
||||
# endif
|
||||
|
||||
for (vector<string>::const_iterator it = cols.begin(); it != cols.end(); it++)
|
||||
{
|
||||
int width = StrToInt(GetLineValue(*it, '(', ')'));
|
||||
my_string_t color = TO_WSTRING(GetLineValue(*it, '[', ']'));
|
||||
char type = GetLineValue(*it, '{', '}')[0];
|
||||
|
||||
width *= COLS/100.0;
|
||||
color = IntoColor(GetLineValue(st, '[', ']', 1));
|
||||
char type = GetLineValue(st, '{', '}', 1)[0];
|
||||
|
||||
string (Song::*get)() const = 0;
|
||||
|
||||
string ss;
|
||||
switch (type)
|
||||
{
|
||||
case 'l':
|
||||
ss = s.GetLength();
|
||||
break;
|
||||
case 'f':
|
||||
ss = s.GetName();
|
||||
get = &Song::GetLength;
|
||||
break;
|
||||
case 'F':
|
||||
ss = s.GetFile();
|
||||
get = &Song::GetFile;
|
||||
break;
|
||||
case 'f':
|
||||
get = &Song::GetName;
|
||||
break;
|
||||
case 'a':
|
||||
ss = s.GetArtist();
|
||||
break;
|
||||
case 't':
|
||||
if (s.GetTitle() != EMPTY_TAG)
|
||||
ss = s.GetTitle();
|
||||
else
|
||||
{
|
||||
const string &file = s.GetName();
|
||||
ss = !s.IsStream() ? file.substr(0, file.find_last_of(".")) : file;
|
||||
}
|
||||
get = &Song::GetArtist;
|
||||
break;
|
||||
case 'b':
|
||||
ss = s.GetAlbum();
|
||||
get = &Song::GetAlbum;
|
||||
break;
|
||||
case 'y':
|
||||
ss = s.GetYear();
|
||||
get = &Song::GetYear;
|
||||
break;
|
||||
case 'n':
|
||||
ss = s.GetTrack();
|
||||
get = &Song::GetTrack;
|
||||
break;
|
||||
case 'g':
|
||||
ss = s.GetGenre();
|
||||
get = &Song::GetGenre;
|
||||
break;
|
||||
case 'c':
|
||||
ss = s.GetComposer();
|
||||
get = &Song::GetComposer;
|
||||
break;
|
||||
case 'p':
|
||||
ss = s.GetPerformer();
|
||||
get = &Song::GetPerformer;
|
||||
break;
|
||||
case 'd':
|
||||
ss = s.GetDisc();
|
||||
get = &Song::GetDisc;
|
||||
break;
|
||||
case 'C':
|
||||
ss = s.GetComment();
|
||||
get = &Song::GetComment;
|
||||
break;
|
||||
case 't':
|
||||
if (!s.GetTitle().empty())
|
||||
get = &Song::GetTitle;
|
||||
else
|
||||
get = &Song::GetName;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
v = TO_WSTRING(ss.substr(0, width-1));
|
||||
for (int i = v.length(); i < width; i++, v += space) { }
|
||||
if (!color.empty())
|
||||
{
|
||||
result += open_col;
|
||||
result += color;
|
||||
result += close_col;
|
||||
if (color != clDefault)
|
||||
*menu << color;
|
||||
whline(menu->Raw(), 32, menu->GetWidth()-where);
|
||||
string tag = (s.*get)();
|
||||
if (!tag.empty())
|
||||
*menu << tag;
|
||||
else
|
||||
*menu << Config.empty_tag;
|
||||
where += width;
|
||||
}
|
||||
result += v;
|
||||
if (!color.empty())
|
||||
result += close_col2;
|
||||
}
|
||||
|
||||
return TO_STRING(result);*/
|
||||
*menu << "dupa";
|
||||
if (color != clDefault)
|
||||
*menu << clEnd;
|
||||
}
|
||||
|
||||
void DisplaySong(const Song &s, void *data, Menu<Song> *menu)
|
||||
|
||||
@@ -106,10 +106,10 @@ Menu<Song> *mLibSongs;
|
||||
Menu<Buffer> *mTagEditor;
|
||||
Menu<StringPair> *mEditorAlbums;
|
||||
Menu<StringPair> *mEditorDirs;
|
||||
Menu<string> *mEditorTagTypes;
|
||||
#endif // HAVE_TAGLIB_H
|
||||
// blah, I use them in conditionals, so just let them be.
|
||||
Menu<StringPair> *mEditorLeftCol = 0;
|
||||
Menu<string> *mEditorTagTypes;
|
||||
Menu<Song> *mEditorTags = 0;
|
||||
|
||||
Menu<string> *mPlaylistList;
|
||||
|
||||
@@ -53,8 +53,14 @@ namespace
|
||||
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
|
||||
}
|
||||
|
||||
Color IntoColor(const string &color)
|
||||
Border IntoBorder(const string &color)
|
||||
{
|
||||
return (Border) IntoColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
Color IntoColor(const string &color)
|
||||
{
|
||||
Color result = clDefault;
|
||||
|
||||
if (color == "black")
|
||||
@@ -75,12 +81,6 @@ namespace
|
||||
result = clWhite;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Border IntoBorder(const string &color)
|
||||
{
|
||||
return (Border) IntoColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateConfigDir()
|
||||
@@ -220,7 +220,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.mpd_host = "localhost";
|
||||
conf.empty_tag = "<empty>";
|
||||
conf.song_list_format = "{%a - }{%t}|{$8%f$9}%r{$3(%l)$9}";
|
||||
conf.song_columns_list_format = "(8)[green]{l} (25)[cyan]{a} (40){t} (30)[red]{b}";
|
||||
conf.song_columns_list_format = "(7)[green]{l} (25)[cyan]{a} (40)[]{t} (30)[red]{b}";
|
||||
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
||||
conf.song_window_title_format = "{%a - }{%t}|{%f}";
|
||||
conf.song_library_format = "{%n - }{%t}|{%f}";
|
||||
@@ -269,14 +269,16 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.message_delay_time = 4;
|
||||
}
|
||||
|
||||
string GetLineValue(const string &line, char a, char b)
|
||||
string GetLineValue(string &line, char a, char b, bool once)
|
||||
{
|
||||
int i = 0;
|
||||
int begin = -1, end = -1;
|
||||
for (string::const_iterator it = line.begin(); it != line.end(); i++, it++)
|
||||
for (string::iterator it = line.begin(); it != line.end() && (begin == -1 || end == -1); i++, it++)
|
||||
{
|
||||
if (*it == a || *it == b)
|
||||
{
|
||||
if (once)
|
||||
*it = 0;
|
||||
if (begin < 0)
|
||||
begin = i+1;
|
||||
else
|
||||
|
||||
@@ -162,9 +162,10 @@ void DefaultConfiguration(ncmpcpp_config &);
|
||||
void ReadKeys(ncmpcpp_keys &);
|
||||
void ReadConfiguration(ncmpcpp_config &);
|
||||
|
||||
Color IntoColor(const string &);
|
||||
string IntoStr(Color);
|
||||
mpd_TagItems IntoTagItem(char);
|
||||
string GetLineValue(const string &, char = '"', char = '"');
|
||||
string GetLineValue(string &, char = '"', char = '"', bool = 0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -127,6 +127,9 @@ Window::~Window()
|
||||
|
||||
void Window::SetColor(Color col, Color background)
|
||||
{
|
||||
if (col == clDefault)
|
||||
col = itsBaseColor;
|
||||
|
||||
if (col != clDefault)
|
||||
wattron(itsWindow, COLOR_PAIR(background*8+col));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user