more fixes, config options, keybindings, case insensitive sorting in browser
This commit is contained in:
@@ -57,7 +57,7 @@
|
|||||||
## - white
|
## - white
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
#song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f}"
|
#song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f[/white]}"
|
||||||
#
|
#
|
||||||
#song_status_format = "(%l) {%a - }{%t}|{%f}"
|
#song_status_format = "(%l) {%a - }{%t}|{%f}"
|
||||||
#
|
#
|
||||||
@@ -65,6 +65,8 @@
|
|||||||
#
|
#
|
||||||
#song_library_format = "{%n - }{%t}|{%f}"
|
#song_library_format = "{%n - }{%t}|{%f}"
|
||||||
#
|
#
|
||||||
|
#browser_playlist_prefix = "[red]playlist[/red] "
|
||||||
|
#
|
||||||
##### interface settings #####
|
##### interface settings #####
|
||||||
#
|
#
|
||||||
#header_visibility = "yes"
|
#header_visibility = "yes"
|
||||||
@@ -75,6 +77,8 @@
|
|||||||
#
|
#
|
||||||
##### colors definitions #####
|
##### colors definitions #####
|
||||||
#
|
#
|
||||||
|
#colors_enabled = "yes"
|
||||||
|
#
|
||||||
#empty_tag_color = "cyan"
|
#empty_tag_color = "cyan"
|
||||||
#
|
#
|
||||||
#header_window_color = "default"
|
#header_window_color = "default"
|
||||||
@@ -87,6 +91,8 @@
|
|||||||
#
|
#
|
||||||
#main_window_color = "yellow"
|
#main_window_color = "yellow"
|
||||||
#
|
#
|
||||||
|
#main_window_highlight_color = "yellow"
|
||||||
|
#
|
||||||
#progressbar_color = "default"
|
#progressbar_color = "default"
|
||||||
#
|
#
|
||||||
#statusbar_color = "default"
|
#statusbar_color = "default"
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ void GetDirectory(string dir)
|
|||||||
{
|
{
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
{
|
{
|
||||||
mBrowser->AddOption("[red](playlist)[/red] " + string(it->name));
|
mBrowser->AddOption(Config.browser_playlist_prefix + string(it->name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itDirectory:
|
case itDirectory:
|
||||||
@@ -631,7 +631,7 @@ void GetDirectory(string dir)
|
|||||||
mBrowser->Highlight(highlightme);
|
mBrowser->Highlight(highlightme);
|
||||||
browsed_subdir.clear();
|
browsed_subdir.clear();
|
||||||
|
|
||||||
if (current_screen != csLibrary && current_screen == csBrowser)
|
if (current_screen == csBrowser)
|
||||||
mBrowser->Hide();
|
mBrowser->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
src/menu.cpp
20
src/menu.cpp
@@ -278,10 +278,12 @@ void Menu::Refresh(bool redraw_whole_window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int line = *it-itsBeginning;
|
int line = *it-itsBeginning;
|
||||||
|
COLOR old_basecolor = itsBaseColor;
|
||||||
|
|
||||||
if (*it == itsHighlight && itsHighlightEnabled)
|
if (*it == itsHighlight && itsHighlightEnabled)
|
||||||
{
|
{
|
||||||
Reverse(1);
|
Reverse(1);
|
||||||
|
SetBaseColor(itsHighlightColor);
|
||||||
SetColor(itsHighlightColor);
|
SetColor(itsHighlightColor);
|
||||||
}
|
}
|
||||||
if (itsOptions[*it]->is_bold)
|
if (itsOptions[*it]->is_bold)
|
||||||
@@ -320,12 +322,9 @@ void Menu::Refresh(bool redraw_whole_window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ifdef UTF8_ENABLED
|
# ifdef UTF8_ENABLED
|
||||||
wstring option = ToWString(itsOptions[*it]->content);
|
WriteXY(x, line, itsWidth, ToWString(itsOptions[*it]->content), 0);
|
||||||
int bbcodes_length = CountBBCodes(option);
|
|
||||||
WriteXY(x, line, option.substr(0, itsWidth+bbcodes_length), 0);
|
|
||||||
# else
|
# else
|
||||||
int bbcodes_length = CountBBCodes(itsOptions[*it]->content);
|
WriteXY(x, line, itsWidth, itsOptions[*it]->content, 0);
|
||||||
WriteXY(x, line, itsOptions[*it]->content.substr(0, itsWidth+bbcodes_length), 0);
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (!ch && (itsOptions[*it]->location == lCenter || itsOptions[*it]->location == lLeft))
|
if (!ch && (itsOptions[*it]->location == lCenter || itsOptions[*it]->location == lLeft))
|
||||||
@@ -339,11 +338,13 @@ void Menu::Refresh(bool redraw_whole_window)
|
|||||||
line++;
|
line++;
|
||||||
|
|
||||||
if (*it == itsHighlight && itsHighlightEnabled)
|
if (*it == itsHighlight && itsHighlightEnabled)
|
||||||
|
{
|
||||||
Reverse(0);
|
Reverse(0);
|
||||||
|
SetBaseColor(old_basecolor);
|
||||||
|
SetColor(old_basecolor);
|
||||||
|
}
|
||||||
if (itsOptions[*it]->is_bold)
|
if (itsOptions[*it]->is_bold)
|
||||||
Bold(0);
|
Bold(0);
|
||||||
|
|
||||||
SetColor(itsBaseColor);
|
|
||||||
}
|
}
|
||||||
NeedsRedraw.clear();
|
NeedsRedraw.clear();
|
||||||
wrefresh(itsWindow);
|
wrefresh(itsWindow);
|
||||||
@@ -488,11 +489,13 @@ void Menu::Highlight(int which)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (which >= itsHeight)
|
if (which >= itsHeight/2)
|
||||||
{
|
{
|
||||||
itsBeginning = itsHighlight-itsHeight/2;
|
itsBeginning = itsHighlight-itsHeight/2;
|
||||||
if (itsBeginning > itsOptions.size()-itsHeight)
|
if (itsBeginning > itsOptions.size()-itsHeight)
|
||||||
itsBeginning = itsOptions.size()-itsHeight;
|
itsBeginning = itsOptions.size()-itsHeight;
|
||||||
|
if (itsBeginning < 0)
|
||||||
|
itsBeginning = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
itsBeginning = 0;
|
itsBeginning = 0;
|
||||||
@@ -522,6 +525,7 @@ void Menu::Highlight(int which)
|
|||||||
|
|
||||||
void Menu::Reset()
|
void Menu::Reset()
|
||||||
{
|
{
|
||||||
|
NeedsRedraw.clear();
|
||||||
itsHighlight = 0;
|
itsHighlight = 0;
|
||||||
itsBeginning = 0;
|
itsBeginning = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ class MPDConnection
|
|||||||
bool GetRepeat() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->repeat : 0; }
|
bool GetRepeat() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->repeat : 0; }
|
||||||
bool GetRandom() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->random : 0; }
|
bool GetRandom() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->random : 0; }
|
||||||
bool GetDBIsUpdating() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->updatingDb : 0; }
|
bool GetDBIsUpdating() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->updatingDb : 0; }
|
||||||
int GetVolume() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->volume : 0; }
|
int GetVolume() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->volume : -1; }
|
||||||
int GetCrossfade() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->crossfade : 0; }
|
int GetCrossfade() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->crossfade : -1; }
|
||||||
long long GetPlaylistID() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlist : -1; }
|
long long GetPlaylistID() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlist : -1; }
|
||||||
long long GetOldPlaylistID() const { return isConnected && itsOldStatus ? itsOldStatus->playlist : -1; }
|
long long GetOldPlaylistID() const { return isConnected && itsOldStatus ? itsOldStatus->playlist : -1; }
|
||||||
int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; }
|
int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; }
|
||||||
|
|||||||
237
src/ncmpcpp.cpp
237
src/ncmpcpp.cpp
@@ -26,16 +26,16 @@
|
|||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "lyrics.h"
|
#include "lyrics.h"
|
||||||
|
|
||||||
#define BLOCK_STATUSBAR_UPDATE \
|
#define LOCK_STATUSBAR \
|
||||||
if (Config.statusbar_visibility) \
|
if (Config.statusbar_visibility) \
|
||||||
block_statusbar_update = 1; \
|
block_statusbar_update = 1; \
|
||||||
else \
|
else \
|
||||||
block_progressbar_update = 1; \
|
block_progressbar_update = 1; \
|
||||||
allow_statusbar_unblock = 0
|
allow_statusbar_unblock = 0
|
||||||
|
|
||||||
#define UNBLOCK_STATUSBAR_UPDATE \
|
#define UNLOCK_STATUSBAR \
|
||||||
allow_statusbar_unblock = 1; \
|
allow_statusbar_unblock = 1; \
|
||||||
if (block_statusbar_update_delay < 0) \
|
if (block_statusbar_update_delay <= 0) \
|
||||||
{ \
|
{ \
|
||||||
if (Config.statusbar_visibility) \
|
if (Config.statusbar_visibility) \
|
||||||
block_statusbar_update = 0; \
|
block_statusbar_update = 0; \
|
||||||
@@ -52,10 +52,10 @@
|
|||||||
|
|
||||||
#ifdef HAVE_TAGLIB_H
|
#ifdef HAVE_TAGLIB_H
|
||||||
const string tag_screen = "Tag editor";
|
const string tag_screen = "Tag editor";
|
||||||
const string tag_screen_keydesc = "\tE e : Edit song's tags\n";
|
const string tag_screen_keydesc = "\te : Edit song's tags\n";
|
||||||
#else
|
#else
|
||||||
const string tag_screen = "Tag info";
|
const string tag_screen = "Tag info";
|
||||||
const string tag_screen_keydesc = "\tE e : Show song's tags\n";
|
const string tag_screen_keydesc = "\te : Show song's tags\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ncmpcpp_config Config;
|
ncmpcpp_config Config;
|
||||||
@@ -100,6 +100,7 @@ int block_statusbar_update_delay = -1;
|
|||||||
|
|
||||||
string browsed_dir = "/";
|
string browsed_dir = "/";
|
||||||
string browsed_subdir;
|
string browsed_subdir;
|
||||||
|
string song_lyrics;
|
||||||
string player_state;
|
string player_state;
|
||||||
string volume_state;
|
string volume_state;
|
||||||
string switch_state;
|
string switch_state;
|
||||||
@@ -170,7 +171,9 @@ int main(int argc, char *argv[])
|
|||||||
noecho();
|
noecho();
|
||||||
cbreak();
|
cbreak();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
EnableColors();
|
|
||||||
|
if (Config.colors_enabled)
|
||||||
|
EnableColors();
|
||||||
|
|
||||||
int main_start_y = 2;
|
int main_start_y = 2;
|
||||||
int main_height = LINES-4;
|
int main_height = LINES-4;
|
||||||
@@ -228,13 +231,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
sHelp->Add("\tr : Toggle repeat mode\n");
|
sHelp->Add("\tr : Toggle repeat mode\n");
|
||||||
sHelp->Add("\tz : Toggle random mode\n");
|
sHelp->Add("\tz : Toggle random mode\n");
|
||||||
sHelp->Add("\tx : Toggle crossfade mode\n");
|
|
||||||
sHelp->Add("\tZ : Shuffle playlist\n");
|
sHelp->Add("\tZ : Shuffle playlist\n");
|
||||||
sHelp->Add("\tU u : Start a music database update\n\n");
|
sHelp->Add("\tx : Toggle crossfade mode\n");
|
||||||
|
sHelp->Add("\tX : Set crossfade\n");
|
||||||
|
sHelp->Add("\tu : Start a music database update\n\n");
|
||||||
|
|
||||||
sHelp->Add("\t/ : Forward find\n");
|
sHelp->Add("\t/ : Forward find\n");
|
||||||
sHelp->Add("\t? : Backward find\n");
|
sHelp->Add("\t? : Backward find\n");
|
||||||
sHelp->Add("\t. : Go to next/previous found position\n");
|
sHelp->Add("\t, : Go to previous found position\n");
|
||||||
|
sHelp->Add("\t. : Go to next found position\n");
|
||||||
sHelp->Add(tag_screen_keydesc);
|
sHelp->Add(tag_screen_keydesc);
|
||||||
sHelp->Add("\tg : Go to chosen position in current song\n");
|
sHelp->Add("\tg : Go to chosen position in current song\n");
|
||||||
sHelp->Add("\tl : Show/hide song's lyrics\n\n");
|
sHelp->Add("\tl : Show/hide song's lyrics\n\n");
|
||||||
@@ -254,6 +259,7 @@ int main(int argc, char *argv[])
|
|||||||
sHelp->Add(" [b]Keys - Browse screen\n -----------------------------------------[/b]\n");
|
sHelp->Add(" [b]Keys - Browse screen\n -----------------------------------------[/b]\n");
|
||||||
sHelp->Add("\tEnter : Enter directory/Add to playlist and play song\n");
|
sHelp->Add("\tEnter : Enter directory/Add to playlist and play song\n");
|
||||||
sHelp->Add("\tSpace : Add song to playlist\n");
|
sHelp->Add("\tSpace : Add song to playlist\n");
|
||||||
|
sHelp->Add("\tBackspace : Go to parent directory\n");
|
||||||
sHelp->Add("\tDelete : Delete playlist\n\n\n");
|
sHelp->Add("\tDelete : Delete playlist\n\n\n");
|
||||||
|
|
||||||
sHelp->Add(" [b]Keys - Search engine\n -----------------------------------------[/b]\n");
|
sHelp->Add(" [b]Keys - Search engine\n -----------------------------------------[/b]\n");
|
||||||
@@ -305,6 +311,15 @@ int main(int argc, char *argv[])
|
|||||||
sLyrics->Timeout(ncmpcpp_window_timeout);
|
sLyrics->Timeout(ncmpcpp_window_timeout);
|
||||||
wFooter->Timeout(ncmpcpp_window_timeout);
|
wFooter->Timeout(ncmpcpp_window_timeout);
|
||||||
|
|
||||||
|
mPlaylist->HighlightColor(Config.main_highlight_color);
|
||||||
|
mBrowser->HighlightColor(Config.main_highlight_color);
|
||||||
|
mTagEditor->HighlightColor(Config.main_highlight_color);
|
||||||
|
mSearcher->HighlightColor(Config.main_highlight_color);
|
||||||
|
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||||
|
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||||
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
|
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||||
|
|
||||||
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
|
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
|
||||||
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
|
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
|
||||||
|
|
||||||
@@ -327,7 +342,7 @@ int main(int argc, char *argv[])
|
|||||||
if (Config.header_visibility)
|
if (Config.header_visibility)
|
||||||
{
|
{
|
||||||
string title;
|
string title;
|
||||||
int max_allowed_title_length = wHeader->GetWidth()-volume_state.length();
|
const int max_allowed_title_length = wHeader->GetWidth()-volume_state.length();
|
||||||
|
|
||||||
switch (current_screen)
|
switch (current_screen)
|
||||||
{
|
{
|
||||||
@@ -350,24 +365,18 @@ int main(int argc, char *argv[])
|
|||||||
title = "Media library";
|
title = "Media library";
|
||||||
break;
|
break;
|
||||||
case csLyrics:
|
case csLyrics:
|
||||||
title = "Lyrics";
|
title = song_lyrics;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title_allowed)
|
if (title_allowed)
|
||||||
{
|
{
|
||||||
wHeader->Bold(1);
|
wHeader->Bold(1);
|
||||||
wHeader->WriteXY(0, 0, title, 1);
|
wHeader->WriteXY(0, 0, max_allowed_title_length, title, 1);
|
||||||
wHeader->Bold(0);
|
wHeader->Bold(0);
|
||||||
|
|
||||||
if (current_screen == csPlaylist && !playlist_stats.empty())
|
if (current_screen == csPlaylist && !playlist_stats.empty())
|
||||||
{
|
wHeader->WriteXY(title.length(), 0, max_allowed_title_length-title.length(), playlist_stats);
|
||||||
int max_length = wHeader->GetWidth()-volume_state.length()-title.length();
|
|
||||||
if (playlist_stats.length() > max_length)
|
|
||||||
wHeader->WriteXY(title.length(), 0, playlist_stats.substr(0, max_length));
|
|
||||||
else
|
|
||||||
wHeader->WriteXY(title.length(), 0, playlist_stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current_screen == csBrowser)
|
if (current_screen == csBrowser)
|
||||||
{
|
{
|
||||||
@@ -395,7 +404,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wHeader->WriteXY(0, 0, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search [b]5:[/b]Library", 1);
|
wHeader->WriteXY(0, 0, max_allowed_title_length, "[b]1:[/b]Help [b]2:[/b]Playlist [b]3:[/b]Browse [b]4:[/b]Search [b]5:[/b]Library", 1);
|
||||||
|
|
||||||
wHeader->SetColor(Config.volume_color);
|
wHeader->SetColor(Config.volume_color);
|
||||||
wHeader->WriteXY(max_allowed_title_length, 0, volume_state);
|
wHeader->WriteXY(max_allowed_title_length, 0, volume_state);
|
||||||
@@ -406,7 +415,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent == mLibAlbums && mLibAlbums->Empty())
|
if (wCurrent == mLibAlbums && mLibAlbums->Empty())
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||||
wCurrent = mLibArtists;
|
wCurrent = mLibArtists;
|
||||||
}
|
}
|
||||||
@@ -591,6 +600,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KEY_BACKSPACE: case 127:
|
||||||
|
{
|
||||||
|
if (wCurrent == mBrowser && browsed_dir != "/")
|
||||||
|
mBrowser->Reset();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ENTER:
|
case ENTER:
|
||||||
{
|
{
|
||||||
switch (current_screen)
|
switch (current_screen)
|
||||||
@@ -627,10 +643,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (browsed_dir != "/")
|
if (browsed_dir != "/")
|
||||||
GetDirectory(browsed_dir + "/" + vBrowser[ci].name);
|
GetDirectory(browsed_dir + "/" + vBrowser[ci].name);
|
||||||
else
|
else
|
||||||
GetDirectory(vBrowser[ci].name);
|
GetDirectory(vBrowser[ci].name);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itSong:
|
case itSong:
|
||||||
@@ -671,7 +689,7 @@ int main(int argc, char *argv[])
|
|||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
int id = mTagEditor->GetRealChoice();
|
int id = mTagEditor->GetRealChoice();
|
||||||
int option = mTagEditor->GetChoice();
|
int option = mTagEditor->GetChoice();
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
Song &s = edited_song;
|
Song &s = edited_song;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
@@ -785,7 +803,7 @@ int main(int argc, char *argv[])
|
|||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
if (id == 8)
|
if (id == 8)
|
||||||
{
|
{
|
||||||
mLibSongs->HighlightColor(Config.main_color);
|
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||||
wCurrent = mLibArtists;
|
wCurrent = mLibArtists;
|
||||||
}
|
}
|
||||||
@@ -800,7 +818,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -808,7 +826,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int id = mSearcher->GetChoice();
|
int id = mSearcher->GetChoice();
|
||||||
int option = mSearcher->GetChoice();
|
int option = mSearcher->GetChoice();
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
Song &s = searched_song;
|
Song &s = searched_song;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
@@ -961,7 +979,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
@@ -1110,7 +1128,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent == mLibArtists)
|
if (wCurrent == mLibArtists)
|
||||||
{
|
{
|
||||||
mLibArtists->HighlightColor(Config.main_color);
|
mLibArtists->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibAlbums;
|
wCurrent = mLibAlbums;
|
||||||
mLibAlbums->HighlightColor(Config.library_active_column_color);
|
mLibAlbums->HighlightColor(Config.library_active_column_color);
|
||||||
@@ -1119,7 +1137,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (wCurrent == mLibAlbums)
|
if (wCurrent == mLibAlbums)
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibSongs;
|
wCurrent = mLibSongs;
|
||||||
mLibSongs->HighlightColor(Config.library_active_column_color);
|
mLibSongs->HighlightColor(Config.library_active_column_color);
|
||||||
@@ -1139,7 +1157,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent == mLibSongs)
|
if (wCurrent == mLibSongs)
|
||||||
{
|
{
|
||||||
mLibSongs->HighlightColor(Config.main_color);
|
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibAlbums;
|
wCurrent = mLibAlbums;
|
||||||
mLibAlbums->HighlightColor(Config.library_active_column_color);
|
mLibAlbums->HighlightColor(Config.library_active_column_color);
|
||||||
@@ -1148,7 +1166,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (wCurrent == mLibAlbums)
|
if (wCurrent == mLibAlbums)
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibArtists;
|
wCurrent = mLibArtists;
|
||||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||||
@@ -1196,7 +1214,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (current_screen == csBrowser)
|
if (current_screen == csBrowser)
|
||||||
{
|
{
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
int id = mBrowser->GetChoice()-1;
|
int id = mBrowser->GetChoice()-1;
|
||||||
if (vBrowser[id].type == itPlaylist)
|
if (vBrowser[id].type == itPlaylist)
|
||||||
{
|
{
|
||||||
@@ -1220,7 +1238,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
ShowMessage("Aborted!");
|
ShowMessage("Aborted!");
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1242,10 +1260,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
case 'S': // save playlist
|
case 'S': // save playlist
|
||||||
{
|
{
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Save playlist as: ", 1);
|
wFooter->WriteXY(0, Config.statusbar_visibility, "Save playlist as: ", 1);
|
||||||
string playlist_name = wFooter->GetString("", TraceMpdStatus);
|
string playlist_name = wFooter->GetString("", TraceMpdStatus);
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
if (playlist_name.find("/") != string::npos)
|
if (playlist_name.find("/") != string::npos)
|
||||||
{
|
{
|
||||||
ShowMessage("Playlist name cannot contain slashes!");
|
ShowMessage("Playlist name cannot contain slashes!");
|
||||||
@@ -1331,7 +1349,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
block_progressbar_update = 1;
|
block_progressbar_update = 1;
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
|
|
||||||
int songpos, in;
|
int songpos, in;
|
||||||
|
|
||||||
@@ -1370,11 +1388,11 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->Seek(songpos);
|
Mpd->Seek(songpos);
|
||||||
|
|
||||||
block_progressbar_update = 0;
|
block_progressbar_update = 0;
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'U': case 'u': // update database
|
case 'u': // update database
|
||||||
{
|
{
|
||||||
if (current_screen == csBrowser)
|
if (current_screen == csBrowser)
|
||||||
Mpd->UpdateDirectory(browsed_dir);
|
Mpd->UpdateDirectory(browsed_dir);
|
||||||
@@ -1382,7 +1400,7 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->UpdateDirectory("/");
|
Mpd->UpdateDirectory("/");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'O': case 'o': // go to playing song
|
case 'o': // go to playing song
|
||||||
{
|
{
|
||||||
if (current_screen == csPlaylist && now_playing >= 0)
|
if (current_screen == csPlaylist && now_playing >= 0)
|
||||||
mPlaylist->Highlight(now_playing+1);
|
mPlaylist->Highlight(now_playing+1);
|
||||||
@@ -1408,77 +1426,55 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time);
|
Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'E': case 'e': // edit song's tags
|
case 'X': // set crossfade
|
||||||
{
|
{
|
||||||
int id = wCurrent->GetChoice()-1;
|
LOCK_STATUSBAR;
|
||||||
switch (current_screen)
|
wFooter->WriteXY(0, Config.statusbar_visibility, "Set crossfade to: ", 1);
|
||||||
|
string crossfade = wFooter->GetString(3, TraceMpdStatus);
|
||||||
|
UNLOCK_STATUSBAR;
|
||||||
|
int cf = StrToInt(crossfade);
|
||||||
|
if (cf > 0)
|
||||||
{
|
{
|
||||||
case csPlaylist:
|
Config.crossfade_time = cf;
|
||||||
|
Mpd->SetCrossfade(cf);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'e': // edit song's tags
|
||||||
|
{
|
||||||
|
if ((wCurrent == mPlaylist && !vPlaylist.empty())
|
||||||
|
|| (wCurrent == mBrowser && vBrowser[mBrowser->GetChoice()-1].type == itSong)
|
||||||
|
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|
||||||
|
|| (wCurrent == mLibSongs && !vSongs.empty()))
|
||||||
|
{
|
||||||
|
int id = wCurrent->GetChoice()-1;
|
||||||
|
Song *s;
|
||||||
|
switch (current_screen)
|
||||||
{
|
{
|
||||||
if (!mPlaylist->Empty())
|
case csPlaylist:
|
||||||
{
|
s = vPlaylist[id];
|
||||||
if (GetSongInfo(*vPlaylist[id]))
|
break;
|
||||||
{
|
case csBrowser:
|
||||||
wCurrent = mTagEditor;
|
s = vBrowser[id].song;
|
||||||
wPrev = mPlaylist;
|
break;
|
||||||
current_screen = csTagEditor;
|
case csSearcher:
|
||||||
prev_screen = csPlaylist;
|
s = vSearched[id-search_engine_static_option];
|
||||||
}
|
break;
|
||||||
else
|
case csLibrary:
|
||||||
ShowMessage("Cannot read file!");
|
s = vSongs[id];
|
||||||
}
|
break;
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case csBrowser:
|
if (GetSongInfo(*s))
|
||||||
{
|
{
|
||||||
if (vBrowser[id].type == itSong)
|
wPrev = wCurrent;
|
||||||
{
|
wCurrent = mTagEditor;
|
||||||
Song edited = Mpd->GetSong(vBrowser[id].name.c_str());
|
prev_screen = current_screen;
|
||||||
if (GetSongInfo(edited))
|
current_screen = csTagEditor;
|
||||||
{
|
|
||||||
wCurrent = mTagEditor;
|
|
||||||
wPrev = mBrowser;
|
|
||||||
current_screen = csTagEditor;
|
|
||||||
prev_screen = csBrowser;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowMessage("Cannot read file!");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case csSearcher:
|
else
|
||||||
{
|
ShowMessage("Cannot read file!");
|
||||||
if (id >= search_engine_static_option && !vSearched.empty())
|
|
||||||
{
|
|
||||||
if (GetSongInfo(*vSearched[id-search_engine_static_option]))
|
|
||||||
{
|
|
||||||
wCurrent = mTagEditor;
|
|
||||||
wPrev = mSearcher;
|
|
||||||
current_screen = csTagEditor;
|
|
||||||
prev_screen = csSearcher;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowMessage("Cannot read file!");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case csLibrary:
|
|
||||||
{
|
|
||||||
if (!vSongs.empty() && wCurrent == mLibSongs)
|
|
||||||
{
|
|
||||||
if (GetSongInfo(*vSongs[id]))
|
|
||||||
{
|
|
||||||
wPrev = wCurrent;
|
|
||||||
wCurrent = mTagEditor;
|
|
||||||
current_screen = csTagEditor;
|
|
||||||
prev_screen = csLibrary;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ShowMessage("Cannot read file!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1488,13 +1484,13 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
int newpos = 0;
|
int newpos = 0;
|
||||||
string position;
|
string position;
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Position to go (in %): ", 1);
|
wFooter->WriteXY(0, Config.statusbar_visibility, "Position to go (in %): ", 1);
|
||||||
position = wFooter->GetString(3, TraceMpdStatus);
|
position = wFooter->GetString(3, TraceMpdStatus);
|
||||||
newpos = atoi(position.c_str());
|
newpos = atoi(position.c_str());
|
||||||
if (newpos > 0 && newpos < 100 && !position.empty())
|
if (newpos > 0 && newpos < 100 && !position.empty())
|
||||||
Mpd->Seek(vPlaylist[now_playing]->GetTotalLength()*newpos/100.0);
|
Mpd->Seek(vPlaylist[now_playing]->GetTotalLength()*newpos/100.0);
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'C': // clear playlist but holds currently playing song
|
case 'C': // clear playlist but holds currently playing song
|
||||||
@@ -1528,10 +1524,10 @@ int main(int argc, char *argv[])
|
|||||||
found_pos = 0;
|
found_pos = 0;
|
||||||
vFoundPositions.clear();
|
vFoundPositions.clear();
|
||||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||||
BLOCK_STATUSBAR_UPDATE;
|
LOCK_STATUSBAR;
|
||||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Find " + how + ": ", 1);
|
wFooter->WriteXY(0, Config.statusbar_visibility, "Find " + how + ": ", 1);
|
||||||
string findme = wFooter->GetString("", TraceMpdStatus);
|
string findme = wFooter->GetString("", TraceMpdStatus);
|
||||||
UNBLOCK_STATUSBAR_UPDATE;
|
UNLOCK_STATUSBAR;
|
||||||
timer = time(NULL);
|
timer = time(NULL);
|
||||||
if (findme.empty())
|
if (findme.empty())
|
||||||
break;
|
break;
|
||||||
@@ -1568,19 +1564,27 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '.': // go to next/previous found position
|
case ',': case '.': // go to previous/next found position
|
||||||
{
|
{
|
||||||
if (!vFoundPositions.empty())
|
if (!vFoundPositions.empty())
|
||||||
{
|
{
|
||||||
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
Menu *mCurrent = static_cast<Menu *>(wCurrent);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mCurrent->Highlight(vFoundPositions.at(++found_pos));
|
mCurrent->Highlight(vFoundPositions.at(input == '.' ? ++found_pos : --found_pos));
|
||||||
}
|
}
|
||||||
catch (std::out_of_range)
|
catch (std::out_of_range)
|
||||||
{
|
{
|
||||||
mCurrent->Highlight(vFoundPositions.front());
|
if (input == '.')
|
||||||
found_pos = 0;
|
{
|
||||||
|
mCurrent->Highlight(vFoundPositions.front());
|
||||||
|
found_pos = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCurrent->Highlight(vFoundPositions.back());
|
||||||
|
found_pos = vFoundPositions.size()-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1602,7 +1606,7 @@ int main(int argc, char *argv[])
|
|||||||
if ((wCurrent == mPlaylist && !vPlaylist.empty())
|
if ((wCurrent == mPlaylist && !vPlaylist.empty())
|
||||||
|| (wCurrent == mBrowser && vBrowser[mBrowser->GetChoice()-1].type == itSong)
|
|| (wCurrent == mBrowser && vBrowser[mBrowser->GetChoice()-1].type == itSong)
|
||||||
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|
|| (wCurrent == mSearcher && !vSearched.empty() && mSearcher->GetChoice() > search_engine_static_option)
|
||||||
|| (wCurrent == mLibSongs))
|
|| (wCurrent == mLibSongs && !vSongs.empty()))
|
||||||
{
|
{
|
||||||
Song *s;
|
Song *s;
|
||||||
switch (current_screen)
|
switch (current_screen)
|
||||||
@@ -1614,7 +1618,7 @@ int main(int argc, char *argv[])
|
|||||||
s = vBrowser[mBrowser->GetChoice()-1].song;
|
s = vBrowser[mBrowser->GetChoice()-1].song;
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
s = vSearched[mSearcher->GetChoice()-search_engine_static_option-1];
|
s = vSearched[mSearcher->GetRealChoice()-2]; // first one is 'Reset'
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
s = vSongs[mLibSongs->GetChoice()-1];
|
s = vSongs[mLibSongs->GetChoice()-1];
|
||||||
@@ -1631,10 +1635,9 @@ int main(int argc, char *argv[])
|
|||||||
wCurrent->Hide();
|
wCurrent->Hide();
|
||||||
wCurrent->Clear();
|
wCurrent->Clear();
|
||||||
current_screen = csLyrics;
|
current_screen = csLyrics;
|
||||||
|
song_lyrics = "Lyrics: " + s->GetArtist() + " - " + s->GetTitle();
|
||||||
sLyrics->WriteXY(0, 0, "Fetching lyrics...");
|
sLyrics->WriteXY(0, 0, "Fetching lyrics...");
|
||||||
sLyrics->Refresh();
|
sLyrics->Refresh();
|
||||||
sLyrics->Add("[b]" + s->GetArtist() + " - " + s->GetTitle() + "[/b]\n\n");
|
|
||||||
sLyrics->Add(GetLyrics(s->GetArtist(), s->GetTitle()));
|
sLyrics->Add(GetLyrics(s->GetArtist(), s->GetTitle()));
|
||||||
sLyrics->Timeout(ncmpcpp_window_timeout);
|
sLyrics->Timeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
@@ -1761,8 +1764,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
mLibArtists->HighlightColor(Config.library_active_column_color);
|
mLibArtists->HighlightColor(Config.library_active_column_color);
|
||||||
mLibAlbums->HighlightColor(Config.main_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
mLibSongs->HighlightColor(Config.main_color);
|
mLibSongs->HighlightColor(Config.main_highlight_color);
|
||||||
|
|
||||||
wCurrent->Hide();
|
wCurrent->Hide();
|
||||||
|
|
||||||
|
|||||||
@@ -27,19 +27,22 @@ using std::ifstream;
|
|||||||
void DefaultConfiguration(ncmpcpp_config &conf)
|
void DefaultConfiguration(ncmpcpp_config &conf)
|
||||||
{
|
{
|
||||||
conf.mpd_music_dir = "/var/lib/mpd/music";
|
conf.mpd_music_dir = "/var/lib/mpd/music";
|
||||||
conf.song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f}";
|
conf.song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f[/white]}";
|
||||||
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}";
|
||||||
|
conf.browser_playlist_prefix = "[red](playlist)[/red] ";
|
||||||
conf.empty_tags_color = clCyan;
|
conf.empty_tags_color = clCyan;
|
||||||
conf.header_color = clDefault;
|
conf.header_color = clDefault;
|
||||||
conf.volume_color = clDefault;
|
conf.volume_color = clDefault;
|
||||||
conf.state_line_color = clDefault;
|
conf.state_line_color = clDefault;
|
||||||
conf.state_flags_color = clDefault;
|
conf.state_flags_color = clDefault;
|
||||||
conf.main_color = clYellow;
|
conf.main_color = clYellow;
|
||||||
|
conf.main_highlight_color = conf.main_color;
|
||||||
conf.progressbar_color = clDefault;
|
conf.progressbar_color = clDefault;
|
||||||
conf.statusbar_color = clDefault;
|
conf.statusbar_color = clDefault;
|
||||||
conf.library_active_column_color = clRed;
|
conf.library_active_column_color = clRed;
|
||||||
|
conf.colors_enabled = true;
|
||||||
conf.header_visibility = true;
|
conf.header_visibility = true;
|
||||||
conf.statusbar_visibility = true;
|
conf.statusbar_visibility = true;
|
||||||
conf.set_window_title = true;
|
conf.set_window_title = true;
|
||||||
@@ -169,12 +172,22 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.song_library_format = v;
|
conf.song_library_format = v;
|
||||||
|
|
||||||
|
if (it->find("browser_playlist_prefix") != string::npos)
|
||||||
|
if (!v.empty())
|
||||||
|
conf.browser_playlist_prefix = v;
|
||||||
|
|
||||||
|
if (it->find("colors_enabled") != string::npos)
|
||||||
|
conf.colors_enabled = v == "yes";
|
||||||
|
|
||||||
if (it->find("header_visibility") != string::npos)
|
if (it->find("header_visibility") != string::npos)
|
||||||
conf.header_visibility = v == "yes";
|
conf.header_visibility = v == "yes";
|
||||||
|
|
||||||
if (it->find("statusbar_visibility") != string::npos)
|
if (it->find("statusbar_visibility") != string::npos)
|
||||||
conf.statusbar_visibility = v == "yes";
|
conf.statusbar_visibility = v == "yes";
|
||||||
|
|
||||||
|
if (it->find("enable_window_title") != string::npos)
|
||||||
|
conf.set_window_title = v == "yes";
|
||||||
|
|
||||||
if (it->find("song_window_title_format") != string::npos)
|
if (it->find("song_window_title_format") != string::npos)
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.song_window_title_format = v;
|
conf.song_window_title_format = v;
|
||||||
@@ -203,6 +216,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
|||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.main_color = IntoColor(v);
|
conf.main_color = IntoColor(v);
|
||||||
|
|
||||||
|
if (it->find("main_window_highlight_color") != string::npos)
|
||||||
|
if (!v.empty())
|
||||||
|
conf.main_highlight_color = IntoColor(v);
|
||||||
|
|
||||||
if (it->find("progressbar_color") != string::npos)
|
if (it->find("progressbar_color") != string::npos)
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
conf.progressbar_color = IntoColor(v);
|
conf.progressbar_color = IntoColor(v);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ struct ncmpcpp_config
|
|||||||
string song_status_format;
|
string song_status_format;
|
||||||
string song_window_title_format;
|
string song_window_title_format;
|
||||||
string song_library_format;
|
string song_library_format;
|
||||||
|
string browser_playlist_prefix;
|
||||||
|
|
||||||
COLOR empty_tags_color;
|
COLOR empty_tags_color;
|
||||||
COLOR header_color;
|
COLOR header_color;
|
||||||
@@ -39,10 +40,12 @@ struct ncmpcpp_config
|
|||||||
COLOR state_line_color;
|
COLOR state_line_color;
|
||||||
COLOR state_flags_color;
|
COLOR state_flags_color;
|
||||||
COLOR main_color;
|
COLOR main_color;
|
||||||
|
COLOR main_highlight_color;
|
||||||
COLOR progressbar_color;
|
COLOR progressbar_color;
|
||||||
COLOR statusbar_color;
|
COLOR statusbar_color;
|
||||||
COLOR library_active_column_color;
|
COLOR library_active_column_color;
|
||||||
|
|
||||||
|
bool colors_enabled;
|
||||||
bool set_window_title;
|
bool set_window_title;
|
||||||
bool header_visibility;
|
bool header_visibility;
|
||||||
bool statusbar_visibility;
|
bool statusbar_visibility;
|
||||||
|
|||||||
@@ -259,25 +259,32 @@ void Window::ReadKey() const
|
|||||||
wgetch(itsWindow);
|
wgetch(itsWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::Write(const string &str, CLEAR_TO_EOL clrtoeol)
|
void Window::Write(int limit, const string &str, CLEAR_TO_EOL clrtoeol)
|
||||||
{
|
{
|
||||||
if (BBEnabled && !str.empty())
|
if (BBEnabled && !str.empty())
|
||||||
{
|
{
|
||||||
bool collect = false;
|
bool collect = false;
|
||||||
string color, tmp;
|
string color, tmp;
|
||||||
for (string::const_iterator it = str.begin(); it != str.end(); it++)
|
for (string::const_iterator it = str.begin(); it != str.end() && limit > 0; it++)
|
||||||
{
|
{
|
||||||
if (*it != '[' && !collect)
|
if (*it != '[' && !collect)
|
||||||
|
{
|
||||||
tmp += *it;
|
tmp += *it;
|
||||||
|
limit--;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
collect = 1;
|
collect = 1;
|
||||||
|
|
||||||
if (collect)
|
if (collect)
|
||||||
{
|
{
|
||||||
if (*it != '[')
|
if (*it != '[')
|
||||||
|
{
|
||||||
color += *it;
|
color += *it;
|
||||||
|
if (color.length() > 10) collect = 0; // longest bbcode is 10 chars long
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
limit -= color.length();
|
||||||
tmp += color;
|
tmp += color;
|
||||||
color = *it;
|
color = *it;
|
||||||
}
|
}
|
||||||
@@ -286,7 +293,7 @@ void Window::Write(const string &str, CLEAR_TO_EOL clrtoeol)
|
|||||||
if (*it == ']' || it+1 == str.end())
|
if (*it == ']' || it+1 == str.end())
|
||||||
collect = 0;
|
collect = 0;
|
||||||
|
|
||||||
if (!collect)
|
if (!collect && !color.empty())
|
||||||
{
|
{
|
||||||
waddstr(itsWindow,tmp.c_str());
|
waddstr(itsWindow,tmp.c_str());
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
@@ -297,7 +304,10 @@ void Window::Write(const string &str, CLEAR_TO_EOL clrtoeol)
|
|||||||
delete [] colors;
|
delete [] colors;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tmp += color;
|
{
|
||||||
|
limit -= color.length();
|
||||||
|
tmp += limit > 0 ? color : color.substr(0, color.length()+limit);
|
||||||
|
}
|
||||||
color.clear();
|
color.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,25 +323,32 @@ void Window::Write(const string &str, CLEAR_TO_EOL clrtoeol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UTF8_ENABLED
|
#ifdef UTF8_ENABLED
|
||||||
void Window::Write(const wstring &str, CLEAR_TO_EOL clrtoeol)
|
void Window::Write(int limit, const wstring &str, CLEAR_TO_EOL clrtoeol)
|
||||||
{
|
{
|
||||||
if (BBEnabled)
|
if (BBEnabled)
|
||||||
{
|
{
|
||||||
bool collect = false;
|
bool collect = false;
|
||||||
wstring color, tmp;
|
wstring color, tmp;
|
||||||
for (wstring::const_iterator it = str.begin(); it != str.end(); it++)
|
for (wstring::const_iterator it = str.begin(); it != str.end() && limit > 0; it++)
|
||||||
{
|
{
|
||||||
if (*it != '[' && !collect)
|
if (*it != '[' && !collect)
|
||||||
|
{
|
||||||
tmp += *it;
|
tmp += *it;
|
||||||
|
limit--;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
collect = 1;
|
collect = 1;
|
||||||
|
|
||||||
if (collect)
|
if (collect)
|
||||||
{
|
{
|
||||||
if (*it != '[')
|
if (*it != '[')
|
||||||
|
{
|
||||||
color += *it;
|
color += *it;
|
||||||
|
if (color.length() > 10) collect = 0; // longest bbcode is 10 chars long
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
limit -= color.length();
|
||||||
tmp += color;
|
tmp += color;
|
||||||
color = *it;
|
color = *it;
|
||||||
}
|
}
|
||||||
@@ -340,7 +357,7 @@ void Window::Write(const wstring &str, CLEAR_TO_EOL clrtoeol)
|
|||||||
if (*it == ']' || it+1 == str.end())
|
if (*it == ']' || it+1 == str.end())
|
||||||
collect = 0;
|
collect = 0;
|
||||||
|
|
||||||
if (!collect)
|
if (!collect && !color.empty())
|
||||||
{
|
{
|
||||||
waddwstr(itsWindow,tmp.c_str());
|
waddwstr(itsWindow,tmp.c_str());
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
@@ -351,7 +368,10 @@ void Window::Write(const wstring &str, CLEAR_TO_EOL clrtoeol)
|
|||||||
delete [] colors;
|
delete [] colors;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tmp += color;
|
{
|
||||||
|
limit -= color.length();
|
||||||
|
tmp += limit > 0 ? color : color.substr(0, color.length()+limit);
|
||||||
|
}
|
||||||
color.clear();
|
color.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -366,17 +386,17 @@ void Window::Write(const wstring &str, CLEAR_TO_EOL clrtoeol)
|
|||||||
wrefresh(itsWindow);
|
wrefresh(itsWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::WriteXY(int x, int y, const wstring &str, CLEAR_TO_EOL cleartoeol)
|
void Window::WriteXY(int x, int y, int limit, const wstring &str, CLEAR_TO_EOL cleartoeol)
|
||||||
{
|
{
|
||||||
wmove(itsWindow,y,x);
|
wmove(itsWindow,y,x);
|
||||||
Write(str, cleartoeol);
|
Write(limit, str, cleartoeol);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Window::WriteXY(int x, int y, const string &str, CLEAR_TO_EOL cleartoeol)
|
void Window::WriteXY(int x, int y, int limit, const string &str, CLEAR_TO_EOL cleartoeol)
|
||||||
{
|
{
|
||||||
wmove(itsWindow,y,x);
|
wmove(itsWindow,y,x);
|
||||||
Write(str, cleartoeol);
|
Write(limit, str, cleartoeol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
12
src/window.h
12
src/window.h
@@ -82,11 +82,15 @@ class Window
|
|||||||
virtual void AutoRefresh(bool val) { AutoRefreshEnabled = val; }
|
virtual void AutoRefresh(bool val) { AutoRefreshEnabled = val; }
|
||||||
virtual void ReadKey(int &) const;
|
virtual void ReadKey(int &) const;
|
||||||
virtual void ReadKey() const;
|
virtual void ReadKey() const;
|
||||||
virtual void Write(const string &, CLEAR_TO_EOL = 1);
|
virtual void Write(const string &s, CLEAR_TO_EOL cte = 0) { Write(0xFFFF, s, cte); }
|
||||||
virtual void WriteXY(int, int, const string &, CLEAR_TO_EOL = 0);
|
virtual void Write(int, const string &, CLEAR_TO_EOL = 0);
|
||||||
|
virtual void WriteXY(int x, int y, const string &s, CLEAR_TO_EOL ete = 0) { WriteXY(x, y, 0xFFFF, s, ete); }
|
||||||
|
virtual void WriteXY(int, int, int, const string &, CLEAR_TO_EOL = 0);
|
||||||
#ifdef UTF8_ENABLED
|
#ifdef UTF8_ENABLED
|
||||||
virtual void Write(const wstring &, CLEAR_TO_EOL = 1);
|
virtual void Write(const wstring &s, CLEAR_TO_EOL cte = 0) { Write(0xFFFF, s, cte); }
|
||||||
virtual void WriteXY(int, int, const wstring &, CLEAR_TO_EOL = 0);
|
virtual void Write(int, const wstring &, CLEAR_TO_EOL = 0);
|
||||||
|
virtual void WriteXY(int x, int y, const wstring &s, CLEAR_TO_EOL ete = 0) { WriteXY(x, y, 0xFFFF, s, ete); }
|
||||||
|
virtual void WriteXY(int, int, int, const wstring &, CLEAR_TO_EOL = 0);
|
||||||
#endif
|
#endif
|
||||||
virtual string GetString(int num, void (*ptr)() = NULL) const { return GetString("", num, ptr); }
|
virtual string GetString(int num, void (*ptr)() = NULL) const { return GetString("", num, ptr); }
|
||||||
virtual string GetString(const string &str, void (*ptr)()) const { return GetString(str, -1, ptr); }
|
virtual string GetString(const string &str, void (*ptr)()) const { return GetString(str, -1, ptr); }
|
||||||
|
|||||||
Reference in New Issue
Block a user