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