summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2009-03-08 01:58:49 +0100
committerAndrzej Rybczak <electricityispower@gmail.com>2009-03-08 01:58:49 +0100
commiteed4fb03ff8d147920779f72fa1808b224adf31e (patch)
tree4576cf8993da792a8b8b114fba17c7af2c039ac4 /src
parentb21ede24f4a404c58d21b07570dbfe643e761187 (diff)
use CamelCase for variables in Global namespace / some cleaning
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp16
-rw-r--r--src/clock.cpp8
-rw-r--r--src/global.h19
-rw-r--r--src/help.cpp6
-rw-r--r--src/info.cpp12
-rw-r--r--src/lyrics.cpp16
-rw-r--r--src/media_library.cpp24
-rw-r--r--src/ncmpcpp.cpp94
-rw-r--r--src/playlist.cpp8
-rw-r--r--src/playlist_editor.cpp16
-rw-r--r--src/search_engine.cpp10
-rw-r--r--src/status.cpp41
-rw-r--r--src/status.h3
-rw-r--r--src/tag_editor.cpp32
14 files changed, 156 insertions, 149 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 5555f894..ed74cf4f 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -51,7 +51,7 @@ const char *Browser::SupportedExtensions[] =
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->SetTimeout(ncmpcpp_window_timeout);
w->SetSelectPrefix(&Config.selected_item_prefix);
@@ -62,7 +62,7 @@ void Browser::Init()
void Browser::Resize()
{
- w->Resize(COLS, main_height);
+ w->Resize(COLS, MainHeight);
hasToBeResized = 0;
}
@@ -76,13 +76,13 @@ void Browser::SwitchTo()
w->Empty() ? myBrowser->GetDirectory(itsBrowsedDir) : myBrowser->UpdateItemList();
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
}
std::string Browser::Title()
{
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;
}
@@ -97,12 +97,12 @@ void Browser::EnterPressed()
case itDirectory:
{
GetDirectory(item.name, itsBrowsedDir);
- redraw_header = 1;
+ RedrawHeader = 1;
break;
}
case itSong:
{
- block_item_list_update = 1;
+ BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && w->isBold())
{
bool found = 0;
@@ -193,7 +193,7 @@ void Browser::SpacePressed()
}
case itSong:
{
- block_item_list_update = 1;
+ BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && w->isBold())
{
Playlist::BlockUpdate = 1;
@@ -439,7 +439,7 @@ void Browser::ChangeBrowseMode()
itsBrowsedDir = Config.local_browser ? home_folder : "/";
w->Reset();
GetDirectory(itsBrowsedDir);
- redraw_header = 1;
+ RedrawHeader = 1;
}
void Browser::UpdateItemList()
diff --git a/src/clock.cpp b/src/clock.cpp
index 8cd3118a..137288d3 100644
--- a/src/clock.cpp
+++ b/src/clock.cpp
@@ -57,7 +57,7 @@ void Clock::Init()
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);
if (myScreen == this)
@@ -72,7 +72,7 @@ void Clock::Resize()
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!");
return;
@@ -85,7 +85,7 @@ void Clock::SwitchTo()
myScreen = this;
myPlaylist->Main()->Hide();
- redraw_header = 1;
+ RedrawHeader = 1;
Prepare();
w->Display();
}
@@ -97,7 +97,7 @@ std::string Clock::Title()
void Clock::Update()
{
- if (Width > size_t(COLS) || Height > main_height)
+ if (Width > size_t(COLS) || Height > MainHeight)
myPlaylist->SwitchTo();
time_t rawtime;
diff --git a/src/global.h b/src/global.h
index f83896bf..e54d9e55 100644
--- a/src/global.h
+++ b/src/global.h
@@ -25,8 +25,6 @@
#include "mpdpp.h"
#include "screen.h"
-/// FIXME: this is absolutely shitty, I need to get rid of this.
-
namespace Global
{
extern BasicScreen *myScreen;
@@ -37,22 +35,21 @@ namespace Global
extern MPD::Connection *Mpd;
- extern size_t main_start_y;
- extern size_t main_height;
+ extern size_t MainStartY;
+ extern size_t MainHeight;
- extern time_t timer;
+ extern time_t Timer;
# ifdef HAVE_CURL_CURL_H
- extern pthread_mutex_t curl;
+ extern pthread_mutex_t CurlLock;
# endif
- extern bool block_progressbar_update;
- extern bool block_item_list_update;
+ extern bool BlockItemListUpdate;
- extern bool messages_allowed;
- extern bool redraw_header;
+ extern bool MessagesAllowed;
+ extern bool RedrawHeader;
- extern std::string volume_state;
+ extern std::string VolumeState;
}
#endif
diff --git a/src/help.cpp b/src/help.cpp
index ccfc9d31..5560da6f 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -31,7 +31,7 @@ Help *myHelp = new Help;
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);
GetKeybindings();
w->Flush();
@@ -39,7 +39,7 @@ void Help::Init()
void Help::Resize()
{
- w->Resize(COLS, main_height);
+ w->Resize(COLS, MainHeight);
hasToBeResized = 0;
}
@@ -52,7 +52,7 @@ void Help::SwitchTo()
Resize();
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
}
diff --git a/src/info.cpp b/src/info.cpp
index 0c5a5f54..6255d349 100644
--- a/src/info.cpp
+++ b/src/info.cpp
@@ -52,13 +52,13 @@ Info *myInfo = new Info;
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);
}
void Info::Resize()
{
- w->Resize(COLS, main_height);
+ w->Resize(COLS, MainHeight);
hasToBeResized = 0;
}
@@ -98,7 +98,7 @@ void Info::GetSong()
myOldScreen = myScreen;
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
itsTitle = "Song info";
w->Clear();
PrepareSong(*s);
@@ -139,7 +139,7 @@ void Info::GetArtist()
Resize();
myOldScreen = myScreen;
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
itsTitle = "Artist's info - " + *artist;
w->Clear();
static_cast<Window &>(*w) << "Fetching artist's info...";
@@ -198,7 +198,7 @@ void *Info::PrepareArtist(void *ptr)
url += c_artist;
url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79";
- pthread_mutex_lock(&curl);
+ pthread_mutex_lock(&CurlLock);
CURL *info = curl_easy_init();
curl_easy_setopt(info, CURLOPT_URL, url.c_str());
curl_easy_setopt(info, CURLOPT_WRITEFUNCTION, write_data);
@@ -207,7 +207,7 @@ void *Info::PrepareArtist(void *ptr)
curl_easy_setopt(info, CURLOPT_NOSIGNAL, 1);
code = curl_easy_perform(info);
curl_easy_cleanup(info);
- pthread_mutex_unlock(&curl);
+ pthread_mutex_unlock(&CurlLock);
curl_free(c_artist);
diff --git a/src/lyrics.cpp b/src/lyrics.cpp
index bcec557e..9c6f8064 100644
--- a/src/lyrics.cpp
+++ b/src/lyrics.cpp
@@ -49,23 +49,23 @@ bool Lyrics::Reload = 0;
std::string Lyrics::Filename;
#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;
-pthread_t Lyrics::Downloader = 0;
#endif
Lyrics *myLyrics = new Lyrics;
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);
}
void Lyrics::Resize()
{
- w->Resize(COLS, main_height);
+ w->Resize(COLS, MainHeight);
hasToBeResized = 0;
}
@@ -124,7 +124,7 @@ void Lyrics::SwitchTo()
myOldScreen = myScreen;
myScreen = this;
}
- redraw_header = 1;
+ RedrawHeader = 1;
w->Clear();
# ifdef HAVE_CURL_CURL_H
static_cast<Window &>(*w) << "Fetching lyrics...";
@@ -144,7 +144,7 @@ void Lyrics::SwitchTo()
std::string Lyrics::Title()
{
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;
}
@@ -201,7 +201,7 @@ void *Lyrics::Get(void *song)
url.replace(url.find("%artist%"), 8, c_artist);
url.replace(url.find("%title%"), 7, c_title);
- pthread_mutex_lock(&curl);
+ pthread_mutex_lock(&CurlLock);
CURL *lyrics = curl_easy_init();
curl_easy_setopt(lyrics, CURLOPT_URL, url.c_str());
curl_easy_setopt(lyrics, CURLOPT_WRITEFUNCTION, write_data);
@@ -210,7 +210,7 @@ void *Lyrics::Get(void *song)
curl_easy_setopt(lyrics, CURLOPT_NOSIGNAL, 1);
code = curl_easy_perform(lyrics);
curl_easy_cleanup(lyrics);
- pthread_mutex_unlock(&curl);
+ pthread_mutex_unlock(&CurlLock);
curl_free(c_artist);
curl_free(c_title);
diff --git a/src/media_library.cpp b/src/media_library.cpp
index 8cd890d0..9296a81b 100644
--- a/src/media_library.cpp
+++ b/src/media_library.cpp
@@ -49,18 +49,18 @@ void MediaLibrary::Init()
itsRightColWidth = COLS-COLS/3*2-1;
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->SetTimeout(ncmpcpp_window_timeout);
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->SetTimeout(ncmpcpp_window_timeout);
Albums->SetItemDisplayer(Display::Pairs);
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->SetTimeout(ncmpcpp_window_timeout);
Songs->SetSelectPrefix(&Config.selected_item_prefix);
@@ -80,12 +80,12 @@ void MediaLibrary::Resize()
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
itsRightColWidth = COLS-COLS/3*2-1;
- Artists->Resize(itsLeftColWidth, main_height);
- Albums->Resize(itsMiddleColWidth, main_height);
- Songs->Resize(itsRightColWidth, main_height);
+ Artists->Resize(itsLeftColWidth, MainHeight);
+ Albums->Resize(itsMiddleColWidth, MainHeight);
+ Songs->Resize(itsRightColWidth, MainHeight);
- Albums->MoveTo(itsMiddleColStartX, main_start_y);
- Songs->MoveTo(itsRightColStartX, main_start_y);
+ Albums->MoveTo(itsMiddleColStartX, MainStartY);
+ Songs->MoveTo(itsRightColStartX, MainStartY);
hasToBeResized = 0;
}
@@ -93,9 +93,9 @@ void MediaLibrary::Resize()
void MediaLibrary::Refresh()
{
Artists->Display();
- mvvline(main_start_y, itsMiddleColStartX-1, 0, main_height);
+ mvvline(MainStartY, itsMiddleColStartX-1, 0, MainHeight);
Albums->Display();
- mvvline(main_start_y, itsRightColStartX-1, 0, main_height);
+ mvvline(MainStartY, itsRightColStartX-1, 0, MainHeight);
Songs->Display();
if (Albums->Empty())
{
@@ -113,7 +113,7 @@ void MediaLibrary::SwitchTo()
Resize();
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
Refresh();
UpdateSongList(Songs);
}
@@ -369,7 +369,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
{
if (!Songs->Empty())
{
- block_item_list_update = 1;
+ BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && Songs->isBold())
{
long long hash = Songs->Current().GetHash();
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp
index 0733e892..68815df6 100644
--- a/src/ncmpcpp.cpp
+++ b/src/ncmpcpp.cpp
@@ -56,7 +56,6 @@
using namespace Global;
using namespace MPD;
-using std::make_pair;
using std::string;
using std::vector;
@@ -68,16 +67,15 @@ Window *Global::wFooter;
Connection *Global::Mpd;
-size_t Global::main_start_y;
-size_t Global::main_height;
+size_t Global::MainStartY;
+size_t Global::MainHeight;
-time_t Global::timer;
+time_t Global::Timer;
-bool Global::block_progressbar_update = 0;
-bool Global::block_item_list_update = 0;
+bool Global::BlockItemListUpdate = 0;
-bool Global::messages_allowed = 0;
-bool Global::redraw_header = 1;
+bool Global::MessagesAllowed = 0;
+bool Global::RedrawHeader = 1;
int main(int argc, char *argv[])
{
@@ -117,16 +115,16 @@ int main(int argc, char *argv[])
InitScreen(Config.colors_enabled);
init_current_locale();
- main_start_y = 2;
- main_height = LINES-4;
+ MainStartY = 2;
+ MainHeight = LINES-4;
if (!Config.header_visibility)
{
- main_start_y -= 2;
- main_height += 2;
+ MainStartY -= 2;
+ MainHeight += 2;
}
if (!Config.statusbar_visibility)
- main_height++;
+ MainHeight++;
myPlaylist->Init();
myBrowser->Init();
@@ -163,7 +161,7 @@ int main(int argc, char *argv[])
myScreen = myPlaylist;
- time(&timer);
+ time(&Timer);
Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL);
Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL);
@@ -191,14 +189,14 @@ int main(int argc, char *argv[])
ShowMessage("Attempting to reconnect...");
if (Mpd->Connect())
ShowMessage("Connected!");
- messages_allowed = 0;
+ MessagesAllowed = 0;
}
TraceMpdStatus();
- block_item_list_update = 0;
+ BlockItemListUpdate = 0;
Playlist::BlockUpdate = 0;
- messages_allowed = 1;
+ MessagesAllowed = 1;
// header stuff
gettimeofday(&past, 0);
@@ -206,10 +204,10 @@ int main(int argc, char *argv[])
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
)
{
- redraw_header = 1;
+ RedrawHeader = 1;
gettimeofday(&now, 0);
}
- if (Config.header_visibility && redraw_header)
+ if (Config.header_visibility && RedrawHeader)
{
if (title_allowed)
{
@@ -233,10 +231,10 @@ int main(int argc, char *argv[])
}
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->Refresh();
- redraw_header = 0;
+ RedrawHeader = 0;
}
// header stuff end
@@ -248,9 +246,9 @@ int main(int argc, char *argv[])
continue;
if (!title_allowed)
- redraw_header = 1;
+ RedrawHeader = 1;
title_allowed = 1;
- time(&timer);
+ time(&Timer);
if (myScreen == myPlaylist)
{
@@ -327,7 +325,7 @@ int main(int argc, char *argv[])
}
else if (input == KEY_RESIZE)
{
- redraw_header = 1;
+ RedrawHeader = 1;
if (COLS < 20 || LINES < 5)
{
@@ -336,12 +334,12 @@ int main(int argc, char *argv[])
return 1;
}
- main_height = LINES-4;
+ MainHeight = LINES-4;
if (!Config.header_visibility)
- main_height += 2;
+ MainHeight += 2;
if (!Config.statusbar_visibility)
- main_height++;
+ MainHeight++;
myHelp->hasToBeResized = 1;
myPlaylist->hasToBeResized = 1;
@@ -460,7 +458,7 @@ int main(int argc, char *argv[])
{
size_t id = myPlaylist->Main()->Choice();
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
if (myPlaylist->NowPlaying > myPlaylist->CurrentSong()->GetPosition()) // needed for keeping proper
myPlaylist->NowPlaying--; // position of now playing song.
Mpd->QueueDeleteSongId(myPlaylist->CurrentSong()->GetID());
@@ -525,7 +523,7 @@ int main(int argc, char *argv[])
while (!myPlaylistEditor->Content->Empty() && Keypressed(input, Key.Delete))
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
Mpd->QueueDeleteFromPlaylist(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice());
myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice());
myPlaylistEditor->Content->Refresh();
@@ -575,13 +573,13 @@ int main(int argc, char *argv[])
Statusbar() << "Playlist already exists, overwrite: " << playlist_name << " ? [y/n] ";
curs_set(1);
int in = 0;
- messages_allowed = 0;
+ MessagesAllowed = 0;
while (in != 'y' && in != 'n')
{
Mpd->UpdateStatus();
wFooter->ReadKey(in);
}
- messages_allowed = 1;
+ MessagesAllowed = 1;
if (in == 'y')
{
@@ -629,7 +627,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
{
(*it)--;
@@ -655,7 +653,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && to > 0)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
to--;
myPlaylist->Main()->at(from).SetPosition(to);
myPlaylist->Main()->at(to).SetPosition(from);
@@ -681,7 +679,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
for (vector<size_t>::iterator it = list.begin(); it != list.end(); it++)
{
(*it)--;
@@ -703,7 +701,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongUp) && to > 0)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
to--;
myPlaylistEditor->Content->Swap(to, to+1);
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)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
{
(*it)++;
@@ -768,7 +766,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongDown) && to < myPlaylist->Main()->Size()-1)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
to++;
myPlaylist->Main()->at(from).SetPosition(to);
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)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++)
{
(*it)++;
@@ -817,7 +815,7 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.MvSongDown) && to < myPlaylistEditor->Content->Size()-1)
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
to++;
myPlaylistEditor->Content->Swap(to, to-1);
myPlaylistEditor->Content->Scroll(wDown);
@@ -868,7 +866,7 @@ int main(int argc, char *argv[])
ShowMessage("Unknown item length!");
continue;
}
- block_progressbar_update = 1;
+ LockProgressbar();
LockStatusbar();
int songpos;
@@ -879,10 +877,10 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
{
TraceMpdStatus();
- time(&timer);
+ time(&Timer);
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))
{
@@ -911,7 +909,7 @@ int main(int argc, char *argv[])
}
Mpd->Seek(songpos);
- block_progressbar_update = 0;
+ UnlockProgressbar();
UnlockStatusbar();
}
else if (Keypressed(input, Key.ToggleDisplayMode))
@@ -1388,7 +1386,7 @@ int main(int argc, char *argv[])
myBrowser->GetDirectory("/");
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
}
- time(&timer);
+ time(&Timer);
FreeSongList(result);
}
else if (Keypressed(input, Key.Crop))
@@ -1450,7 +1448,7 @@ int main(int argc, char *argv[])
{
myPlaylist->Sort();
myPlaylist->Main()->Highlighting(1);
- time(&timer);
+ time(&Timer);
}
else if (Keypressed(input, Key.ApplyFilter))
{
@@ -1473,10 +1471,10 @@ int main(int argc, char *argv[])
if (myScreen == myPlaylist)
{
- time(&timer);
+ time(&Timer);
myPlaylist->Main()->Highlighting(1);
Playlist::ReloadTotalLength = 1;
- redraw_header = 1;
+ RedrawHeader = 1;
}
}
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") << ": ";
string findme = wFooter->GetString(mList->GetSearchConstraint());
UnlockStatusbar();
- time(&timer);
+ time(&Timer);
if (findme.empty())
continue;
diff --git a/src/playlist.cpp b/src/playlist.cpp
index 9d071677..1135656c 100644
--- a/src/playlist.cpp
+++ b/src/playlist.cpp
@@ -50,7 +50,7 @@ const size_t Playlist::SortDialogHeight = 17;
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->HighlightColor(Config.main_highlight_color);
w->SetSelectPrefix(&Config.selected_item_prefix);
@@ -91,12 +91,12 @@ void Playlist::SwitchTo()
myScreen = this;
w->Window::Clear();
- redraw_header = 1;
+ RedrawHeader = 1;
}
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) : "");
SortDialog->MoveTo((COLS-SortDialogWidth)/2, (LINES-SortDialogHeight)/2);
hasToBeResized = 0;
@@ -107,7 +107,7 @@ std::string Playlist::Title()
std::string result = "Playlist ";
if (ReloadTotalLength || ReloadRemaining)
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;
}
diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp
index d97ebed3..99c5971b 100644
--- a/src/playlist_editor.cpp
+++ b/src/playlist_editor.cpp
@@ -46,12 +46,12 @@ void PlaylistEditor::Init()
RightColumnStartX = 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->SetTimeout(ncmpcpp_window_timeout);
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->SetTimeout(ncmpcpp_window_timeout);
Content->SetSelectPrefix(&Config.selected_item_prefix);
@@ -70,10 +70,10 @@ void PlaylistEditor::Resize()
RightColumnStartX = LeftColumnWidth+1;
RightColumnWidth = COLS-LeftColumnWidth-1;
- Playlists->Resize(LeftColumnWidth, main_height);
- Content->Resize(RightColumnWidth, main_height);
+ Playlists->Resize(LeftColumnWidth, MainHeight);
+ Content->Resize(RightColumnWidth, MainHeight);
- Content->MoveTo(RightColumnStartX, main_start_y);
+ Content->MoveTo(RightColumnStartX, MainStartY);
hasToBeResized = 0;
}
@@ -86,7 +86,7 @@ std::string PlaylistEditor::Title()
void PlaylistEditor::Refresh()
{
Playlists->Display();
- mvvline(main_start_y, RightColumnStartX-1, 0, main_height);
+ mvvline(MainStartY, RightColumnStartX-1, 0, MainHeight);
Content->Display();
}
@@ -99,7 +99,7 @@ void PlaylistEditor::SwitchTo()
Resize();
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
Refresh();
UpdateSongList(Content);
}
@@ -211,7 +211,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
{
if (!Content->Empty())
{
- block_item_list_update = 1;
+ BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && Content->isBold())
{
long long hash = Content->Current().GetHash();
diff --git a/src/search_engine.cpp b/src/search_engine.cpp
index fc0271c7..7f5cf43d 100644
--- a/src/search_engine.cpp
+++ b/src/search_engine.cpp
@@ -44,7 +44,7 @@ bool SearchEngine::CaseSensitive = 0;
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->SetTimeout(ncmpcpp_window_timeout);
w->SetItemDisplayer(Display::SearchEngine);
@@ -55,7 +55,7 @@ void SearchEngine::Init()
void SearchEngine::Resize()
{
- w->Resize(COLS, main_height);
+ w->Resize(COLS, MainHeight);
hasToBeResized = 0;
}
@@ -70,7 +70,7 @@ void SearchEngine::SwitchTo()
if (w->Empty())
Prepare();
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
if (!w->Back().first)
{
@@ -221,7 +221,7 @@ void SearchEngine::EnterPressed()
}
default:
{
- block_item_list_update = 1;
+ BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && w->isBold())
{
long long hash = w->Current().second->GetHash();
@@ -263,7 +263,7 @@ void SearchEngine::SpacePressed()
return;
}
- block_item_list_update = 1;
+ BlockItemListUpdate = 1;
if (Config.ncmpc_like_songs_adding && w->isBold())
{
Playlist::BlockUpdate = 1;
diff --git a/src/status.cpp b/src/status.cpp
index b37f9f7a..c071070a 100644
--- a/src/status.cpp
+++ b/src/status.cpp
@@ -38,24 +38,21 @@ using namespace Global;
using namespace MPD;
using std::string;
-string Global::volume_state;
+string Global::VolumeState;
namespace
{
time_t time_of_statusbar_lock;
-
int lock_statusbar_delay = -1;
- string switch_state;
-
bool block_statusbar_update = 0;
+ bool block_progressbar_update = 0;
bool allow_statusbar_unlock = 1;
- bool repeat_one_allowed = 0;
-
- const string term_type = getenv("TERM") ? getenv("TERM") : "";
void WindowTitle(const string &status)
{
+ static const string term_type = getenv("TERM") ? getenv("TERM") : "";
+
if (term_type != "linux" && Config.set_window_title)
std::cout << "\033]0;" << status << "\7";
}
@@ -73,6 +70,16 @@ void StatusbarApplyFilterImmediately(const std::wstring &ws)
TraceMpdStatus();
}
+void LockProgressbar()
+{
+ block_progressbar_update = 1;
+}
+
+void UnlockProgressbar()
+{
+ block_progressbar_update = 0;
+}
+
void LockStatusbar()
{
if (Config.statusbar_visibility)
@@ -100,7 +107,7 @@ void TraceMpdStatus()
Mpd->UpdateStatus();
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);
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 *)
{
static size_t playing_song_scroll_begin = 0;
+ static bool repeat_one_allowed = 0;
static string player_state;
int sx, sy;
@@ -235,7 +243,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
Playlist::ReloadRemaining = 1;
if (myScreen == myPlaylist)
- redraw_header = 1;
+ RedrawHeader = 1;
if (myPlaylist->Main()->Empty())
{
@@ -243,7 +251,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
ShowMessage("Cleared playlist!");
}
- if (!block_item_list_update)
+ if (!BlockItemListUpdate)
{
if (myScreen == myBrowser)
{
@@ -448,6 +456,8 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
}
if (changed.StatusFlags && Config.header_visibility)
{
+ static string switch_state;
+
switch_state.clear();
if (mpd_repeat)
switch_state += mpd_repeat;
@@ -476,11 +486,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
}
if (changed.Volume && Config.header_visibility)
{
- volume_state = " Volume: ";
- volume_state += IntoStr(Mpd->GetVolume());
- volume_state += "%";
+ VolumeState = " Volume: ";
+ VolumeState += IntoStr(Mpd->GetVolume());
+ VolumeState += "%";
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->Refresh();
}
@@ -499,7 +509,7 @@ Window &Statusbar()
void ShowMessage(const char *format, ...)
{
- if (messages_allowed)
+ if (MessagesAllowed)
{
time(&time_of_statusbar_lock);
lock_statusbar_delay = Config.message_delay_time;
@@ -519,4 +529,3 @@ void ShowMessage(const char *format, ...)
wFooter->Refresh();
}
}
-
diff --git a/src/status.h b/src/status.h
index 3a6db57b..e9d19074 100644
--- a/src/status.h
+++ b/src/status.h
@@ -24,6 +24,9 @@
#include "mpdpp.h"
#include "ncmpcpp.h"
+void LockProgressbar();
+void UnlockProgressbar();
+
void LockStatusbar();
void UnlockStatusbar();
diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp
index 52aec0cd..8fc6ab59 100644
--- a/src/tag_editor.cpp
+++ b/src/tag_editor.cpp
@@ -47,7 +47,7 @@ TinyTagEditor *myTinyTagEditor = new TinyTagEditor;
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->SetTimeout(ncmpcpp_window_timeout);
w->SetItemDisplayer(Display::Generic);
@@ -55,7 +55,7 @@ void TinyTagEditor::Init()
void TinyTagEditor::Resize()
{
- w->Resize(COLS, main_height);
+ w->Resize(COLS, MainHeight);
hasToBeResized = 0;
}
@@ -71,7 +71,7 @@ void TinyTagEditor::SwitchTo()
Resize();
myOldScreen = myScreen;
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
}
else
{
@@ -303,13 +303,13 @@ void TagEditor::Init()
RightColumnWidth = COLS-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->SetTimeout(ncmpcpp_window_timeout);
Albums->SetItemDisplayer(Display::Pairs);
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->SetTimeout(ncmpcpp_window_timeout);
Dirs->SetItemDisplayer(Display::Pairs);
@@ -317,12 +317,12 @@ void TagEditor::Init()
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->SetTimeout(ncmpcpp_window_timeout);
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->SetTimeout(ncmpcpp_window_timeout);
Tags->SetSelectPrefix(&Config.selected_item_prefix);
@@ -342,13 +342,13 @@ void TagEditor::Resize()
RightColumnWidth = COLS-LeftColumnWidth-MiddleColumnWidth-2;
RightColumnStartX = LeftColumnWidth+MiddleColumnWidth+2;
- Albums->Resize(LeftColumnWidth, main_height);
- Dirs->Resize(LeftColumnWidth, main_height);
- TagTypes->Resize(MiddleColumnWidth, main_height);
- Tags->Resize(RightColumnWidth, main_height);
+ Albums->Resize(LeftColumnWidth, MainHeight);
+ Dirs->Resize(LeftColumnWidth, MainHeight);
+ TagTypes->Resize(MiddleColumnWidth, MainHeight);
+ Tags->Resize(RightColumnWidth, MainHeight);
- TagTypes->MoveTo(MiddleColumnStartX, main_start_y);
- Tags->MoveTo(RightColumnStartX, main_start_y);
+ TagTypes->MoveTo(MiddleColumnStartX, MainStartY);
+ Tags->MoveTo(RightColumnStartX, MainStartY);
hasToBeResized = 0;
}
@@ -367,7 +367,7 @@ void TagEditor::SwitchTo()
Resize();
myScreen = this;
- redraw_header = 1;
+ RedrawHeader = 1;
Refresh();
if (TagTypes->Empty())
@@ -398,9 +398,9 @@ void TagEditor::SwitchTo()
void TagEditor::Refresh()
{
LeftColumn->Display();
- mvvline(main_start_y, MiddleColumnStartX-1, 0, main_height);
+ mvvline(MainStartY, MiddleColumnStartX-1, 0, MainHeight);
TagTypes->Display();
- mvvline(main_start_y, RightColumnStartX-1, 0, main_height);
+ mvvline(MainStartY, RightColumnStartX-1, 0, MainHeight);
Tags->Display();
}