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