use CamelCase for variables in Global namespace / some cleaning
This commit is contained in:
@@ -51,7 +51,7 @@ const char *Browser::SupportedExtensions[] =
|
|||||||
|
|
||||||
void Browser::Init()
|
void Browser::Init()
|
||||||
{
|
{
|
||||||
w = new Menu<Item>(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Menu<Item>(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||||
w->HighlightColor(Config.main_highlight_color);
|
w->HighlightColor(Config.main_highlight_color);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
w->SetSelectPrefix(&Config.selected_item_prefix);
|
w->SetSelectPrefix(&Config.selected_item_prefix);
|
||||||
@@ -62,7 +62,7 @@ void Browser::Init()
|
|||||||
|
|
||||||
void Browser::Resize()
|
void Browser::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,13 +76,13 @@ void Browser::SwitchTo()
|
|||||||
|
|
||||||
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
|
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Browser::Title()
|
std::string Browser::Title()
|
||||||
{
|
{
|
||||||
string result = "Browse: ";
|
string result = "Browse: ";
|
||||||
result += TO_STRING(Scroller(itsBrowsedDir, COLS-result.length()-volume_state.length(), itsScrollBeginning));
|
result += TO_STRING(Scroller(itsBrowsedDir, COLS-result.length()-VolumeState.length(), itsScrollBeginning));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,12 +97,12 @@ void Browser::EnterPressed()
|
|||||||
case itDirectory:
|
case itDirectory:
|
||||||
{
|
{
|
||||||
GetDirectory(item.name, itsBrowsedDir);
|
GetDirectory(item.name, itsBrowsedDir);
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itSong:
|
case itSong:
|
||||||
{
|
{
|
||||||
block_item_list_update = 1;
|
BlockItemListUpdate = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||||
{
|
{
|
||||||
bool found = 0;
|
bool found = 0;
|
||||||
@@ -193,7 +193,7 @@ void Browser::SpacePressed()
|
|||||||
}
|
}
|
||||||
case itSong:
|
case itSong:
|
||||||
{
|
{
|
||||||
block_item_list_update = 1;
|
BlockItemListUpdate = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||||
{
|
{
|
||||||
Playlist::BlockUpdate = 1;
|
Playlist::BlockUpdate = 1;
|
||||||
@@ -439,7 +439,7 @@ void Browser::ChangeBrowseMode()
|
|||||||
itsBrowsedDir = Config.local_browser ? home_folder : "/";
|
itsBrowsedDir = Config.local_browser ? home_folder : "/";
|
||||||
w->Reset();
|
w->Reset();
|
||||||
GetDirectory(itsBrowsedDir);
|
GetDirectory(itsBrowsedDir);
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::UpdateItemList()
|
void Browser::UpdateItemList()
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void Clock::Init()
|
|||||||
|
|
||||||
void Clock::Resize()
|
void Clock::Resize()
|
||||||
{
|
{
|
||||||
if (Width <= size_t(COLS) && Height <= main_height)
|
if (Width <= size_t(COLS) && Height <= MainHeight)
|
||||||
{
|
{
|
||||||
w->MoveTo((COLS-Width)/2, (LINES-Height)/2);
|
w->MoveTo((COLS-Width)/2, (LINES-Height)/2);
|
||||||
if (myScreen == this)
|
if (myScreen == this)
|
||||||
@@ -72,7 +72,7 @@ void Clock::Resize()
|
|||||||
|
|
||||||
void Clock::SwitchTo()
|
void Clock::SwitchTo()
|
||||||
{
|
{
|
||||||
if (Width > size_t(COLS) || Height > main_height)
|
if (Width > size_t(COLS) || Height > MainHeight)
|
||||||
{
|
{
|
||||||
ShowMessage("Screen is too small to display clock!");
|
ShowMessage("Screen is too small to display clock!");
|
||||||
return;
|
return;
|
||||||
@@ -85,7 +85,7 @@ void Clock::SwitchTo()
|
|||||||
|
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
myPlaylist->Main()->Hide();
|
myPlaylist->Main()->Hide();
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
Prepare();
|
Prepare();
|
||||||
w->Display();
|
w->Display();
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ std::string Clock::Title()
|
|||||||
|
|
||||||
void Clock::Update()
|
void Clock::Update()
|
||||||
{
|
{
|
||||||
if (Width > size_t(COLS) || Height > main_height)
|
if (Width > size_t(COLS) || Height > MainHeight)
|
||||||
myPlaylist->SwitchTo();
|
myPlaylist->SwitchTo();
|
||||||
|
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
|
|||||||
19
src/global.h
19
src/global.h
@@ -25,8 +25,6 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/// FIXME: this is absolutely shitty, I need to get rid of this.
|
|
||||||
|
|
||||||
namespace Global
|
namespace Global
|
||||||
{
|
{
|
||||||
extern BasicScreen *myScreen;
|
extern BasicScreen *myScreen;
|
||||||
@@ -37,22 +35,21 @@ namespace Global
|
|||||||
|
|
||||||
extern MPD::Connection *Mpd;
|
extern MPD::Connection *Mpd;
|
||||||
|
|
||||||
extern size_t main_start_y;
|
extern size_t MainStartY;
|
||||||
extern size_t main_height;
|
extern size_t MainHeight;
|
||||||
|
|
||||||
extern time_t timer;
|
extern time_t Timer;
|
||||||
|
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
extern pthread_mutex_t curl;
|
extern pthread_mutex_t CurlLock;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
extern bool block_progressbar_update;
|
extern bool BlockItemListUpdate;
|
||||||
extern bool block_item_list_update;
|
|
||||||
|
|
||||||
extern bool messages_allowed;
|
extern bool MessagesAllowed;
|
||||||
extern bool redraw_header;
|
extern bool RedrawHeader;
|
||||||
|
|
||||||
extern std::string volume_state;
|
extern std::string VolumeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Help *myHelp = new Help;
|
|||||||
|
|
||||||
void Help::Init()
|
void Help::Init()
|
||||||
{
|
{
|
||||||
w = new Scrollpad(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
GetKeybindings();
|
GetKeybindings();
|
||||||
w->Flush();
|
w->Flush();
|
||||||
@@ -39,7 +39,7 @@ void Help::Init()
|
|||||||
|
|
||||||
void Help::Resize()
|
void Help::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ void Help::SwitchTo()
|
|||||||
Resize();
|
Resize();
|
||||||
|
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
src/info.cpp
12
src/info.cpp
@@ -52,13 +52,13 @@ Info *myInfo = new Info;
|
|||||||
|
|
||||||
void Info::Init()
|
void Info::Init()
|
||||||
{
|
{
|
||||||
w = new Scrollpad(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Info::Resize()
|
void Info::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ void Info::GetSong()
|
|||||||
|
|
||||||
myOldScreen = myScreen;
|
myOldScreen = myScreen;
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
itsTitle = "Song info";
|
itsTitle = "Song info";
|
||||||
w->Clear();
|
w->Clear();
|
||||||
PrepareSong(*s);
|
PrepareSong(*s);
|
||||||
@@ -139,7 +139,7 @@ void Info::GetArtist()
|
|||||||
Resize();
|
Resize();
|
||||||
myOldScreen = myScreen;
|
myOldScreen = myScreen;
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
itsTitle = "Artist's info - " + *artist;
|
itsTitle = "Artist's info - " + *artist;
|
||||||
w->Clear();
|
w->Clear();
|
||||||
static_cast<Window &>(*w) << "Fetching artist's info...";
|
static_cast<Window &>(*w) << "Fetching artist's info...";
|
||||||
@@ -198,7 +198,7 @@ void *Info::PrepareArtist(void *ptr)
|
|||||||
url += c_artist;
|
url += c_artist;
|
||||||
url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79";
|
url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79";
|
||||||
|
|
||||||
pthread_mutex_lock(&curl);
|
pthread_mutex_lock(&CurlLock);
|
||||||
CURL *info = curl_easy_init();
|
CURL *info = curl_easy_init();
|
||||||
curl_easy_setopt(info, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(info, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(info, CURLOPT_WRITEFUNCTION, write_data);
|
curl_easy_setopt(info, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
@@ -207,7 +207,7 @@ void *Info::PrepareArtist(void *ptr)
|
|||||||
curl_easy_setopt(info, CURLOPT_NOSIGNAL, 1);
|
curl_easy_setopt(info, CURLOPT_NOSIGNAL, 1);
|
||||||
code = curl_easy_perform(info);
|
code = curl_easy_perform(info);
|
||||||
curl_easy_cleanup(info);
|
curl_easy_cleanup(info);
|
||||||
pthread_mutex_unlock(&curl);
|
pthread_mutex_unlock(&CurlLock);
|
||||||
|
|
||||||
curl_free(c_artist);
|
curl_free(c_artist);
|
||||||
|
|
||||||
|
|||||||
@@ -49,23 +49,23 @@ bool Lyrics::Reload = 0;
|
|||||||
std::string Lyrics::Filename;
|
std::string Lyrics::Filename;
|
||||||
|
|
||||||
#ifdef HAVE_CURL_CURL_H
|
#ifdef HAVE_CURL_CURL_H
|
||||||
pthread_mutex_t Global::curl = PTHREAD_MUTEX_INITIALIZER;
|
pthread_t Lyrics::Downloader = 0;
|
||||||
|
pthread_mutex_t Global::CurlLock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
bool Lyrics::Ready = 0;
|
bool Lyrics::Ready = 0;
|
||||||
pthread_t Lyrics::Downloader = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Lyrics *myLyrics = new Lyrics;
|
Lyrics *myLyrics = new Lyrics;
|
||||||
|
|
||||||
void Lyrics::Init()
|
void Lyrics::Init()
|
||||||
{
|
{
|
||||||
w = new Scrollpad(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lyrics::Resize()
|
void Lyrics::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ void Lyrics::SwitchTo()
|
|||||||
myOldScreen = myScreen;
|
myOldScreen = myScreen;
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
}
|
}
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
w->Clear();
|
w->Clear();
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
static_cast<Window &>(*w) << "Fetching lyrics...";
|
static_cast<Window &>(*w) << "Fetching lyrics...";
|
||||||
@@ -144,7 +144,7 @@ void Lyrics::SwitchTo()
|
|||||||
std::string Lyrics::Title()
|
std::string Lyrics::Title()
|
||||||
{
|
{
|
||||||
string result = "Lyrics: ";
|
string result = "Lyrics: ";
|
||||||
result += TO_STRING(Scroller(itsSong.toString("%a - %t"), COLS-result.length()-volume_state.length(), itsScrollBegin));
|
result += TO_STRING(Scroller(itsSong.toString("%a - %t"), COLS-result.length()-VolumeState.length(), itsScrollBegin));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ void *Lyrics::Get(void *song)
|
|||||||
url.replace(url.find("%artist%"), 8, c_artist);
|
url.replace(url.find("%artist%"), 8, c_artist);
|
||||||
url.replace(url.find("%title%"), 7, c_title);
|
url.replace(url.find("%title%"), 7, c_title);
|
||||||
|
|
||||||
pthread_mutex_lock(&curl);
|
pthread_mutex_lock(&CurlLock);
|
||||||
CURL *lyrics = curl_easy_init();
|
CURL *lyrics = curl_easy_init();
|
||||||
curl_easy_setopt(lyrics, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(lyrics, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(lyrics, CURLOPT_WRITEFUNCTION, write_data);
|
curl_easy_setopt(lyrics, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
@@ -210,7 +210,7 @@ void *Lyrics::Get(void *song)
|
|||||||
curl_easy_setopt(lyrics, CURLOPT_NOSIGNAL, 1);
|
curl_easy_setopt(lyrics, CURLOPT_NOSIGNAL, 1);
|
||||||
code = curl_easy_perform(lyrics);
|
code = curl_easy_perform(lyrics);
|
||||||
curl_easy_cleanup(lyrics);
|
curl_easy_cleanup(lyrics);
|
||||||
pthread_mutex_unlock(&curl);
|
pthread_mutex_unlock(&CurlLock);
|
||||||
|
|
||||||
curl_free(c_artist);
|
curl_free(c_artist);
|
||||||
curl_free(c_title);
|
curl_free(c_title);
|
||||||
|
|||||||
@@ -49,18 +49,18 @@ void MediaLibrary::Init()
|
|||||||
itsRightColWidth = COLS-COLS/3*2-1;
|
itsRightColWidth = COLS-COLS/3*2-1;
|
||||||
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
||||||
|
|
||||||
Artists = new Menu<string>(0, main_start_y, itsLeftColWidth, main_height, IntoStr(Config.media_lib_primary_tag) + "s", Config.main_color, brNone);
|
Artists = new Menu<string>(0, MainStartY, itsLeftColWidth, MainHeight, IntoStr(Config.media_lib_primary_tag) + "s", Config.main_color, brNone);
|
||||||
Artists->HighlightColor(Config.active_column_color);
|
Artists->HighlightColor(Config.active_column_color);
|
||||||
Artists->SetTimeout(ncmpcpp_window_timeout);
|
Artists->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Artists->SetItemDisplayer(Display::Generic);
|
Artists->SetItemDisplayer(Display::Generic);
|
||||||
|
|
||||||
Albums = new Menu< std::pair<std::string, SearchConstraints> >(itsMiddleColStartX, main_start_y, itsMiddleColWidth, main_height, "Albums", Config.main_color, brNone);
|
Albums = new Menu< std::pair<std::string, SearchConstraints> >(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, "Albums", Config.main_color, brNone);
|
||||||
Albums->HighlightColor(Config.main_highlight_color);
|
Albums->HighlightColor(Config.main_highlight_color);
|
||||||
Albums->SetTimeout(ncmpcpp_window_timeout);
|
Albums->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Albums->SetItemDisplayer(Display::Pairs);
|
Albums->SetItemDisplayer(Display::Pairs);
|
||||||
Albums->SetGetStringFunction(StringPairToString);
|
Albums->SetGetStringFunction(StringPairToString);
|
||||||
|
|
||||||
Songs = new Menu<Song>(itsRightColStartX, main_start_y, itsRightColWidth, main_height, "Songs", Config.main_color, brNone);
|
Songs = new Menu<Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, "Songs", Config.main_color, brNone);
|
||||||
Songs->HighlightColor(Config.main_highlight_color);
|
Songs->HighlightColor(Config.main_highlight_color);
|
||||||
Songs->SetTimeout(ncmpcpp_window_timeout);
|
Songs->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Songs->SetSelectPrefix(&Config.selected_item_prefix);
|
Songs->SetSelectPrefix(&Config.selected_item_prefix);
|
||||||
@@ -80,12 +80,12 @@ void MediaLibrary::Resize()
|
|||||||
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
||||||
itsRightColWidth = COLS-COLS/3*2-1;
|
itsRightColWidth = COLS-COLS/3*2-1;
|
||||||
|
|
||||||
Artists->Resize(itsLeftColWidth, main_height);
|
Artists->Resize(itsLeftColWidth, MainHeight);
|
||||||
Albums->Resize(itsMiddleColWidth, main_height);
|
Albums->Resize(itsMiddleColWidth, MainHeight);
|
||||||
Songs->Resize(itsRightColWidth, main_height);
|
Songs->Resize(itsRightColWidth, MainHeight);
|
||||||
|
|
||||||
Albums->MoveTo(itsMiddleColStartX, main_start_y);
|
Albums->MoveTo(itsMiddleColStartX, MainStartY);
|
||||||
Songs->MoveTo(itsRightColStartX, main_start_y);
|
Songs->MoveTo(itsRightColStartX, MainStartY);
|
||||||
|
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
@@ -93,9 +93,9 @@ void MediaLibrary::Resize()
|
|||||||
void MediaLibrary::Refresh()
|
void MediaLibrary::Refresh()
|
||||||
{
|
{
|
||||||
Artists->Display();
|
Artists->Display();
|
||||||
mvvline(main_start_y, itsMiddleColStartX-1, 0, main_height);
|
mvvline(MainStartY, itsMiddleColStartX-1, 0, MainHeight);
|
||||||
Albums->Display();
|
Albums->Display();
|
||||||
mvvline(main_start_y, itsRightColStartX-1, 0, main_height);
|
mvvline(MainStartY, itsRightColStartX-1, 0, MainHeight);
|
||||||
Songs->Display();
|
Songs->Display();
|
||||||
if (Albums->Empty())
|
if (Albums->Empty())
|
||||||
{
|
{
|
||||||
@@ -113,7 +113,7 @@ void MediaLibrary::SwitchTo()
|
|||||||
Resize();
|
Resize();
|
||||||
|
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
Refresh();
|
Refresh();
|
||||||
UpdateSongList(Songs);
|
UpdateSongList(Songs);
|
||||||
}
|
}
|
||||||
@@ -369,7 +369,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
|||||||
{
|
{
|
||||||
if (!Songs->Empty())
|
if (!Songs->Empty())
|
||||||
{
|
{
|
||||||
block_item_list_update = 1;
|
BlockItemListUpdate = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && Songs->isBold())
|
if (Config.ncmpc_like_songs_adding && Songs->isBold())
|
||||||
{
|
{
|
||||||
long long hash = Songs->Current().GetHash();
|
long long hash = Songs->Current().GetHash();
|
||||||
|
|||||||
@@ -56,7 +56,6 @@
|
|||||||
using namespace Global;
|
using namespace Global;
|
||||||
using namespace MPD;
|
using namespace MPD;
|
||||||
|
|
||||||
using std::make_pair;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
@@ -68,16 +67,15 @@ Window *Global::wFooter;
|
|||||||
|
|
||||||
Connection *Global::Mpd;
|
Connection *Global::Mpd;
|
||||||
|
|
||||||
size_t Global::main_start_y;
|
size_t Global::MainStartY;
|
||||||
size_t Global::main_height;
|
size_t Global::MainHeight;
|
||||||
|
|
||||||
time_t Global::timer;
|
time_t Global::Timer;
|
||||||
|
|
||||||
bool Global::block_progressbar_update = 0;
|
bool Global::BlockItemListUpdate = 0;
|
||||||
bool Global::block_item_list_update = 0;
|
|
||||||
|
|
||||||
bool Global::messages_allowed = 0;
|
bool Global::MessagesAllowed = 0;
|
||||||
bool Global::redraw_header = 1;
|
bool Global::RedrawHeader = 1;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -117,16 +115,16 @@ int main(int argc, char *argv[])
|
|||||||
InitScreen(Config.colors_enabled);
|
InitScreen(Config.colors_enabled);
|
||||||
init_current_locale();
|
init_current_locale();
|
||||||
|
|
||||||
main_start_y = 2;
|
MainStartY = 2;
|
||||||
main_height = LINES-4;
|
MainHeight = LINES-4;
|
||||||
|
|
||||||
if (!Config.header_visibility)
|
if (!Config.header_visibility)
|
||||||
{
|
{
|
||||||
main_start_y -= 2;
|
MainStartY -= 2;
|
||||||
main_height += 2;
|
MainHeight += 2;
|
||||||
}
|
}
|
||||||
if (!Config.statusbar_visibility)
|
if (!Config.statusbar_visibility)
|
||||||
main_height++;
|
MainHeight++;
|
||||||
|
|
||||||
myPlaylist->Init();
|
myPlaylist->Init();
|
||||||
myBrowser->Init();
|
myBrowser->Init();
|
||||||
@@ -163,7 +161,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
myScreen = myPlaylist;
|
myScreen = myPlaylist;
|
||||||
|
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
|
|
||||||
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
|
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
|
||||||
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
|
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
|
||||||
@@ -191,14 +189,14 @@ int main(int argc, char *argv[])
|
|||||||
ShowMessage("Attempting to reconnect...");
|
ShowMessage("Attempting to reconnect...");
|
||||||
if (Mpd->Connect())
|
if (Mpd->Connect())
|
||||||
ShowMessage("Connected!");
|
ShowMessage("Connected!");
|
||||||
messages_allowed = 0;
|
MessagesAllowed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
|
|
||||||
block_item_list_update = 0;
|
BlockItemListUpdate = 0;
|
||||||
Playlist::BlockUpdate = 0;
|
Playlist::BlockUpdate = 0;
|
||||||
messages_allowed = 1;
|
MessagesAllowed = 1;
|
||||||
|
|
||||||
// header stuff
|
// header stuff
|
||||||
gettimeofday(&past, 0);
|
gettimeofday(&past, 0);
|
||||||
@@ -206,10 +204,10 @@ int main(int argc, char *argv[])
|
|||||||
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
|
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
gettimeofday(&now, 0);
|
gettimeofday(&now, 0);
|
||||||
}
|
}
|
||||||
if (Config.header_visibility && redraw_header)
|
if (Config.header_visibility && RedrawHeader)
|
||||||
{
|
{
|
||||||
if (title_allowed)
|
if (title_allowed)
|
||||||
{
|
{
|
||||||
@@ -233,10 +231,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
wHeader->SetColor(Config.volume_color);
|
wHeader->SetColor(Config.volume_color);
|
||||||
*wHeader << XY(wHeader->GetWidth()-volume_state.length(), 0) << volume_state;
|
*wHeader << XY(wHeader->GetWidth()-VolumeState.length(), 0) << VolumeState;
|
||||||
wHeader->SetColor(Config.header_color);
|
wHeader->SetColor(Config.header_color);
|
||||||
wHeader->Refresh();
|
wHeader->Refresh();
|
||||||
redraw_header = 0;
|
RedrawHeader = 0;
|
||||||
}
|
}
|
||||||
// header stuff end
|
// header stuff end
|
||||||
|
|
||||||
@@ -248,9 +246,9 @@ int main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!title_allowed)
|
if (!title_allowed)
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
title_allowed = 1;
|
title_allowed = 1;
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
|
|
||||||
if (myScreen == myPlaylist)
|
if (myScreen == myPlaylist)
|
||||||
{
|
{
|
||||||
@@ -327,7 +325,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (input == KEY_RESIZE)
|
else if (input == KEY_RESIZE)
|
||||||
{
|
{
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
|
|
||||||
if (COLS < 20 || LINES < 5)
|
if (COLS < 20 || LINES < 5)
|
||||||
{
|
{
|
||||||
@@ -336,12 +334,12 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_height = LINES-4;
|
MainHeight = LINES-4;
|
||||||
|
|
||||||
if (!Config.header_visibility)
|
if (!Config.header_visibility)
|
||||||
main_height += 2;
|
MainHeight += 2;
|
||||||
if (!Config.statusbar_visibility)
|
if (!Config.statusbar_visibility)
|
||||||
main_height++;
|
MainHeight++;
|
||||||
|
|
||||||
myHelp->hasToBeResized = 1;
|
myHelp->hasToBeResized = 1;
|
||||||
myPlaylist->hasToBeResized = 1;
|
myPlaylist->hasToBeResized = 1;
|
||||||
@@ -460,7 +458,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
size_t id = myPlaylist->Main()->Choice();
|
size_t id = myPlaylist->Main()->Choice();
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
if (myPlaylist->NowPlaying > myPlaylist->CurrentSong()->GetPosition()) // needed for keeping proper
|
if (myPlaylist->NowPlaying > myPlaylist->CurrentSong()->GetPosition()) // needed for keeping proper
|
||||||
myPlaylist->NowPlaying--; // position of now playing song.
|
myPlaylist->NowPlaying--; // position of now playing song.
|
||||||
Mpd->QueueDeleteSongId(myPlaylist->CurrentSong()->GetID());
|
Mpd->QueueDeleteSongId(myPlaylist->CurrentSong()->GetID());
|
||||||
@@ -525,7 +523,7 @@ int main(int argc, char *argv[])
|
|||||||
while (!myPlaylistEditor->Content->Empty() && Keypressed(input, Key.Delete))
|
while (!myPlaylistEditor->Content->Empty() && Keypressed(input, Key.Delete))
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
Mpd->QueueDeleteFromPlaylist(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice());
|
Mpd->QueueDeleteFromPlaylist(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice());
|
||||||
myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice());
|
myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice());
|
||||||
myPlaylistEditor->Content->Refresh();
|
myPlaylistEditor->Content->Refresh();
|
||||||
@@ -575,13 +573,13 @@ int main(int argc, char *argv[])
|
|||||||
Statusbar() << "Playlist already exists, overwrite: " << playlist_name << " ? [y/n] ";
|
Statusbar() << "Playlist already exists, overwrite: " << playlist_name << " ? [y/n] ";
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
int in = 0;
|
int in = 0;
|
||||||
messages_allowed = 0;
|
MessagesAllowed = 0;
|
||||||
while (in != 'y' && in != 'n')
|
while (in != 'y' && in != 'n')
|
||||||
{
|
{
|
||||||
Mpd->UpdateStatus();
|
Mpd->UpdateStatus();
|
||||||
wFooter->ReadKey(in);
|
wFooter->ReadKey(in);
|
||||||
}
|
}
|
||||||
messages_allowed = 1;
|
MessagesAllowed = 1;
|
||||||
|
|
||||||
if (in == 'y')
|
if (in == 'y')
|
||||||
{
|
{
|
||||||
@@ -629,7 +627,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
|
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
(*it)--;
|
(*it)--;
|
||||||
@@ -655,7 +653,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongUp) && to > 0)
|
while (Keypressed(input, Key.MvSongUp) && to > 0)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
to--;
|
to--;
|
||||||
myPlaylist->Main()->at(from).SetPosition(to);
|
myPlaylist->Main()->at(from).SetPosition(to);
|
||||||
myPlaylist->Main()->at(to).SetPosition(from);
|
myPlaylist->Main()->at(to).SetPosition(from);
|
||||||
@@ -681,7 +679,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
|
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
(*it)--;
|
(*it)--;
|
||||||
@@ -703,7 +701,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongUp) && to > 0)
|
while (Keypressed(input, Key.MvSongUp) && to > 0)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
to--;
|
to--;
|
||||||
myPlaylistEditor->Content->Swap(to, to+1);
|
myPlaylistEditor->Content->Swap(to, to+1);
|
||||||
myPlaylistEditor->Content->Scroll(wUp);
|
myPlaylistEditor->Content->Scroll(wUp);
|
||||||
@@ -742,7 +740,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylist->Main()->Size()-1)
|
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylist->Main()->Size()-1)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
||||||
{
|
{
|
||||||
(*it)++;
|
(*it)++;
|
||||||
@@ -768,7 +766,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongDown) && to < myPlaylist->Main()->Size()-1)
|
while (Keypressed(input, Key.MvSongDown) && to < myPlaylist->Main()->Size()-1)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
to++;
|
to++;
|
||||||
myPlaylist->Main()->at(from).SetPosition(to);
|
myPlaylist->Main()->at(from).SetPosition(to);
|
||||||
myPlaylist->Main()->at(to).SetPosition(from);
|
myPlaylist->Main()->at(to).SetPosition(from);
|
||||||
@@ -795,7 +793,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylistEditor->Content->Size()-1)
|
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylistEditor->Content->Size()-1)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
|
||||||
{
|
{
|
||||||
(*it)++;
|
(*it)++;
|
||||||
@@ -817,7 +815,7 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.MvSongDown) && to < myPlaylistEditor->Content->Size()-1)
|
while (Keypressed(input, Key.MvSongDown) && to < myPlaylistEditor->Content->Size()-1)
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
to++;
|
to++;
|
||||||
myPlaylistEditor->Content->Swap(to, to-1);
|
myPlaylistEditor->Content->Swap(to, to-1);
|
||||||
myPlaylistEditor->Content->Scroll(wDown);
|
myPlaylistEditor->Content->Scroll(wDown);
|
||||||
@@ -868,7 +866,7 @@ int main(int argc, char *argv[])
|
|||||||
ShowMessage("Unknown item length!");
|
ShowMessage("Unknown item length!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
block_progressbar_update = 1;
|
LockProgressbar();
|
||||||
LockStatusbar();
|
LockStatusbar();
|
||||||
|
|
||||||
int songpos;
|
int songpos;
|
||||||
@@ -879,10 +877,10 @@ int main(int argc, char *argv[])
|
|||||||
while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
|
while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
|
||||||
{
|
{
|
||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
myPlaylist->Main()->ReadKey(input);
|
myPlaylist->Main()->ReadKey(input);
|
||||||
|
|
||||||
int howmuch = Config.incremental_seeking ? (timer-t)/2+Config.seek_time : Config.seek_time;
|
int howmuch = Config.incremental_seeking ? (Timer-t)/2+Config.seek_time : Config.seek_time;
|
||||||
|
|
||||||
if (songpos < s->GetTotalLength() && Keypressed(input, Key.SeekForward))
|
if (songpos < s->GetTotalLength() && Keypressed(input, Key.SeekForward))
|
||||||
{
|
{
|
||||||
@@ -911,7 +909,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
Mpd->Seek(songpos);
|
Mpd->Seek(songpos);
|
||||||
|
|
||||||
block_progressbar_update = 0;
|
UnlockProgressbar();
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.ToggleDisplayMode))
|
else if (Keypressed(input, Key.ToggleDisplayMode))
|
||||||
@@ -1388,7 +1386,7 @@ int main(int argc, char *argv[])
|
|||||||
myBrowser->GetDirectory("/");
|
myBrowser->GetDirectory("/");
|
||||||
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
|
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
|
||||||
}
|
}
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
FreeSongList(result);
|
FreeSongList(result);
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.Crop))
|
else if (Keypressed(input, Key.Crop))
|
||||||
@@ -1450,7 +1448,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
myPlaylist->Sort();
|
myPlaylist->Sort();
|
||||||
myPlaylist->Main()->Highlighting(1);
|
myPlaylist->Main()->Highlighting(1);
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.ApplyFilter))
|
else if (Keypressed(input, Key.ApplyFilter))
|
||||||
{
|
{
|
||||||
@@ -1473,10 +1471,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (myScreen == myPlaylist)
|
if (myScreen == myPlaylist)
|
||||||
{
|
{
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
myPlaylist->Main()->Highlighting(1);
|
myPlaylist->Main()->Highlighting(1);
|
||||||
Playlist::ReloadTotalLength = 1;
|
Playlist::ReloadTotalLength = 1;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward))
|
else if (Keypressed(input, Key.FindForward) || Keypressed(input, Key.FindBackward))
|
||||||
@@ -1490,7 +1488,7 @@ int main(int argc, char *argv[])
|
|||||||
Statusbar() << "Find " << (Keypressed(input, Key.FindForward) ? "forward" : "backward") << ": ";
|
Statusbar() << "Find " << (Keypressed(input, Key.FindForward) ? "forward" : "backward") << ": ";
|
||||||
string findme = wFooter->GetString(mList->GetSearchConstraint());
|
string findme = wFooter->GetString(mList->GetSearchConstraint());
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
time(&timer);
|
time(&Timer);
|
||||||
if (findme.empty())
|
if (findme.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const size_t Playlist::SortDialogHeight = 17;
|
|||||||
|
|
||||||
void Playlist::Init()
|
void Playlist::Init()
|
||||||
{
|
{
|
||||||
w = new Menu<MPD::Song>(0, main_start_y, COLS, main_height, Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "", Config.main_color, brNone);
|
w = new Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "", Config.main_color, brNone);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
w->HighlightColor(Config.main_highlight_color);
|
w->HighlightColor(Config.main_highlight_color);
|
||||||
w->SetSelectPrefix(&Config.selected_item_prefix);
|
w->SetSelectPrefix(&Config.selected_item_prefix);
|
||||||
@@ -91,12 +91,12 @@ void Playlist::SwitchTo()
|
|||||||
|
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
w->Window::Clear();
|
w->Window::Clear();
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::Resize()
|
void Playlist::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
w->SetTitle(Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "");
|
w->SetTitle(Config.columns_in_playlist ? Display::Columns(Config.song_columns_list_format) : "");
|
||||||
SortDialog->MoveTo((COLS-SortDialogWidth)/2, (LINES-SortDialogHeight)/2);
|
SortDialog->MoveTo((COLS-SortDialogWidth)/2, (LINES-SortDialogHeight)/2);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
@@ -107,7 +107,7 @@ std::string Playlist::Title()
|
|||||||
std::string result = "Playlist ";
|
std::string result = "Playlist ";
|
||||||
if (ReloadTotalLength || ReloadRemaining)
|
if (ReloadTotalLength || ReloadRemaining)
|
||||||
itsBufferedStats = TotalLength();
|
itsBufferedStats = TotalLength();
|
||||||
result += TO_STRING(Scroller(itsBufferedStats, w->GetWidth()-result.length()-volume_state.length(), itsScrollBegin));
|
result += TO_STRING(Scroller(itsBufferedStats, w->GetWidth()-result.length()-VolumeState.length(), itsScrollBegin));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ void PlaylistEditor::Init()
|
|||||||
RightColumnStartX = LeftColumnWidth+1;
|
RightColumnStartX = LeftColumnWidth+1;
|
||||||
RightColumnWidth = COLS-LeftColumnWidth-1;
|
RightColumnWidth = COLS-LeftColumnWidth-1;
|
||||||
|
|
||||||
Playlists = new Menu<string>(0, main_start_y, LeftColumnWidth, main_height, "Playlists", Config.main_color, brNone);
|
Playlists = new Menu<string>(0, MainStartY, LeftColumnWidth, MainHeight, "Playlists", Config.main_color, brNone);
|
||||||
Playlists->HighlightColor(Config.active_column_color);
|
Playlists->HighlightColor(Config.active_column_color);
|
||||||
Playlists->SetTimeout(ncmpcpp_window_timeout);
|
Playlists->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Playlists->SetItemDisplayer(Display::Generic);
|
Playlists->SetItemDisplayer(Display::Generic);
|
||||||
|
|
||||||
Content = new Menu<Song>(RightColumnStartX, main_start_y, RightColumnWidth, main_height, "Playlist's content", Config.main_color, brNone);
|
Content = new Menu<Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, "Playlist's content", Config.main_color, brNone);
|
||||||
Content->HighlightColor(Config.main_highlight_color);
|
Content->HighlightColor(Config.main_highlight_color);
|
||||||
Content->SetTimeout(ncmpcpp_window_timeout);
|
Content->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Content->SetSelectPrefix(&Config.selected_item_prefix);
|
Content->SetSelectPrefix(&Config.selected_item_prefix);
|
||||||
@@ -70,10 +70,10 @@ void PlaylistEditor::Resize()
|
|||||||
RightColumnStartX = LeftColumnWidth+1;
|
RightColumnStartX = LeftColumnWidth+1;
|
||||||
RightColumnWidth = COLS-LeftColumnWidth-1;
|
RightColumnWidth = COLS-LeftColumnWidth-1;
|
||||||
|
|
||||||
Playlists->Resize(LeftColumnWidth, main_height);
|
Playlists->Resize(LeftColumnWidth, MainHeight);
|
||||||
Content->Resize(RightColumnWidth, main_height);
|
Content->Resize(RightColumnWidth, MainHeight);
|
||||||
|
|
||||||
Content->MoveTo(RightColumnStartX, main_start_y);
|
Content->MoveTo(RightColumnStartX, MainStartY);
|
||||||
|
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ std::string PlaylistEditor::Title()
|
|||||||
void PlaylistEditor::Refresh()
|
void PlaylistEditor::Refresh()
|
||||||
{
|
{
|
||||||
Playlists->Display();
|
Playlists->Display();
|
||||||
mvvline(main_start_y, RightColumnStartX-1, 0, main_height);
|
mvvline(MainStartY, RightColumnStartX-1, 0, MainHeight);
|
||||||
Content->Display();
|
Content->Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ void PlaylistEditor::SwitchTo()
|
|||||||
Resize();
|
Resize();
|
||||||
|
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
Refresh();
|
Refresh();
|
||||||
UpdateSongList(Content);
|
UpdateSongList(Content);
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
|||||||
{
|
{
|
||||||
if (!Content->Empty())
|
if (!Content->Empty())
|
||||||
{
|
{
|
||||||
block_item_list_update = 1;
|
BlockItemListUpdate = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && Content->isBold())
|
if (Config.ncmpc_like_songs_adding && Content->isBold())
|
||||||
{
|
{
|
||||||
long long hash = Content->Current().GetHash();
|
long long hash = Content->Current().GetHash();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ bool SearchEngine::CaseSensitive = 0;
|
|||||||
|
|
||||||
void SearchEngine::Init()
|
void SearchEngine::Init()
|
||||||
{
|
{
|
||||||
w = new Menu< std::pair<Buffer *, Song *> >(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Menu< std::pair<Buffer *, Song *> >(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||||
w->HighlightColor(Config.main_highlight_color);
|
w->HighlightColor(Config.main_highlight_color);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
w->SetItemDisplayer(Display::SearchEngine);
|
w->SetItemDisplayer(Display::SearchEngine);
|
||||||
@@ -55,7 +55,7 @@ void SearchEngine::Init()
|
|||||||
|
|
||||||
void SearchEngine::Resize()
|
void SearchEngine::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ void SearchEngine::SwitchTo()
|
|||||||
if (w->Empty())
|
if (w->Empty())
|
||||||
Prepare();
|
Prepare();
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
|
|
||||||
if (!w->Back().first)
|
if (!w->Back().first)
|
||||||
{
|
{
|
||||||
@@ -221,7 +221,7 @@ void SearchEngine::EnterPressed()
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
block_item_list_update = 1;
|
BlockItemListUpdate = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||||
{
|
{
|
||||||
long long hash = w->Current().second->GetHash();
|
long long hash = w->Current().second->GetHash();
|
||||||
@@ -263,7 +263,7 @@ void SearchEngine::SpacePressed()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
block_item_list_update = 1;
|
BlockItemListUpdate = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && w->isBold())
|
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||||
{
|
{
|
||||||
Playlist::BlockUpdate = 1;
|
Playlist::BlockUpdate = 1;
|
||||||
|
|||||||
@@ -38,24 +38,21 @@ using namespace Global;
|
|||||||
using namespace MPD;
|
using namespace MPD;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
string Global::volume_state;
|
string Global::VolumeState;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
time_t time_of_statusbar_lock;
|
time_t time_of_statusbar_lock;
|
||||||
|
|
||||||
int lock_statusbar_delay = -1;
|
int lock_statusbar_delay = -1;
|
||||||
|
|
||||||
string switch_state;
|
|
||||||
|
|
||||||
bool block_statusbar_update = 0;
|
bool block_statusbar_update = 0;
|
||||||
|
bool block_progressbar_update = 0;
|
||||||
bool allow_statusbar_unlock = 1;
|
bool allow_statusbar_unlock = 1;
|
||||||
bool repeat_one_allowed = 0;
|
|
||||||
|
|
||||||
const string term_type = getenv("TERM") ? getenv("TERM") : "";
|
|
||||||
|
|
||||||
void WindowTitle(const string &status)
|
void WindowTitle(const string &status)
|
||||||
{
|
{
|
||||||
|
static const string term_type = getenv("TERM") ? getenv("TERM") : "";
|
||||||
|
|
||||||
if (term_type != "linux" && Config.set_window_title)
|
if (term_type != "linux" && Config.set_window_title)
|
||||||
std::cout << "\033]0;" << status << "\7";
|
std::cout << "\033]0;" << status << "\7";
|
||||||
}
|
}
|
||||||
@@ -73,6 +70,16 @@ void StatusbarApplyFilterImmediately(const std::wstring &ws)
|
|||||||
TraceMpdStatus();
|
TraceMpdStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LockProgressbar()
|
||||||
|
{
|
||||||
|
block_progressbar_update = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnlockProgressbar()
|
||||||
|
{
|
||||||
|
block_progressbar_update = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void LockStatusbar()
|
void LockStatusbar()
|
||||||
{
|
{
|
||||||
if (Config.statusbar_visibility)
|
if (Config.statusbar_visibility)
|
||||||
@@ -100,7 +107,7 @@ void TraceMpdStatus()
|
|||||||
Mpd->UpdateStatus();
|
Mpd->UpdateStatus();
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
if (myScreen == myPlaylist && now == timer+Config.playlist_disable_highlight_delay)
|
if (myScreen == myPlaylist && now == Timer+Config.playlist_disable_highlight_delay)
|
||||||
myPlaylist->Main()->Highlighting(!Config.playlist_disable_highlight_delay);
|
myPlaylist->Main()->Highlighting(!Config.playlist_disable_highlight_delay);
|
||||||
|
|
||||||
if (lock_statusbar_delay > 0)
|
if (lock_statusbar_delay > 0)
|
||||||
@@ -151,6 +158,7 @@ void NcmpcppErrorCallback(Connection *Mpd, int errorid, const char *msg, void *)
|
|||||||
void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||||
{
|
{
|
||||||
static size_t playing_song_scroll_begin = 0;
|
static size_t playing_song_scroll_begin = 0;
|
||||||
|
static bool repeat_one_allowed = 0;
|
||||||
static string player_state;
|
static string player_state;
|
||||||
|
|
||||||
int sx, sy;
|
int sx, sy;
|
||||||
@@ -235,7 +243,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
Playlist::ReloadRemaining = 1;
|
Playlist::ReloadRemaining = 1;
|
||||||
|
|
||||||
if (myScreen == myPlaylist)
|
if (myScreen == myPlaylist)
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
|
|
||||||
if (myPlaylist->Main()->Empty())
|
if (myPlaylist->Main()->Empty())
|
||||||
{
|
{
|
||||||
@@ -243,7 +251,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
ShowMessage("Cleared playlist!");
|
ShowMessage("Cleared playlist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!block_item_list_update)
|
if (!BlockItemListUpdate)
|
||||||
{
|
{
|
||||||
if (myScreen == myBrowser)
|
if (myScreen == myBrowser)
|
||||||
{
|
{
|
||||||
@@ -448,6 +456,8 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
}
|
}
|
||||||
if (changed.StatusFlags && Config.header_visibility)
|
if (changed.StatusFlags && Config.header_visibility)
|
||||||
{
|
{
|
||||||
|
static string switch_state;
|
||||||
|
|
||||||
switch_state.clear();
|
switch_state.clear();
|
||||||
if (mpd_repeat)
|
if (mpd_repeat)
|
||||||
switch_state += mpd_repeat;
|
switch_state += mpd_repeat;
|
||||||
@@ -476,11 +486,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
}
|
}
|
||||||
if (changed.Volume && Config.header_visibility)
|
if (changed.Volume && Config.header_visibility)
|
||||||
{
|
{
|
||||||
volume_state = " Volume: ";
|
VolumeState = " Volume: ";
|
||||||
volume_state += IntoStr(Mpd->GetVolume());
|
VolumeState += IntoStr(Mpd->GetVolume());
|
||||||
volume_state += "%";
|
VolumeState += "%";
|
||||||
wHeader->SetColor(Config.volume_color);
|
wHeader->SetColor(Config.volume_color);
|
||||||
*wHeader << XY(wHeader->GetWidth()-volume_state.length(), 0) << volume_state;
|
*wHeader << XY(wHeader->GetWidth()-VolumeState.length(), 0) << VolumeState;
|
||||||
wHeader->SetColor(Config.header_color);
|
wHeader->SetColor(Config.header_color);
|
||||||
wHeader->Refresh();
|
wHeader->Refresh();
|
||||||
}
|
}
|
||||||
@@ -499,7 +509,7 @@ Window &Statusbar()
|
|||||||
|
|
||||||
void ShowMessage(const char *format, ...)
|
void ShowMessage(const char *format, ...)
|
||||||
{
|
{
|
||||||
if (messages_allowed)
|
if (MessagesAllowed)
|
||||||
{
|
{
|
||||||
time(&time_of_statusbar_lock);
|
time(&time_of_statusbar_lock);
|
||||||
lock_statusbar_delay = Config.message_delay_time;
|
lock_statusbar_delay = Config.message_delay_time;
|
||||||
@@ -519,4 +529,3 @@ void ShowMessage(const char *format, ...)
|
|||||||
wFooter->Refresh();
|
wFooter->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
|
|
||||||
|
void LockProgressbar();
|
||||||
|
void UnlockProgressbar();
|
||||||
|
|
||||||
void LockStatusbar();
|
void LockStatusbar();
|
||||||
void UnlockStatusbar();
|
void UnlockStatusbar();
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ TinyTagEditor *myTinyTagEditor = new TinyTagEditor;
|
|||||||
|
|
||||||
void TinyTagEditor::Init()
|
void TinyTagEditor::Init()
|
||||||
{
|
{
|
||||||
w = new Menu<Buffer>(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Menu<Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||||
w->HighlightColor(Config.main_highlight_color);
|
w->HighlightColor(Config.main_highlight_color);
|
||||||
w->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
w->SetItemDisplayer(Display::Generic);
|
w->SetItemDisplayer(Display::Generic);
|
||||||
@@ -55,7 +55,7 @@ void TinyTagEditor::Init()
|
|||||||
|
|
||||||
void TinyTagEditor::Resize()
|
void TinyTagEditor::Resize()
|
||||||
{
|
{
|
||||||
w->Resize(COLS, main_height);
|
w->Resize(COLS, MainHeight);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ void TinyTagEditor::SwitchTo()
|
|||||||
Resize();
|
Resize();
|
||||||
myOldScreen = myScreen;
|
myOldScreen = myScreen;
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -303,13 +303,13 @@ void TagEditor::Init()
|
|||||||
RightColumnWidth = COLS-LeftColumnWidth-MiddleColumnWidth-2;
|
RightColumnWidth = COLS-LeftColumnWidth-MiddleColumnWidth-2;
|
||||||
RightColumnStartX = LeftColumnWidth+MiddleColumnWidth+2;
|
RightColumnStartX = LeftColumnWidth+MiddleColumnWidth+2;
|
||||||
|
|
||||||
Albums = new Menu<string_pair>(0, main_start_y, LeftColumnWidth, main_height, "Albums", Config.main_color, brNone);
|
Albums = new Menu<string_pair>(0, MainStartY, LeftColumnWidth, MainHeight, "Albums", Config.main_color, brNone);
|
||||||
Albums->HighlightColor(Config.active_column_color);
|
Albums->HighlightColor(Config.active_column_color);
|
||||||
Albums->SetTimeout(ncmpcpp_window_timeout);
|
Albums->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Albums->SetItemDisplayer(Display::Pairs);
|
Albums->SetItemDisplayer(Display::Pairs);
|
||||||
Albums->SetGetStringFunction(StringPairToString);
|
Albums->SetGetStringFunction(StringPairToString);
|
||||||
|
|
||||||
Dirs = new Menu<string_pair>(0, main_start_y, LeftColumnWidth, main_height, "Directories", Config.main_color, brNone);
|
Dirs = new Menu<string_pair>(0, MainStartY, LeftColumnWidth, MainHeight, "Directories", Config.main_color, brNone);
|
||||||
Dirs->HighlightColor(Config.active_column_color);
|
Dirs->HighlightColor(Config.active_column_color);
|
||||||
Dirs->SetTimeout(ncmpcpp_window_timeout);
|
Dirs->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Dirs->SetItemDisplayer(Display::Pairs);
|
Dirs->SetItemDisplayer(Display::Pairs);
|
||||||
@@ -317,12 +317,12 @@ void TagEditor::Init()
|
|||||||
|
|
||||||
LeftColumn = Config.albums_in_tag_editor ? Albums : Dirs;
|
LeftColumn = Config.albums_in_tag_editor ? Albums : Dirs;
|
||||||
|
|
||||||
TagTypes = new Menu<string>(MiddleColumnStartX, main_start_y, MiddleColumnWidth, main_height, "Tag types", Config.main_color, brNone);
|
TagTypes = new Menu<string>(MiddleColumnStartX, MainStartY, MiddleColumnWidth, MainHeight, "Tag types", Config.main_color, brNone);
|
||||||
TagTypes->HighlightColor(Config.main_highlight_color);
|
TagTypes->HighlightColor(Config.main_highlight_color);
|
||||||
TagTypes->SetTimeout(ncmpcpp_window_timeout);
|
TagTypes->SetTimeout(ncmpcpp_window_timeout);
|
||||||
TagTypes->SetItemDisplayer(Display::Generic);
|
TagTypes->SetItemDisplayer(Display::Generic);
|
||||||
|
|
||||||
Tags = new Menu<Song>(RightColumnStartX, main_start_y, RightColumnWidth, main_height, "Tags", Config.main_color, brNone);
|
Tags = new Menu<Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, "Tags", Config.main_color, brNone);
|
||||||
Tags->HighlightColor(Config.main_highlight_color);
|
Tags->HighlightColor(Config.main_highlight_color);
|
||||||
Tags->SetTimeout(ncmpcpp_window_timeout);
|
Tags->SetTimeout(ncmpcpp_window_timeout);
|
||||||
Tags->SetSelectPrefix(&Config.selected_item_prefix);
|
Tags->SetSelectPrefix(&Config.selected_item_prefix);
|
||||||
@@ -342,13 +342,13 @@ void TagEditor::Resize()
|
|||||||
RightColumnWidth = COLS-LeftColumnWidth-MiddleColumnWidth-2;
|
RightColumnWidth = COLS-LeftColumnWidth-MiddleColumnWidth-2;
|
||||||
RightColumnStartX = LeftColumnWidth+MiddleColumnWidth+2;
|
RightColumnStartX = LeftColumnWidth+MiddleColumnWidth+2;
|
||||||
|
|
||||||
Albums->Resize(LeftColumnWidth, main_height);
|
Albums->Resize(LeftColumnWidth, MainHeight);
|
||||||
Dirs->Resize(LeftColumnWidth, main_height);
|
Dirs->Resize(LeftColumnWidth, MainHeight);
|
||||||
TagTypes->Resize(MiddleColumnWidth, main_height);
|
TagTypes->Resize(MiddleColumnWidth, MainHeight);
|
||||||
Tags->Resize(RightColumnWidth, main_height);
|
Tags->Resize(RightColumnWidth, MainHeight);
|
||||||
|
|
||||||
TagTypes->MoveTo(MiddleColumnStartX, main_start_y);
|
TagTypes->MoveTo(MiddleColumnStartX, MainStartY);
|
||||||
Tags->MoveTo(RightColumnStartX, main_start_y);
|
Tags->MoveTo(RightColumnStartX, MainStartY);
|
||||||
|
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
@@ -367,7 +367,7 @@ void TagEditor::SwitchTo()
|
|||||||
Resize();
|
Resize();
|
||||||
|
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
redraw_header = 1;
|
RedrawHeader = 1;
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
if (TagTypes->Empty())
|
if (TagTypes->Empty())
|
||||||
@@ -398,9 +398,9 @@ void TagEditor::SwitchTo()
|
|||||||
void TagEditor::Refresh()
|
void TagEditor::Refresh()
|
||||||
{
|
{
|
||||||
LeftColumn->Display();
|
LeftColumn->Display();
|
||||||
mvvline(main_start_y, MiddleColumnStartX-1, 0, main_height);
|
mvvline(MainStartY, MiddleColumnStartX-1, 0, MainHeight);
|
||||||
TagTypes->Display();
|
TagTypes->Display();
|
||||||
mvvline(main_start_y, RightColumnStartX-1, 0, main_height);
|
mvvline(MainStartY, RightColumnStartX-1, 0, MainHeight);
|
||||||
Tags->Display();
|
Tags->Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user