add custom sort format
This commit is contained in:
committed by
Andrzej Rybczak
parent
d134a807d4
commit
6c73c3cecf
11
doc/config
11
doc/config
@@ -179,6 +179,17 @@
|
|||||||
#tag_editor_album_format = "{(%y) }%b"
|
#tag_editor_album_format = "{(%y) }%b"
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
## Note: Below variables are used for sorting the library browser.
|
||||||
|
## The sort mode determines how the song library is sorted, and can
|
||||||
|
## be used in combination with a sort format to specify a custom sorting format.
|
||||||
|
## Possible values for sort_mode are "name", "mtime" and "format".
|
||||||
|
##
|
||||||
|
#
|
||||||
|
#sort_mode = "name"
|
||||||
|
#
|
||||||
|
#sort_format = "{%b~%n}|{~%n}|{~~%t}|{~~%f}"
|
||||||
|
#
|
||||||
|
##
|
||||||
## Note: Below variables are for alternative version of user's interface.
|
## Note: Below variables are for alternative version of user's interface.
|
||||||
## Their syntax supports all tags and colors listed above plus some extra
|
## Their syntax supports all tags and colors listed above plus some extra
|
||||||
## markers used for text attributes. They are followed by character '$'.
|
## markers used for text attributes. They are followed by character '$'.
|
||||||
|
|||||||
@@ -131,6 +131,12 @@ Format for albums' list in Tag editor.
|
|||||||
.TP
|
.TP
|
||||||
.B song_window_title_format
|
.B song_window_title_format
|
||||||
Song format for window title.
|
Song format for window title.
|
||||||
|
.TP
|
||||||
|
.B sort_mode
|
||||||
|
Determines the sort mode for the song library. Possible values are "name", "mtime" and "format".
|
||||||
|
.TP
|
||||||
|
.B sort_format
|
||||||
|
Format to use for sorting the song library. For this option to be effective, sort_mode must be set to "format".
|
||||||
.TP
|
.TP
|
||||||
.B external_editor = PATH
|
.B external_editor = PATH
|
||||||
Path to external editor used to edit lyrics.
|
Path to external editor used to edit lyrics.
|
||||||
@@ -295,7 +301,7 @@ If enabled, bitrate of currently playing song will be displayed in statusbar.
|
|||||||
If enabled, remaining time of currently playing song will be be displayed in statusbar instead of elapsed time.
|
If enabled, remaining time of currently playing song will be be displayed in statusbar instead of elapsed time.
|
||||||
.TP
|
.TP
|
||||||
.B ignore_leading_the = yes/no
|
.B ignore_leading_the = yes/no
|
||||||
If enabled, word "the" at the beginning of tags/filenames will be ignored while sorting items.
|
If enabled, word "the" at the beginning of tags/filenames will be ignored while sorting items. Note that this doesn't currently work with custom sorting formats.
|
||||||
.TP
|
.TP
|
||||||
.B use_console_editor = yes/no
|
.B use_console_editor = yes/no
|
||||||
If your external editor is console application, you need to enable it.
|
If your external editor is console application, you need to enable it.
|
||||||
|
|||||||
@@ -100,9 +100,6 @@ void Browser::SwitchTo()
|
|||||||
if (hasToBeResized || myLockedScreen)
|
if (hasToBeResized || myLockedScreen)
|
||||||
Resize();
|
Resize();
|
||||||
|
|
||||||
if (isLocal()) // local browser doesn't support sorting by mtime
|
|
||||||
Config.browser_sort_by_mtime = 0;
|
|
||||||
|
|
||||||
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
|
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
|
||||||
|
|
||||||
if (myScreen != this && myScreen->isTabbable())
|
if (myScreen != this && myScreen->isTabbable())
|
||||||
|
|||||||
@@ -306,10 +306,16 @@ bool CaseInsensitiveSorting::operator()(const MPD::Item &a, const MPD::Item &b)
|
|||||||
return cmp(ExtractTopName(a.name), ExtractTopName(b.name)) < 0;
|
return cmp(ExtractTopName(a.name), ExtractTopName(b.name)) < 0;
|
||||||
case MPD::itPlaylist:
|
case MPD::itPlaylist:
|
||||||
return cmp(a.name, b.name) < 0;
|
return cmp(a.name, b.name) < 0;
|
||||||
case MPD::itSong:
|
case MPD::itSong: {
|
||||||
return Config.browser_sort_by_mtime
|
unsigned mode = Config.sort_mode;
|
||||||
? a.song->GetMTime() > b.song->GetMTime()
|
if (myBrowser->isLocal() && mode == 1) mode = 0; // local browser doesn't support sorting by mtime.
|
||||||
: operator()(a.song, b.song);
|
switch (mode) {
|
||||||
|
case 0: return operator()(a.song, b.song);
|
||||||
|
case 1: return a.song->GetMTime() > b.song->GetMTime();
|
||||||
|
case 2: return cmp(a.song->toString(Config.sort_format), b.song->toString(Config.sort_format)) < 0;
|
||||||
|
default: return 0; // no other mode.
|
||||||
|
}
|
||||||
|
}
|
||||||
default: // there's no other type, just silence compiler.
|
default: // there's no other type, just silence compiler.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2177,9 +2177,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (myScreen == myBrowser && !myBrowser->isLocal())
|
else if (myScreen == myBrowser && !myBrowser->isLocal())
|
||||||
{
|
{
|
||||||
Config.browser_sort_by_mtime = !Config.browser_sort_by_mtime;
|
Config.sort_mode = (Config.sort_mode + 1) % 3;
|
||||||
myBrowser->Main()->Sort<CaseInsensitiveSorting>(myBrowser->CurrentDir() != "/");
|
myBrowser->Main()->Sort<CaseInsensitiveSorting>(myBrowser->CurrentDir() != "/");
|
||||||
ShowMessage("Sort songs by: %s", Config.browser_sort_by_mtime ? "Modification time" : "Name");
|
switch (Config.sort_mode) {
|
||||||
|
case 0: ShowMessage("Sort songs by: Name"); break;
|
||||||
|
case 1: ShowMessage("Sort songs by: Modification time"); break;
|
||||||
|
case 2: ShowMessage("Sort songs by: Custom format"); break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (myScreen->ActiveWindow() == myLibrary->Artists
|
else if (myScreen->ActiveWindow() == myLibrary->Artists
|
||||||
|| (myLibrary->Columns() == 2 && myScreen->ActiveWindow() == myLibrary->Albums))
|
|| (myLibrary->Columns() == 2 && myScreen->ActiveWindow() == myLibrary->Albums))
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ void NcmpcppConfig::SetDefaults()
|
|||||||
song_status_format_no_colors = song_status_format;
|
song_status_format_no_colors = song_status_format;
|
||||||
song_window_title_format = "{{%a - }{%t}|{%f}}";
|
song_window_title_format = "{{%a - }{%t}|{%f}}";
|
||||||
song_library_format = "{{%n - }{%t}|{%f}}";
|
song_library_format = "{{%n - }{%t}|{%f}}";
|
||||||
|
sort_format = "{%b~%n}|{~%n}|{~~%t}|{~~%f}";
|
||||||
tag_editor_album_format = "{{(%y) }%b}";
|
tag_editor_album_format = "{{(%y) }%b}";
|
||||||
new_header_first_line = "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}";
|
new_header_first_line = "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}";
|
||||||
new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}";
|
new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}";
|
||||||
@@ -444,7 +445,6 @@ void NcmpcppConfig::SetDefaults()
|
|||||||
new_design = false;
|
new_design = false;
|
||||||
visualizer_use_wave = true;
|
visualizer_use_wave = true;
|
||||||
visualizer_in_stereo = false;
|
visualizer_in_stereo = false;
|
||||||
browser_sort_by_mtime = false;
|
|
||||||
tag_editor_extended_numeration = false;
|
tag_editor_extended_numeration = false;
|
||||||
media_library_display_date = true;
|
media_library_display_date = true;
|
||||||
media_library_display_empty_tag = true;
|
media_library_display_empty_tag = true;
|
||||||
@@ -464,6 +464,7 @@ void NcmpcppConfig::SetDefaults()
|
|||||||
lines_scrolled = 2;
|
lines_scrolled = 2;
|
||||||
search_engine_default_search_mode = 0;
|
search_engine_default_search_mode = 0;
|
||||||
visualizer_sync_interval = 30;
|
visualizer_sync_interval = 30;
|
||||||
|
sort_mode = 0;
|
||||||
locked_screen_width_part = 0.5;
|
locked_screen_width_part = 0.5;
|
||||||
selected_item_suffix_length = 0;
|
selected_item_suffix_length = 0;
|
||||||
now_playing_suffix_length = 0;
|
now_playing_suffix_length = 0;
|
||||||
@@ -853,6 +854,11 @@ void NcmpcppConfig::Read()
|
|||||||
tag_editor_album_format += '}';
|
tag_editor_album_format += '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (name == "sort_format")
|
||||||
|
{
|
||||||
|
if (!v.empty())
|
||||||
|
sort_format = v;
|
||||||
|
}
|
||||||
else if (name == "external_editor")
|
else if (name == "external_editor")
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
@@ -1232,6 +1238,12 @@ void NcmpcppConfig::Read()
|
|||||||
if (interval)
|
if (interval)
|
||||||
visualizer_sync_interval = interval;
|
visualizer_sync_interval = interval;
|
||||||
}
|
}
|
||||||
|
else if (name == "sort_mode")
|
||||||
|
{
|
||||||
|
if (v == "mtime") sort_mode = 1;
|
||||||
|
else if (v == "format") sort_mode = 2;
|
||||||
|
else sort_mode = 0; // "name" or invalid
|
||||||
|
}
|
||||||
else if (name == "locked_screen_width_part")
|
else if (name == "locked_screen_width_part")
|
||||||
{
|
{
|
||||||
int part = StrToInt(v);
|
int part = StrToInt(v);
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ struct NcmpcppConfig
|
|||||||
std::string song_library_format;
|
std::string song_library_format;
|
||||||
std::string tag_editor_album_format;
|
std::string tag_editor_album_format;
|
||||||
std::string song_in_columns_to_string_format;
|
std::string song_in_columns_to_string_format;
|
||||||
|
std::string sort_format;
|
||||||
std::string external_editor;
|
std::string external_editor;
|
||||||
std::string system_encoding;
|
std::string system_encoding;
|
||||||
std::string execute_on_song_change;
|
std::string execute_on_song_change;
|
||||||
@@ -252,7 +253,6 @@ struct NcmpcppConfig
|
|||||||
bool new_design;
|
bool new_design;
|
||||||
bool visualizer_use_wave;
|
bool visualizer_use_wave;
|
||||||
bool visualizer_in_stereo;
|
bool visualizer_in_stereo;
|
||||||
bool browser_sort_by_mtime;
|
|
||||||
bool tag_editor_extended_numeration;
|
bool tag_editor_extended_numeration;
|
||||||
bool media_library_display_date;
|
bool media_library_display_date;
|
||||||
bool media_library_display_empty_tag;
|
bool media_library_display_empty_tag;
|
||||||
@@ -273,6 +273,7 @@ struct NcmpcppConfig
|
|||||||
unsigned lines_scrolled;
|
unsigned lines_scrolled;
|
||||||
unsigned search_engine_default_search_mode;
|
unsigned search_engine_default_search_mode;
|
||||||
unsigned visualizer_sync_interval;
|
unsigned visualizer_sync_interval;
|
||||||
|
unsigned sort_mode;
|
||||||
|
|
||||||
double locked_screen_width_part;
|
double locked_screen_width_part;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user