get rid of 'using namespace NCurses' directive
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "mpdpp.h"
|
||||
#include "helpers.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
#include "browser.h"
|
||||
@@ -50,6 +51,12 @@
|
||||
#include "tiny_tag_editor.h"
|
||||
#include "visualizer.h"
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
# include "fileref.h"
|
||||
# include "tag.h"
|
||||
#endif // HAVE_TAGLIB_H
|
||||
|
||||
using namespace std::placeholders;
|
||||
using Global::myScreen;
|
||||
|
||||
bool Action::OriginalStatusbarVisibility;
|
||||
@@ -64,7 +71,7 @@ size_t Action::FooterStartY;
|
||||
std::map<ActionType, Action *> Action::Actions;
|
||||
Action::Key Action::NoOp = Action::Key(ERR, ctNCurses);
|
||||
|
||||
Action::Key Action::ReadKey(Window &w)
|
||||
Action::Key Action::ReadKey(NC::Window &w)
|
||||
{
|
||||
std::string tmp;
|
||||
int input;
|
||||
@@ -98,7 +105,7 @@ void Action::ValidateScreenSize()
|
||||
|
||||
if (COLS < 20 || MainHeight < 3)
|
||||
{
|
||||
DestroyScreen();
|
||||
NC::DestroyScreen();
|
||||
std::cout << "Screen is too small!\n";
|
||||
exit(1);
|
||||
}
|
||||
@@ -252,7 +259,7 @@ void Action::Seek()
|
||||
time_t t = time(0);
|
||||
|
||||
int old_timeout = wFooter->GetTimeout();
|
||||
wFooter->SetTimeout(ncmpcpp_window_timeout);
|
||||
wFooter->SetTimeout(500);
|
||||
|
||||
SeekingInProgress = true;
|
||||
while (true)
|
||||
@@ -289,7 +296,7 @@ void Action::Seek()
|
||||
else
|
||||
break;
|
||||
|
||||
*wFooter << fmtBold;
|
||||
*wFooter << NC::fmtBold;
|
||||
std::string tracklength;
|
||||
if (Config.new_design)
|
||||
{
|
||||
@@ -302,7 +309,7 @@ void Action::Seek()
|
||||
tracklength = MPD::Song::ShowTime(songpos);
|
||||
tracklength += "/";
|
||||
tracklength += MPD::Song::ShowTime(Mpd.GetTotalTime());
|
||||
*wHeader << XY(0, 0) << tracklength << " ";
|
||||
*wHeader << NC::XY(0, 0) << tracklength << " ";
|
||||
wHeader->Refresh();
|
||||
}
|
||||
else
|
||||
@@ -318,9 +325,9 @@ void Action::Seek()
|
||||
tracklength += "/";
|
||||
tracklength += MPD::Song::ShowTime(Mpd.GetTotalTime());
|
||||
tracklength += "]";
|
||||
*wFooter << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength;
|
||||
*wFooter << NC::XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength;
|
||||
}
|
||||
*wFooter << fmtBoldEnd;
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
DrawProgressbar(songpos, Mpd.GetTotalTime());
|
||||
wFooter->Refresh();
|
||||
}
|
||||
@@ -415,7 +422,7 @@ bool Action::AskYesNoQuestion(const std::string &question, void (*callback)())
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << question << " [" << fmtBold << 'y' << fmtBoldEnd << '/' << fmtBold << 'n' << fmtBoldEnd << "]";
|
||||
Statusbar() << question << " [" << NC::fmtBold << 'y' << NC::fmtBoldEnd << '/' << NC::fmtBold << 'n' << NC::fmtBoldEnd << "]";
|
||||
wFooter->Refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -491,13 +498,13 @@ void MouseEvent::Run()
|
||||
|
||||
void ScrollUp::Run()
|
||||
{
|
||||
myScreen->Scroll(wUp);
|
||||
myScreen->Scroll(NC::wUp);
|
||||
ListsChangeFinisher();
|
||||
}
|
||||
|
||||
void ScrollDown::Run()
|
||||
{
|
||||
myScreen->Scroll(wDown);
|
||||
myScreen->Scroll(NC::wDown);
|
||||
ListsChangeFinisher();
|
||||
}
|
||||
|
||||
@@ -583,25 +590,25 @@ void ScrollDownAlbum::Run()
|
||||
|
||||
void PageUp::Run()
|
||||
{
|
||||
myScreen->Scroll(wPageUp);
|
||||
myScreen->Scroll(NC::wPageUp);
|
||||
ListsChangeFinisher();
|
||||
}
|
||||
|
||||
void PageDown::Run()
|
||||
{
|
||||
myScreen->Scroll(wPageDown);
|
||||
myScreen->Scroll(NC::wPageDown);
|
||||
ListsChangeFinisher();
|
||||
}
|
||||
|
||||
void MoveHome::Run()
|
||||
{
|
||||
myScreen->Scroll(wHome);
|
||||
myScreen->Scroll(NC::wHome);
|
||||
ListsChangeFinisher();
|
||||
}
|
||||
|
||||
void MoveEnd::Run()
|
||||
{
|
||||
myScreen->Scroll(wEnd);
|
||||
myScreen->Scroll(NC::wEnd);
|
||||
ListsChangeFinisher();
|
||||
}
|
||||
|
||||
@@ -1416,7 +1423,7 @@ void EditLibraryTag::Run()
|
||||
if (!isMPDMusicDirSet())
|
||||
return;
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << tagTypeToString(Config.media_lib_primary_tag) << fmtBoldEnd << ": ";
|
||||
Statusbar() << NC::fmtBold << tagTypeToString(Config.media_lib_primary_tag) << NC::fmtBoldEnd << ": ";
|
||||
std::string new_tag = wFooter->GetString(myLibrary->Tags->Current().value());
|
||||
UnlockStatusbar();
|
||||
if (!new_tag.empty() && new_tag != myLibrary->Tags->Current().value())
|
||||
@@ -1469,7 +1476,7 @@ void EditLibraryAlbum::Run()
|
||||
if (!isMPDMusicDirSet())
|
||||
return;
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "Album: " << NC::fmtBoldEnd;
|
||||
std::string new_album = wFooter->GetString(myLibrary->Albums->Current().value().Album);
|
||||
UnlockStatusbar();
|
||||
if (!new_album.empty() && new_album != myLibrary->Albums->Current().value().Album)
|
||||
@@ -1529,7 +1536,7 @@ void EditDirectoryName::Run()
|
||||
{
|
||||
std::string old_dir = myBrowser->Main()->Current().value().name;
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << "Directory: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
|
||||
std::string new_dir = wFooter->GetString(old_dir);
|
||||
UnlockStatusbar();
|
||||
if (!new_dir.empty() && new_dir != old_dir)
|
||||
@@ -1563,7 +1570,7 @@ void EditDirectoryName::Run()
|
||||
{
|
||||
std::string old_dir = myTagEditor->Dirs->Current().value().first;
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << "Directory: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
|
||||
std::string new_dir = wFooter->GetString(old_dir);
|
||||
UnlockStatusbar();
|
||||
if (!new_dir.empty() && new_dir != old_dir)
|
||||
@@ -1605,7 +1612,7 @@ void EditPlaylistName::Run()
|
||||
else
|
||||
old_name = myBrowser->Main()->Current().value().name;
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << "Playlist: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "Playlist: " << NC::fmtBoldEnd;
|
||||
std::string new_name = wFooter->GetString(old_name);
|
||||
UnlockStatusbar();
|
||||
if (!new_name.empty() && new_name != old_name)
|
||||
@@ -2005,7 +2012,7 @@ void ApplyFilter::Run()
|
||||
assert(f);
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << "Apply filter: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "Apply filter: " << NC::fmtBoldEnd;
|
||||
wFooter->SetGetStringHelper(std::bind(StatusbarApplyFilterImmediately, f, _1));
|
||||
wFooter->GetString(f->currentFilter());
|
||||
wFooter->SetGetStringHelper(StatusbarGetStringHelper);
|
||||
@@ -2060,9 +2067,9 @@ void Find::Run()
|
||||
UnlockStatusbar();
|
||||
|
||||
ShowMessage("Searching...");
|
||||
Screen<Scrollpad> *s = static_cast<Screen<Scrollpad> *>(myScreen);
|
||||
Screen<NC::Scrollpad> *s = static_cast<Screen<NC::Scrollpad> *>(myScreen);
|
||||
s->Main()->RemoveFormatting();
|
||||
ShowMessage("%s", findme.empty() || s->Main()->SetFormatting(fmtReverse, TO_WSTRING(findme), fmtReverseEnd, 0) ? "Done!" : "No matching patterns found");
|
||||
ShowMessage("%s", findme.empty() || s->Main()->SetFormatting(NC::fmtReverse, TO_WSTRING(findme), NC::fmtReverseEnd, 0) ? "Done!" : "No matching patterns found");
|
||||
s->Main()->Flush();
|
||||
}
|
||||
|
||||
@@ -2131,7 +2138,7 @@ void ToggleReplayGainMode::Run()
|
||||
}
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Replay gain mode? [" << fmtBold << 'o' << fmtBoldEnd << "ff/" << fmtBold << 't' << fmtBoldEnd << "rack/" << fmtBold << 'a' << fmtBoldEnd << "lbum]";
|
||||
Statusbar() << "Replay gain mode? [" << NC::fmtBold << 'o' << NC::fmtBoldEnd << "ff/" << NC::fmtBold << 't' << NC::fmtBoldEnd << "rack/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "lbum]";
|
||||
wFooter->Refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -2175,7 +2182,7 @@ void AddRandomItems::Run()
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Add random? [" << fmtBold << 's' << fmtBoldEnd << "ongs/" << fmtBold << 'a' << fmtBoldEnd << "rtists/al" << fmtBold << 'b' << fmtBoldEnd << "ums] ";
|
||||
Statusbar() << "Add random? [" << NC::fmtBold << 's' << NC::fmtBoldEnd << "ongs/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtists/al" << NC::fmtBold << 'b' << NC::fmtBoldEnd << "ums] ";
|
||||
wFooter->Refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
@@ -2238,7 +2245,7 @@ void ToggleLibraryTagType::Run()
|
||||
using Global::wFooter;
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Tag type? [" << fmtBold << 'a' << fmtBoldEnd << "rtist/album" << fmtBold << 'A' << fmtBoldEnd << "rtist/" << fmtBold << 'y' << fmtBoldEnd << "ear/" << fmtBold << 'g' << fmtBoldEnd << "enre/" << fmtBold << 'c' << fmtBoldEnd << "omposer/" << fmtBold << 'p' << fmtBoldEnd << "erformer] ";
|
||||
Statusbar() << "Tag type? [" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtist/album" << NC::fmtBold << 'A' << NC::fmtBoldEnd << "rtist/" << NC::fmtBold << 'y' << NC::fmtBoldEnd << "ear/" << NC::fmtBold << 'g' << NC::fmtBoldEnd << "enre/" << NC::fmtBold << 'c' << NC::fmtBoldEnd << "omposer/" << NC::fmtBold << 'p' << NC::fmtBoldEnd << "erformer] ";
|
||||
wFooter->Refresh();
|
||||
int answer = 0;
|
||||
do
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "ncmpcpp.h"
|
||||
#include "window.h"
|
||||
|
||||
enum ActionType
|
||||
{
|
||||
@@ -102,7 +102,7 @@ struct Action
|
||||
return false;
|
||||
}
|
||||
|
||||
static Key ReadKey(Window &w);
|
||||
static Key ReadKey(NC::Window &w);
|
||||
|
||||
static void ValidateScreenSize();
|
||||
static void SetResizeFlags();
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "tag_editor.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
@@ -58,7 +60,7 @@ bool BrowserEntryMatcher(const Regex &rx, const MPD::Item &item, bool filter);
|
||||
|
||||
void Browser::Init()
|
||||
{
|
||||
w = new Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, brNone);
|
||||
w = new NC::Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
|
||||
w->HighlightColor(Config.main_highlight_color);
|
||||
w->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
w->CenteredCursor(Config.centered_cursor);
|
||||
@@ -172,7 +174,7 @@ void Browser::SpacePressed()
|
||||
{
|
||||
i = w->Choice();
|
||||
w->at(i).setSelected(!w->at(i).isSelected());
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,7 +221,7 @@ void Browser::SpacePressed()
|
||||
break;
|
||||
}
|
||||
}
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
|
||||
void Browser::MouseButtonPressed(MEVENT me)
|
||||
@@ -242,7 +244,7 @@ void Browser::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = w->Choice();
|
||||
SpacePressed();
|
||||
if (pos < w->Size()-1)
|
||||
w->Scroll(wUp);
|
||||
w->Scroll(NC::wUp);
|
||||
}
|
||||
break;
|
||||
case itPlaylist:
|
||||
@@ -252,7 +254,7 @@ void Browser::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = w->Choice();
|
||||
SpacePressed();
|
||||
if (pos < w->Size()-1)
|
||||
w->Scroll(wUp);
|
||||
w->Scroll(NC::wUp);
|
||||
}
|
||||
else
|
||||
EnterPressed();
|
||||
@@ -260,7 +262,7 @@ void Browser::MouseButtonPressed(MEVENT me)
|
||||
}
|
||||
}
|
||||
else
|
||||
Screen< Menu<MPD::Item> >::MouseButtonPressed(me);
|
||||
Screen< NC::Menu<MPD::Item> >::MouseButtonPressed(me);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -22,11 +22,9 @@
|
||||
#define _BROWSER_H
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "regex_filter.h"
|
||||
#include "screen.h"
|
||||
|
||||
class Browser : public Screen< Menu<MPD::Item> >, public Filterable, public HasSongs, public Searchable
|
||||
class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
public:
|
||||
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
|
||||
@@ -59,7 +57,7 @@ class Browser : public Screen< Menu<MPD::Item> >, public Filterable, public HasS
|
||||
virtual void removeSelection();
|
||||
virtual MPD::SongList getSelectedSongs();
|
||||
|
||||
virtual List *GetList() { return w; }
|
||||
virtual NC::List *GetList() { return w; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ void Clock::Init()
|
||||
{
|
||||
Width = Config.clock_display_seconds ? 60 : 40;
|
||||
|
||||
itsPane = new Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new Window((COLS-Width)/2, (MainHeight-Height)/2+MainStartY, Width, Height-1, "", Config.main_color, Border(Config.main_color));
|
||||
itsPane = new NC::Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w = new NC::Window((COLS-Width)/2, (MainHeight-Height)/2+MainStartY, Width, Height-1, "", Config.main_color, NC::Border(Config.main_color));
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ void Clock::Update()
|
||||
next[k] = 0;
|
||||
for (int s = 1; s >= 0; --s)
|
||||
{
|
||||
*w << (s ? fmtReverse : fmtReverseEnd);
|
||||
*w << (s ? NC::fmtReverse : NC::fmtReverseEnd);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
long a = (newer[i] ^ older[i]) & (s ? newer : older)[i];
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "window.h"
|
||||
#include "screen.h"
|
||||
|
||||
class Clock : public Screen<Window>
|
||||
class Clock : public Screen<NC::Window>
|
||||
{
|
||||
public:
|
||||
virtual void Resize();
|
||||
@@ -39,7 +39,7 @@ class Clock : public Screen<Window>
|
||||
virtual std::basic_string<my_char_t> Title();
|
||||
|
||||
virtual void Update();
|
||||
virtual void Scroll(Where) { }
|
||||
virtual void Scroll(NC::Where) { }
|
||||
|
||||
virtual void EnterPressed() { }
|
||||
virtual void SpacePressed() { }
|
||||
@@ -48,7 +48,7 @@ class Clock : public Screen<Window>
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
@@ -57,7 +57,7 @@ class Clock : public Screen<Window>
|
||||
virtual bool isLockable() { return false; }
|
||||
|
||||
private:
|
||||
Window *itsPane;
|
||||
NC::Window *itsPane;
|
||||
|
||||
static void Prepare();
|
||||
static void Set(int, int);
|
||||
|
||||
@@ -73,7 +73,7 @@ const my_char_t *toColumnName(char c)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void setProperties(Menu<T> &menu, const MPD::Song &s, HasSongs &screen, bool &separate_albums,
|
||||
void setProperties(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen, bool &separate_albums,
|
||||
bool &is_now_playing, bool &is_selected, bool &discard_colors)
|
||||
{
|
||||
separate_albums = false;
|
||||
@@ -84,7 +84,7 @@ void setProperties(Menu<T> &menu, const MPD::Song &s, HasSongs &screen, bool &se
|
||||
separate_albums = true;
|
||||
}
|
||||
if (separate_albums)
|
||||
menu << fmtUnderline;
|
||||
menu << NC::fmtUnderline;
|
||||
|
||||
int song_pos = menu.isFiltered() ? s.getPosition() : menu.DrawnPosition();
|
||||
is_now_playing = static_cast<void *>(&menu) == myPlaylist->Items
|
||||
@@ -94,7 +94,7 @@ void setProperties(Menu<T> &menu, const MPD::Song &s, HasSongs &screen, bool &se
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void showSongs(Menu<T> &menu, const MPD::Song &s, HasSongs &screen, const std::string &format)
|
||||
void showSongs(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen, const std::string &format)
|
||||
{
|
||||
bool separate_albums, is_now_playing, is_selected, discard_colors;
|
||||
setProperties(menu, s, screen, separate_albums, is_now_playing, is_selected, discard_colors);
|
||||
@@ -112,20 +112,20 @@ void showSongs(Menu<T> &menu, const MPD::Song &s, HasSongs &screen, const std::s
|
||||
else if (isdigit(*it)) // color
|
||||
{
|
||||
if (!discard_colors)
|
||||
menu << Color(*it-'0');
|
||||
menu << NC::Color(*it-'0');
|
||||
}
|
||||
else if (*it == 'R') // right align
|
||||
{
|
||||
basic_buffer<my_char_t> buf;
|
||||
NC::basic_buffer<my_char_t> buf;
|
||||
buf << U(" ");
|
||||
String2Buffer(TO_WSTRING(line.substr(it-line.begin()+1)), buf);
|
||||
if (discard_colors)
|
||||
buf.RemoveFormatting();
|
||||
if (is_now_playing)
|
||||
buf << Config.now_playing_suffix;
|
||||
menu << XY(menu.GetWidth()-buf.Str().length()-(is_selected ? Config.selected_item_suffix_length : 0), menu.Y()) << buf;
|
||||
menu << NC::XY(menu.GetWidth()-buf.Str().length()-(is_selected ? Config.selected_item_suffix_length : 0), menu.Y()) << buf;
|
||||
if (separate_albums)
|
||||
menu << fmtUnderlineEnd;
|
||||
menu << NC::fmtUnderlineEnd;
|
||||
return;
|
||||
}
|
||||
else // not a color nor right align, just a random character
|
||||
@@ -144,11 +144,11 @@ void showSongs(Menu<T> &menu, const MPD::Song &s, HasSongs &screen, const std::s
|
||||
if (is_now_playing)
|
||||
menu << Config.now_playing_suffix;
|
||||
if (separate_albums)
|
||||
menu << fmtUnderlineEnd;
|
||||
menu << NC::fmtUnderlineEnd;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void showSongsInColumns(Menu<T> &menu, const MPD::Song &s, HasSongs &screen)
|
||||
void showSongsInColumns(NC::Menu<T> &menu, const MPD::Song &s, HasSongs &screen)
|
||||
{
|
||||
if (Config.columns.empty())
|
||||
return;
|
||||
@@ -219,16 +219,16 @@ void showSongsInColumns(Menu<T> &menu, const MPD::Song &s, HasSongs &screen)
|
||||
}
|
||||
if (tag.empty() && it->display_empty_tag)
|
||||
tag = TO_WSTRING(Config.empty_tag);
|
||||
Window::Cut(tag, width);
|
||||
NC::Window::Cut(tag, width);
|
||||
|
||||
if (!discard_colors && it->color != clDefault)
|
||||
if (!discard_colors && it->color != NC::clDefault)
|
||||
menu << it->color;
|
||||
|
||||
int x_off = 0;
|
||||
// if column uses right alignment, calculate proper offset.
|
||||
// otherwise just assume offset is 0, ie. we start from the left.
|
||||
if (it->right_alignment)
|
||||
x_off = std::max(0, width - int(Window::Length(tag)));
|
||||
x_off = std::max(0, width - int(NC::Window::Length(tag)));
|
||||
|
||||
whline(menu.Raw(), KEY_SPACE, width);
|
||||
menu.GotoXY(x + x_off, y);
|
||||
@@ -241,8 +241,8 @@ void showSongsInColumns(Menu<T> &menu, const MPD::Song &s, HasSongs &screen)
|
||||
remained_width -= width+1;
|
||||
}
|
||||
|
||||
if (!discard_colors && it->color != clDefault)
|
||||
menu << clEnd;
|
||||
if (!discard_colors && it->color != NC::clDefault)
|
||||
menu << NC::clEnd;
|
||||
}
|
||||
|
||||
// here comes the shitty part, second chapter. here we apply
|
||||
@@ -261,7 +261,7 @@ void showSongsInColumns(Menu<T> &menu, const MPD::Song &s, HasSongs &screen)
|
||||
menu.GotoXY(menu.GetWidth() - Config.selected_item_suffix_length, y);
|
||||
|
||||
if (separate_albums)
|
||||
menu << fmtUnderlineEnd;
|
||||
menu << NC::fmtUnderlineEnd;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -308,9 +308,9 @@ std::string Display::Columns(size_t list_width)
|
||||
}
|
||||
else
|
||||
name = it->name;
|
||||
Window::Cut(name, width);
|
||||
NC::Window::Cut(name, width);
|
||||
|
||||
int x_off = std::max(0, width - int(Window::Length(name)));
|
||||
int x_off = std::max(0, width - int(NC::Window::Length(name)));
|
||||
if (it->right_alignment)
|
||||
{
|
||||
result += std::string(x_off, KEY_SPACE);
|
||||
@@ -333,17 +333,17 @@ std::string Display::Columns(size_t list_width)
|
||||
return result;
|
||||
}
|
||||
|
||||
void Display::SongsInColumns(Menu<MPD::Song> &menu, HasSongs &screen)
|
||||
void Display::SongsInColumns(NC::Menu<MPD::Song> &menu, HasSongs &screen)
|
||||
{
|
||||
showSongsInColumns(menu, menu.Drawn().value(), screen);
|
||||
}
|
||||
|
||||
void Display::Songs(Menu<MPD::Song> &menu, HasSongs &screen, const std::string &format)
|
||||
void Display::Songs(NC::Menu<MPD::Song> &menu, HasSongs &screen, const std::string &format)
|
||||
{
|
||||
showSongs(menu, menu.Drawn().value(), screen, format);
|
||||
}
|
||||
|
||||
void Display::Tags(Menu<MPD::MutableSong> &menu)
|
||||
void Display::Tags(NC::Menu<MPD::MutableSong> &menu)
|
||||
{
|
||||
const MPD::MutableSong &s = menu.Drawn().value();
|
||||
size_t i = myTagEditor->TagTypes->Choice();
|
||||
@@ -356,16 +356,16 @@ void Display::Tags(Menu<MPD::MutableSong> &menu)
|
||||
if (s.getNewURI().empty())
|
||||
menu << s.getName();
|
||||
else
|
||||
menu << s.getName() << Config.color2 << " -> " << clEnd << s.getNewURI();
|
||||
menu << s.getName() << Config.color2 << " -> " << NC::clEnd << s.getNewURI();
|
||||
}
|
||||
}
|
||||
|
||||
void Display::Outputs(Menu< MPD::Output > &menu)
|
||||
void Display::Outputs(NC::Menu<MPD::Output> &menu)
|
||||
{
|
||||
menu << menu.Drawn().value().name();
|
||||
}
|
||||
|
||||
void Display::Items(Menu<MPD::Item> &menu)
|
||||
void Display::Items(NC::Menu<MPD::Item> &menu)
|
||||
{
|
||||
const MPD::Item &item = menu.Drawn().value();
|
||||
switch (item.type)
|
||||
@@ -385,7 +385,7 @@ void Display::Items(Menu<MPD::Item> &menu)
|
||||
}
|
||||
}
|
||||
|
||||
void Display::SearchEngine(Menu<SEItem> &menu)
|
||||
void Display::SearchEngine(NC::Menu<SEItem> &menu)
|
||||
{
|
||||
const SEItem &si = menu.Drawn().value();
|
||||
if (si.isSong())
|
||||
|
||||
@@ -22,9 +22,7 @@
|
||||
#define _DISPLAY_H
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "menu.h"
|
||||
#include "mpdpp.h"
|
||||
#include "mutable_song.h"
|
||||
#include "search_engine.h"
|
||||
|
||||
@@ -32,27 +30,27 @@ namespace Display
|
||||
{
|
||||
std::string Columns(size_t);
|
||||
|
||||
template <typename T> void Default(Menu<T> &menu)
|
||||
template <typename T> void Default(NC::Menu<T> &menu)
|
||||
{
|
||||
menu << menu.Drawn().value();
|
||||
}
|
||||
|
||||
template <typename A, typename B> void Pair(Menu< std::pair<A, B> > &menu)
|
||||
template <typename A, typename B> void Pair(NC::Menu< std::pair<A, B> > &menu)
|
||||
{
|
||||
menu << menu.Drawn().value().first;
|
||||
}
|
||||
|
||||
void SongsInColumns(Menu<MPD::Song> &menu, HasSongs &screen);
|
||||
void SongsInColumns(NC::Menu<MPD::Song> &menu, HasSongs &screen);
|
||||
|
||||
void Songs(Menu<MPD::Song> &menu, HasSongs &screen, const std::string &format);
|
||||
void Songs(NC::Menu<MPD::Song> &menu, HasSongs &screen, const std::string &format);
|
||||
|
||||
void Tags(Menu<MPD::MutableSong> &menu);
|
||||
void Tags(NC::Menu<MPD::MutableSong> &menu);
|
||||
|
||||
void Outputs(Menu<MPD::Output> &menu);
|
||||
void Outputs(NC::Menu<MPD::Output> &menu);
|
||||
|
||||
void SearchEngine(Menu<SEItem> &menu);
|
||||
void SearchEngine(NC::Menu<SEItem> &menu);
|
||||
|
||||
void Items(Menu<MPD::Item> &menu);
|
||||
void Items(NC::Menu<MPD::Item> &menu);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "ncmpcpp.h"
|
||||
#include "mpdpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
@@ -45,10 +44,10 @@ namespace Global
|
||||
extern BasicScreen *myInactiveScreen;
|
||||
|
||||
// header window (above main window)
|
||||
extern Window *wHeader;
|
||||
extern NC::Window *wHeader;
|
||||
|
||||
// footer window (below main window)
|
||||
extern Window *wFooter;
|
||||
extern NC::Window *wFooter;
|
||||
|
||||
// Y coordinate of top of main window
|
||||
extern size_t MainStartY;
|
||||
|
||||
12
src/help.cpp
12
src/help.cpp
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "help.h"
|
||||
#include "scrollpad.h"
|
||||
#include "settings.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -88,11 +88,13 @@ std::string keyToString(const Action::Key &key, bool *print_backspace)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Help::Init()
|
||||
{
|
||||
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
GetKeybindings();
|
||||
w->Flush();
|
||||
isInitialized = 1;
|
||||
@@ -154,8 +156,8 @@ std::string Help::DisplayKeys(const ActionType at)
|
||||
|
||||
void Help::Section(const char *type, const char *title)
|
||||
{
|
||||
*w << U("\n ") << fmtBold << TO_WSTRING(type) << U(" - ");
|
||||
*w << TO_WSTRING(title) << fmtBoldEnd << '\n' << '\n';
|
||||
*w << U("\n ") << NC::fmtBold << TO_WSTRING(type) << U(" - ");
|
||||
*w << TO_WSTRING(title) << NC::fmtBoldEnd << '\n' << '\n';
|
||||
}
|
||||
|
||||
void Help::KeyDesc(const ActionType at, const char *desc)
|
||||
@@ -172,7 +174,7 @@ void Help::MouseDesc(std::string action, const char *desc, bool indent)
|
||||
|
||||
void Help::MouseColumn(const char *column)
|
||||
{
|
||||
*w << fmtBold << U(" ") << TO_WSTRING(column) << U(" column:\n") << fmtBoldEnd;
|
||||
*w << NC::fmtBold << U(" ") << TO_WSTRING(column) << U(" column:\n") << NC::fmtBoldEnd;
|
||||
}
|
||||
|
||||
void Help::GetKeybindings()
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
#ifndef _HELP_H
|
||||
#define _HELP_H
|
||||
|
||||
#include "ncmpcpp.h"
|
||||
#include "actions.h"
|
||||
#include "screen.h"
|
||||
|
||||
class Help : public Screen<Scrollpad>
|
||||
class Help : public Screen<NC::Scrollpad>
|
||||
{
|
||||
public:
|
||||
virtual void Resize();
|
||||
@@ -38,7 +38,7 @@ class Help : public Screen<Scrollpad>
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -282,22 +282,10 @@ std::string Timestamp(time_t t)
|
||||
return result;
|
||||
}
|
||||
|
||||
void UpdateSongList(Menu<MPD::Song> *menu)
|
||||
void UpdateSongList(NC::Menu<MPD::Song> *menu)
|
||||
{
|
||||
bool bold = 0;
|
||||
for (size_t i = 0; i < menu->Size(); ++i)
|
||||
{
|
||||
for (size_t j = 0; j < myPlaylist->Items->Size(); ++j)
|
||||
{
|
||||
if (myPlaylist->Items->at(j).value().getHash() == menu->at(i).value().getHash())
|
||||
{
|
||||
bold = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
(*menu)[i].setBold(bold);
|
||||
bold = 0;
|
||||
}
|
||||
for (auto it = menu->Begin(); it != menu->End(); ++it)
|
||||
it->setSelected(myPlaylist->checkForSong(it->value()));
|
||||
menu->Refresh();
|
||||
}
|
||||
|
||||
@@ -307,14 +295,14 @@ std::basic_string<my_char_t> Scroller(const std::basic_string<my_char_t> &str, s
|
||||
if (!Config.header_text_scrolling)
|
||||
return s;
|
||||
std::basic_string<my_char_t> result;
|
||||
size_t len = Window::Length(s);
|
||||
size_t len = NC::Window::Length(s);
|
||||
|
||||
if (len > width)
|
||||
{
|
||||
s += U(" ** ");
|
||||
len = 0;
|
||||
std::basic_string<my_char_t>::const_iterator b = s.begin(), e = s.end();
|
||||
for (std::basic_string<my_char_t>::const_iterator it = b+pos; it < e && len < width; ++it)
|
||||
auto b = s.begin(), e = s.end();
|
||||
for (auto it = b+pos; it < e && len < width; ++it)
|
||||
{
|
||||
if ((len += wcwidth(*it)) > width)
|
||||
break;
|
||||
|
||||
@@ -21,11 +21,17 @@
|
||||
#ifndef _HELPERS_H
|
||||
#define _HELPERS_H
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "mpdpp.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
|
||||
inline HasSongs *hasSongs(BasicScreen *screen)
|
||||
{
|
||||
return dynamic_cast<HasSongs *>(screen);
|
||||
}
|
||||
|
||||
template <typename Iterator> void removeSelectionHelper(Iterator first, Iterator last)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
@@ -51,7 +57,7 @@ template <typename Iterator> std::string getSharedDirectory(Iterator first, Iter
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T> void withUnfilteredMenu(Menu<T> &menu, std::function<void()> action)
|
||||
template <typename T> void withUnfilteredMenu(NC::Menu<T> &menu, std::function<void()> action)
|
||||
{
|
||||
bool is_filtered = menu.isFiltered();
|
||||
menu.ShowAll();
|
||||
@@ -65,17 +71,17 @@ void ParseArgv(int, char **);
|
||||
template <typename T> struct StringConverter {
|
||||
const char *operator()(const char *s) { return s; }
|
||||
};
|
||||
template <> struct StringConverter< basic_buffer<wchar_t> > {
|
||||
template <> struct StringConverter< NC::basic_buffer<wchar_t> > {
|
||||
std::wstring operator()(const char *s) { return ToWString(s); }
|
||||
};
|
||||
template <> struct StringConverter<Scrollpad> {
|
||||
template <> struct StringConverter<NC::Scrollpad> {
|
||||
std::basic_string<my_char_t> operator()(const char *s) { return TO_WSTRING(s); }
|
||||
};
|
||||
|
||||
template <typename C> void String2Buffer(const std::basic_string<C> &s, basic_buffer<C> &buf)
|
||||
template <typename C> void String2Buffer(const std::basic_string<C> &s, NC::basic_buffer<C> &buf)
|
||||
{
|
||||
StringConverter< basic_buffer<C> > cnv;
|
||||
for (typename std::basic_string<C>::const_iterator it = s.begin(); it != s.end(); ++it)
|
||||
StringConverter< NC::basic_buffer<C> > cnv;
|
||||
for (auto it = s.begin(); it != s.end(); ++it)
|
||||
{
|
||||
if (*it == '$')
|
||||
{
|
||||
@@ -86,23 +92,23 @@ template <typename C> void String2Buffer(const std::basic_string<C> &s, basic_bu
|
||||
}
|
||||
else if (isdigit(*it))
|
||||
{
|
||||
buf << Color(*it-'0');
|
||||
buf << NC::Color(*it-'0');
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (*it)
|
||||
{
|
||||
case 'b':
|
||||
buf << fmtBold;
|
||||
buf << NC::fmtBold;
|
||||
break;
|
||||
case 'u':
|
||||
buf << fmtUnderline;
|
||||
buf << NC::fmtUnderline;
|
||||
break;
|
||||
case 'a':
|
||||
buf << fmtAltCharset;
|
||||
buf << NC::fmtAltCharset;
|
||||
break;
|
||||
case 'r':
|
||||
buf << fmtReverse;
|
||||
buf << NC::fmtReverse;
|
||||
break;
|
||||
case '/':
|
||||
if (++it == s.end())
|
||||
@@ -113,16 +119,16 @@ template <typename C> void String2Buffer(const std::basic_string<C> &s, basic_bu
|
||||
switch (*it)
|
||||
{
|
||||
case 'b':
|
||||
buf << fmtBoldEnd;
|
||||
buf << NC::fmtBoldEnd;
|
||||
break;
|
||||
case 'u':
|
||||
buf << fmtUnderlineEnd;
|
||||
buf << NC::fmtUnderlineEnd;
|
||||
break;
|
||||
case 'a':
|
||||
buf << fmtAltCharsetEnd;
|
||||
buf << NC::fmtAltCharsetEnd;
|
||||
break;
|
||||
case 'r':
|
||||
buf << fmtReverseEnd;
|
||||
buf << NC::fmtReverseEnd;
|
||||
break;
|
||||
default:
|
||||
buf << '$' << *--it;
|
||||
@@ -195,14 +201,14 @@ template <typename T> void ShowTime(T &buf, size_t length, bool short_names)
|
||||
template <typename T> void ShowTag(T &buf, const std::string &tag)
|
||||
{
|
||||
if (tag.empty())
|
||||
buf << Config.empty_tags_color << Config.empty_tag << clEnd;
|
||||
buf << Config.empty_tags_color << Config.empty_tag << NC::clEnd;
|
||||
else
|
||||
buf << tag;
|
||||
}
|
||||
|
||||
std::string Timestamp(time_t t);
|
||||
|
||||
void UpdateSongList(Menu<MPD::Song> *);
|
||||
void UpdateSongList(NC::Menu<MPD::Song> *);
|
||||
|
||||
std::basic_string<my_char_t> Scroller(const std::basic_string<my_char_t> &str, size_t &pos, size_t width);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "helpers.h"
|
||||
#include "charset.h"
|
||||
#include "global.h"
|
||||
|
||||
@@ -44,7 +45,7 @@ Lastfm *myLastfm = new Lastfm;
|
||||
|
||||
void Lastfm::Init()
|
||||
{
|
||||
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ void Lastfm::Download()
|
||||
itsService->colorizeOutput(*w);
|
||||
}
|
||||
else
|
||||
*w << clRed << result.second << clEnd;
|
||||
*w << NC::clRed << result.second << NC::clEnd;
|
||||
|
||||
isReadyToTake = 1;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "lastfm_service.h"
|
||||
#include "screen.h"
|
||||
|
||||
class Lastfm : public Screen<Scrollpad>
|
||||
class Lastfm : public Screen<NC::Scrollpad>
|
||||
{
|
||||
public:
|
||||
Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { }
|
||||
@@ -50,7 +50,7 @@ class Lastfm : public Screen<Scrollpad>
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -102,10 +102,10 @@ bool ArtistInfo::checkArgs(const Args &args)
|
||||
return args.find("artist") != args.end();
|
||||
}
|
||||
|
||||
void ArtistInfo::colorizeOutput(NCurses::Scrollpad &w)
|
||||
void ArtistInfo::colorizeOutput(NC::Scrollpad &w)
|
||||
{
|
||||
w.SetFormatting(fmtBold, U("\n\nSimilar artists:\n"), fmtBoldEnd, false);
|
||||
w.SetFormatting(Config.color2, U("\n * "), clEnd, true);
|
||||
w.SetFormatting(NC::fmtBold, U("\n\nSimilar artists:\n"), NC::fmtBoldEnd, false);
|
||||
w.SetFormatting(Config.color2, U("\n * "), NC::clEnd, true);
|
||||
// below is used so format won't be removed using RemoveFormatting() by accident.
|
||||
w.ForgetFormatting();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ struct LastfmService
|
||||
virtual Result fetch(Args &args);
|
||||
|
||||
virtual bool checkArgs(const Args &args) = 0;
|
||||
virtual void colorizeOutput(NCurses::Scrollpad &w) = 0;
|
||||
virtual void colorizeOutput(NC::Scrollpad &w) = 0;
|
||||
|
||||
protected:
|
||||
virtual bool actionFailed(const std::string &data);
|
||||
@@ -60,7 +60,7 @@ struct ArtistInfo : public LastfmService
|
||||
virtual const char *name() { return "Artist info"; }
|
||||
|
||||
virtual bool checkArgs(const Args &args);
|
||||
virtual void colorizeOutput(NCurses::Scrollpad &w);
|
||||
virtual void colorizeOutput(NC::Scrollpad &w);
|
||||
|
||||
protected:
|
||||
virtual bool parse(std::string &data);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "helpers.h"
|
||||
#include "lyrics.h"
|
||||
#include "playlist.h"
|
||||
#include "scrollpad.h"
|
||||
#include "settings.h"
|
||||
#include "song.h"
|
||||
|
||||
@@ -49,7 +50,7 @@ Lyrics *myLyrics = new Lyrics;
|
||||
|
||||
void Lyrics::Init()
|
||||
{
|
||||
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
@@ -254,10 +255,10 @@ void *Lyrics::Download()
|
||||
bool fetcher_defined = itsFetcher && *itsFetcher;
|
||||
for (LyricsFetcher **plugin = fetcher_defined ? itsFetcher : lyricsPlugins; *plugin != 0; ++plugin)
|
||||
{
|
||||
*w << U("Fetching lyrics from ") << fmtBold << TO_WSTRING((*plugin)->name()) << fmtBoldEnd << U("... ");
|
||||
*w << U("Fetching lyrics from ") << NC::fmtBold << TO_WSTRING((*plugin)->name()) << NC::fmtBoldEnd << U("... ");
|
||||
result = (*plugin)->fetch(artist, title);
|
||||
if (result.first == false)
|
||||
*w << clRed << TO_WSTRING(result.second) << clEnd << '\n';
|
||||
*w << NC::clRed << TO_WSTRING(result.second) << NC::clEnd << '\n';
|
||||
else
|
||||
break;
|
||||
if (fetcher_defined)
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
#include <pthread.h>
|
||||
#include <queue>
|
||||
|
||||
#include "ncmpcpp.h"
|
||||
#include "mpdpp.h"
|
||||
#include "screen.h"
|
||||
#include "lyrics_fetcher.h"
|
||||
|
||||
class Lyrics : public Screen<Scrollpad>
|
||||
class Lyrics : public Screen<NC::Scrollpad>
|
||||
{
|
||||
public:
|
||||
Lyrics() : ReloadNP(0),
|
||||
@@ -50,7 +49,7 @@ class Lyrics : public Screen<Scrollpad>
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "utility/comparators.h"
|
||||
#include "utility/type_conversions.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
@@ -62,11 +64,11 @@ std::string AlbumToString(const SearchConstraints &sc);
|
||||
std::string SongToString(const MPD::Song &s);
|
||||
|
||||
bool TagEntryMatcher(const Regex &rx, const std::string &tag);
|
||||
bool AlbumEntryMatcher(const Regex &rx, const Menu<SearchConstraints>::Item &item, bool filter);
|
||||
bool AlbumEntryMatcher(const Regex &rx, const NC::Menu<SearchConstraints>::Item &item, bool filter);
|
||||
bool SongEntryMatcher(const Regex &rx, const MPD::Song &s);
|
||||
|
||||
void DisplayAlbums(Menu<SearchConstraints> &menu);
|
||||
void DisplayPrimaryTags(Menu<std::string> &menu);
|
||||
void DisplayAlbums(NC::Menu<SearchConstraints> &menu);
|
||||
void DisplayPrimaryTags(NC::Menu<std::string> &menu);
|
||||
|
||||
bool SortSongsByTrack(const MPD::Song &a, const MPD::Song &b);
|
||||
bool SortAllTracks(const MPD::Song &a, const MPD::Song &b);
|
||||
@@ -83,7 +85,7 @@ void MediaLibrary::Init()
|
||||
itsRightColWidth = COLS-COLS/3*2-1;
|
||||
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
|
||||
|
||||
Tags = new Menu<std::string>(0, MainStartY, itsLeftColWidth, MainHeight, Config.titles_visibility ? tagTypeToString(Config.media_lib_primary_tag) + "s" : "", Config.main_color, brNone);
|
||||
Tags = new NC::Menu<std::string>(0, MainStartY, itsLeftColWidth, MainHeight, Config.titles_visibility ? tagTypeToString(Config.media_lib_primary_tag) + "s" : "", Config.main_color, NC::brNone);
|
||||
Tags->HighlightColor(Config.active_column_color);
|
||||
Tags->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Tags->CenteredCursor(Config.centered_cursor);
|
||||
@@ -91,7 +93,7 @@ void MediaLibrary::Init()
|
||||
Tags->SetSelectSuffix(Config.selected_item_suffix);
|
||||
Tags->setItemDisplayer(DisplayPrimaryTags);
|
||||
|
||||
Albums = new Menu<SearchConstraints>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, brNone);
|
||||
Albums = new NC::Menu<SearchConstraints>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::brNone);
|
||||
Albums->HighlightColor(Config.main_highlight_color);
|
||||
Albums->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Albums->CenteredCursor(Config.centered_cursor);
|
||||
@@ -99,7 +101,7 @@ void MediaLibrary::Init()
|
||||
Albums->SetSelectSuffix(Config.selected_item_suffix);
|
||||
Albums->setItemDisplayer(DisplayAlbums);
|
||||
|
||||
Songs = new Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, brNone);
|
||||
Songs = new NC::Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, NC::brNone);
|
||||
Songs->HighlightColor(Config.main_highlight_color);
|
||||
Songs->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Songs->CenteredCursor(Config.centered_cursor);
|
||||
@@ -152,7 +154,7 @@ void MediaLibrary::Refresh()
|
||||
Songs->Display();
|
||||
if (Albums->Empty())
|
||||
{
|
||||
*Albums << XY(0, 0) << "No albums found.";
|
||||
*Albums << NC::XY(0, 0) << "No albums found.";
|
||||
Albums->Window::Refresh();
|
||||
}
|
||||
}
|
||||
@@ -267,7 +269,7 @@ void MediaLibrary::Update()
|
||||
else if (hasTwoColumns && Albums->ReallyEmpty())
|
||||
{
|
||||
Songs->Clear();
|
||||
*Albums << XY(0, 0) << "Fetching albums...";
|
||||
*Albums << NC::XY(0, 0) << "Fetching albums...";
|
||||
Albums->Window::Refresh();
|
||||
Mpd.BlockIdle(true);
|
||||
auto artists = Mpd.GetList(Config.media_lib_primary_tag);
|
||||
@@ -359,7 +361,7 @@ void MediaLibrary::SpacePressed()
|
||||
size_t i = Songs->Choice();
|
||||
Songs->at(i).setSelected(!Songs->at(i).isSelected());
|
||||
}
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
else
|
||||
AddToPlaylist(0);
|
||||
@@ -382,11 +384,11 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = Tags->Choice();
|
||||
SpacePressed();
|
||||
if (pos < Tags->Size()-1)
|
||||
Tags->Scroll(wUp);
|
||||
Tags->Scroll(NC::wUp);
|
||||
}
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
Albums->Clear();
|
||||
Songs->Clear();
|
||||
}
|
||||
@@ -402,11 +404,11 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = Albums->Choice();
|
||||
SpacePressed();
|
||||
if (pos < Albums->Size()-1)
|
||||
Albums->Scroll(wUp);
|
||||
Albums->Scroll(NC::wUp);
|
||||
}
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
Songs->Clear();
|
||||
}
|
||||
else if (!Songs->Empty() && Songs->hasCoords(me.x, me.y))
|
||||
@@ -424,17 +426,17 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = Songs->Choice();
|
||||
SpacePressed();
|
||||
if (pos < Songs->Size()-1)
|
||||
Songs->Scroll(wUp);
|
||||
Songs->Scroll(NC::wUp);
|
||||
}
|
||||
else
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
}
|
||||
|
||||
List *MediaLibrary::GetList()
|
||||
NC::List *MediaLibrary::GetList()
|
||||
{
|
||||
if (w == Tags)
|
||||
return Tags;
|
||||
@@ -841,7 +843,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
||||
|
||||
if (!add_n_play)
|
||||
{
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
if (w == Tags)
|
||||
{
|
||||
Albums->Clear();
|
||||
@@ -881,14 +883,12 @@ std::string SongToString(const MPD::Song &s)
|
||||
return s.toString(Config.song_library_format);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool TagEntryMatcher(const Regex &rx, const std::string &tag)
|
||||
{
|
||||
return rx.match(tag);
|
||||
}
|
||||
|
||||
bool AlbumEntryMatcher(const Regex &rx, const Menu<SearchConstraints>::Item &item, bool filter)
|
||||
bool AlbumEntryMatcher(const Regex &rx, const NC::Menu<SearchConstraints>::Item &item, bool filter)
|
||||
{
|
||||
if (item.isSeparator() || item.value().Date == AllTracksMarker)
|
||||
return filter;
|
||||
@@ -902,12 +902,12 @@ bool SongEntryMatcher(const Regex &rx, const MPD::Song &s)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void DisplayAlbums(Menu<SearchConstraints> &menu)
|
||||
void DisplayAlbums(NC::Menu<SearchConstraints> &menu)
|
||||
{
|
||||
menu << AlbumToString(menu.Drawn().value());
|
||||
}
|
||||
|
||||
void DisplayPrimaryTags(Menu<std::string> &menu)
|
||||
void DisplayPrimaryTags(NC::Menu<std::string> &menu)
|
||||
{
|
||||
const std::string &tag = menu.Drawn().value();
|
||||
if (tag.empty())
|
||||
|
||||
@@ -22,10 +22,9 @@
|
||||
#define _H_MEDIA_LIBRARY
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
class MediaLibrary : public Screen<Window>, public Filterable, public HasSongs, public Searchable
|
||||
class MediaLibrary : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
public:
|
||||
virtual void SwitchTo();
|
||||
@@ -59,7 +58,7 @@ class MediaLibrary : public Screen<Window>, public Filterable, public HasSongs,
|
||||
virtual void removeSelection();
|
||||
virtual MPD::SongList getSelectedSongs();
|
||||
|
||||
virtual List *GetList();
|
||||
virtual NC::List *GetList();
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
@@ -84,9 +83,9 @@ class MediaLibrary : public Screen<Window>, public Filterable, public HasSongs,
|
||||
std::string Date;
|
||||
};
|
||||
|
||||
Menu<std::string> *Tags;
|
||||
Menu<SearchConstraints> *Albums;
|
||||
Menu<MPD::Song> *Songs;
|
||||
NC::Menu<std::string> *Tags;
|
||||
NC::Menu<SearchConstraints> *Albums;
|
||||
NC::Menu<MPD::Song> *Songs;
|
||||
|
||||
protected:
|
||||
virtual void Init();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "strbuffer.h"
|
||||
#include "window.h"
|
||||
|
||||
namespace NCurses {
|
||||
namespace NC {
|
||||
|
||||
/// List class is an interface for Menu class
|
||||
struct List
|
||||
|
||||
@@ -73,7 +73,6 @@ namespace MPD
|
||||
};
|
||||
|
||||
typedef std::vector<Item> ItemList;
|
||||
typedef std::vector<Song> SongList;
|
||||
typedef std::vector<std::string> StringList;
|
||||
typedef std::vector<Output> OutputList;
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include "mpdpp.h"
|
||||
#include "ncmpcpp.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "browser.h"
|
||||
@@ -67,7 +66,7 @@ namespace
|
||||
errorlog.close();
|
||||
Mpd.Disconnect();
|
||||
# ifndef USE_PDCURSES // destroying screen somehow crashes pdcurses
|
||||
DestroyScreen();
|
||||
NC::DestroyScreen();
|
||||
# endif // USE_PDCURSES
|
||||
WindowTitle("");
|
||||
}
|
||||
@@ -135,7 +134,7 @@ int main(int argc, char **argv)
|
||||
cerr_buffer = std::cerr.rdbuf();
|
||||
std::cerr.rdbuf(errorlog.rdbuf());
|
||||
|
||||
InitScreen("ncmpcpp ver. "VERSION, Config.colors_enabled);
|
||||
NC::InitScreen("ncmpcpp ver. "VERSION, Config.colors_enabled);
|
||||
|
||||
Action::OriginalStatusbarVisibility = Config.statusbar_visibility;
|
||||
|
||||
@@ -148,12 +147,12 @@ int main(int argc, char **argv)
|
||||
Action::SetWindowsDimensions();
|
||||
Action::ValidateScreenSize();
|
||||
|
||||
wHeader = new Window(0, 0, COLS, Action::HeaderHeight, "", Config.header_color, brNone);
|
||||
wHeader = new NC::Window(0, 0, COLS, Action::HeaderHeight, "", Config.header_color, NC::brNone);
|
||||
if (Config.header_visibility || Config.new_design)
|
||||
wHeader->Display();
|
||||
|
||||
wFooter = new Window(0, Action::FooterStartY, COLS, Action::FooterHeight, "", Config.statusbar_color, brNone);
|
||||
wFooter->SetTimeout(ncmpcpp_window_timeout);
|
||||
wFooter = new NC::Window(0, Action::FooterStartY, COLS, Action::FooterHeight, "", Config.statusbar_color, NC::brNone);
|
||||
wFooter->SetTimeout(500);
|
||||
wFooter->SetGetStringHelper(StatusbarGetStringHelper);
|
||||
if (Mpd.SupportsIdle())
|
||||
wFooter->AddFDCallback(Mpd.GetFD(), StatusbarMPDCallback);
|
||||
@@ -243,20 +242,20 @@ int main(int argc, char **argv)
|
||||
if (Config.new_design)
|
||||
{
|
||||
std::basic_string<my_char_t> title = myScreen->Title();
|
||||
*wHeader << XY(0, 3) << wclrtoeol;
|
||||
*wHeader << fmtBold << Config.alternative_ui_separator_color;
|
||||
*wHeader << NC::XY(0, 3) << wclrtoeol;
|
||||
*wHeader << NC::fmtBold << Config.alternative_ui_separator_color;
|
||||
mvwhline(wHeader->Raw(), 2, 0, 0, COLS);
|
||||
mvwhline(wHeader->Raw(), 4, 0, 0, COLS);
|
||||
*wHeader << XY((COLS-Window::Length(title))/2, 3);
|
||||
*wHeader << Config.header_color << title << clEnd;
|
||||
*wHeader << clEnd << fmtBoldEnd;
|
||||
*wHeader << NC::XY((COLS-NC::Window::Length(title))/2, 3);
|
||||
*wHeader << Config.header_color << title << NC::clEnd;
|
||||
*wHeader << NC::clEnd << NC::fmtBoldEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
*wHeader << XY(0, 0) << wclrtoeol << fmtBold << myScreen->Title() << fmtBoldEnd;
|
||||
*wHeader << NC::XY(0, 0) << wclrtoeol << NC::fmtBold << myScreen->Title() << NC::fmtBoldEnd;
|
||||
*wHeader << Config.volume_color;
|
||||
*wHeader << XY(wHeader->GetWidth()-VolumeState.length(), 0) << VolumeState;
|
||||
*wHeader << clEnd;
|
||||
*wHeader << NC::XY(wHeader->GetWidth()-VolumeState.length(), 0) << VolumeState;
|
||||
*wHeader << NC::clEnd;
|
||||
}
|
||||
wHeader->Refresh();
|
||||
RedrawHeader = false;
|
||||
@@ -295,10 +294,10 @@ int main(int argc, char **argv)
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
// visualizer sets timeout to 40ms, but since only it needs such small
|
||||
// value, we should restore defalt one after switching to another screen.
|
||||
if (wFooter->GetTimeout() < ncmpcpp_window_timeout
|
||||
if (wFooter->GetTimeout() < 500
|
||||
&& !(myScreen == myVisualizer || myLockedScreen == myVisualizer || myInactiveScreen == myVisualizer)
|
||||
)
|
||||
wFooter->SetTimeout(ncmpcpp_window_timeout);
|
||||
wFooter->SetTimeout(500);
|
||||
# endif // ENABLE_VISUALIZER
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008-2012 by Andrzej Rybczak *
|
||||
* electricityispower@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _NCMPCPP_H
|
||||
#define _NCMPCPP_H
|
||||
|
||||
#include "window.h"
|
||||
#include "menu.h"
|
||||
#include "scrollpad.h"
|
||||
|
||||
using namespace NCurses;
|
||||
using namespace std::placeholders;
|
||||
|
||||
typedef std::pair<std::string, std::string> string_pair;
|
||||
|
||||
const int ncmpcpp_window_timeout = 500;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -33,7 +35,7 @@ Outputs *myOutputs = new Outputs;
|
||||
|
||||
void Outputs::Init()
|
||||
{
|
||||
w = new Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
w->CenteredCursor(Config.centered_cursor);
|
||||
w->HighlightColor(Config.main_highlight_color);
|
||||
@@ -108,7 +110,7 @@ void Outputs::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen< Menu<MPD::Output> >::MouseButtonPressed(me);
|
||||
Screen< NC::Menu<MPD::Output> >::MouseButtonPressed(me);
|
||||
}
|
||||
|
||||
void Outputs::FetchList()
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
#ifndef _OUTPUTS_H
|
||||
#define _OUTPUTS_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ENABLE_OUTPUTS
|
||||
|
||||
@@ -31,7 +29,7 @@
|
||||
#include "mpdpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
class Outputs : public Screen< Menu<MPD::Output> >
|
||||
class Outputs : public Screen< NC::Menu<MPD::Output> >
|
||||
{
|
||||
public:
|
||||
virtual void SwitchTo();
|
||||
@@ -46,7 +44,7 @@ class Outputs : public Screen< Menu<MPD::Output> >
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return w; }
|
||||
virtual NC::List *GetList() { return w; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "status.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
@@ -41,7 +43,7 @@ bool Playlist::ReloadRemaining = false;
|
||||
|
||||
namespace {//
|
||||
|
||||
Menu< std::pair<std::string, MPD::Song::GetFunction> > *SortDialog = 0;
|
||||
NC::Menu< std::pair<std::string, MPD::Song::GetFunction> > *SortDialog = 0;
|
||||
size_t SortDialogHeight;
|
||||
|
||||
const size_t SortOptions = 10;
|
||||
@@ -54,7 +56,7 @@ bool playlistEntryMatcher(const Regex &rx, const MPD::Song &s);
|
||||
|
||||
void Playlist::Init()
|
||||
{
|
||||
Items = new Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, brNone);
|
||||
Items = new NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
|
||||
Items->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Items->CenteredCursor(Config.centered_cursor);
|
||||
Items->HighlightColor(Config.main_highlight_color);
|
||||
@@ -69,7 +71,7 @@ void Playlist::Init()
|
||||
{
|
||||
SortDialogHeight = std::min(int(MainHeight), 17);
|
||||
|
||||
SortDialog = new Menu< std::pair<std::string, MPD::Song::GetFunction> >((COLS-SortDialogWidth)/2, (MainHeight-SortDialogHeight)/2+MainStartY, SortDialogWidth, SortDialogHeight, "Sort songs by...", Config.main_color, Config.window_border);
|
||||
SortDialog = new NC::Menu< std::pair<std::string, MPD::Song::GetFunction> >((COLS-SortDialogWidth)/2, (MainHeight-SortDialogHeight)/2+MainStartY, SortDialogWidth, SortDialogHeight, "Sort songs by...", Config.main_color, Config.window_border);
|
||||
SortDialog->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
SortDialog->CenteredCursor(Config.centered_cursor);
|
||||
SortDialog->setItemDisplayer(Display::Pair<std::string, MPD::Song::GetFunction>);
|
||||
@@ -239,7 +241,7 @@ void Playlist::SpacePressed()
|
||||
if (w == Items && !Items->Empty())
|
||||
{
|
||||
Items->Current().setSelected(!Items->Current().isSelected());
|
||||
Items->Scroll(wDown);
|
||||
Items->Scroll(NC::wDown);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +256,7 @@ void Playlist::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
else if (w == SortDialog && SortDialog->hasCoords(me.x, me.y))
|
||||
{
|
||||
@@ -265,7 +267,7 @@ void Playlist::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +409,7 @@ void Playlist::MoveSelectedItems(Movement where)
|
||||
if (pos > 0)
|
||||
{
|
||||
if (Mpd.Move(pos-1, pos))
|
||||
Items->Scroll(wUp);
|
||||
Items->Scroll(NC::wUp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -439,7 +441,7 @@ void Playlist::MoveSelectedItems(Movement where)
|
||||
if (pos < Items->Size()-1)
|
||||
{
|
||||
if (Mpd.Move(pos, pos+1))
|
||||
Items->Scroll(wDown);
|
||||
Items->Scroll(NC::wDown);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -497,7 +499,7 @@ void Playlist::AdjustSortOrder(Movement where)
|
||||
if (pos > 0 && pos < SortOptions)
|
||||
{
|
||||
SortDialog->Swap(pos, pos-1);
|
||||
SortDialog->Scroll(wUp);
|
||||
SortDialog->Scroll(NC::wUp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -507,7 +509,7 @@ void Playlist::AdjustSortOrder(Movement where)
|
||||
if (pos < SortOptions-1)
|
||||
{
|
||||
SortDialog->Swap(pos, pos+1);
|
||||
SortDialog->Scroll(wDown);
|
||||
SortDialog->Scroll(NC::wDown);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,10 @@
|
||||
#define _PLAYLIST_H
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
|
||||
class Playlist : public Screen<Window>, public Filterable, public HasSongs, public Searchable
|
||||
class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
public:
|
||||
enum Movement { mUp, mDown };
|
||||
@@ -62,7 +61,7 @@ class Playlist : public Screen<Window>, public Filterable, public HasSongs, publ
|
||||
virtual void removeSelection();
|
||||
virtual MPD::SongList getSelectedSongs();
|
||||
|
||||
virtual List *GetList() { return w == Items ? Items : 0; }
|
||||
virtual NC::List *GetList() { return w == Items ? Items : 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
@@ -92,7 +91,7 @@ class Playlist : public Screen<Window>, public Filterable, public HasSongs, publ
|
||||
//static std::string SongToString(const MPD::Song &s);
|
||||
//static std::string SongInColumnsToString(const MPD::Song &s);
|
||||
|
||||
Menu< MPD::Song > *Items;
|
||||
NC::Menu< MPD::Song > *Items;
|
||||
|
||||
int NowPlaying;
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "tag_editor.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
@@ -56,7 +58,7 @@ void PlaylistEditor::Init()
|
||||
RightColumnStartX = LeftColumnWidth+1;
|
||||
RightColumnWidth = COLS-LeftColumnWidth-1;
|
||||
|
||||
Playlists = new Menu<std::string>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Playlists" : "", Config.main_color, brNone);
|
||||
Playlists = new NC::Menu<std::string>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Playlists" : "", Config.main_color, NC::brNone);
|
||||
Playlists->HighlightColor(Config.active_column_color);
|
||||
Playlists->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Playlists->CenteredCursor(Config.centered_cursor);
|
||||
@@ -64,7 +66,7 @@ void PlaylistEditor::Init()
|
||||
Playlists->SetSelectSuffix(Config.selected_item_suffix);
|
||||
Playlists->setItemDisplayer(Display::Default<std::string>);
|
||||
|
||||
Content = new Menu<MPD::Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Playlist content" : "", Config.main_color, brNone);
|
||||
Content = new NC::Menu<MPD::Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Playlist content" : "", Config.main_color, NC::brNone);
|
||||
Content->HighlightColor(Config.main_highlight_color);
|
||||
Content->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Content->CenteredCursor(Config.centered_cursor);
|
||||
@@ -183,7 +185,7 @@ void PlaylistEditor::Update()
|
||||
|
||||
if (Content->ReallyEmpty())
|
||||
{
|
||||
*Content << XY(0, 0) << "Playlist is empty.";
|
||||
*Content << NC::XY(0, 0) << "Playlist is empty.";
|
||||
Content->Window::Refresh();
|
||||
}
|
||||
}
|
||||
@@ -227,7 +229,7 @@ void PlaylistEditor::MoveSelectedItems(Playlist::Movement where)
|
||||
{
|
||||
if (Mpd.Move(Playlists->Current().value(), pos-1, pos))
|
||||
{
|
||||
Content->Scroll(wUp);
|
||||
Content->Scroll(NC::wUp);
|
||||
Content->Swap(pos-1, pos);
|
||||
}
|
||||
}
|
||||
@@ -262,7 +264,7 @@ void PlaylistEditor::MoveSelectedItems(Playlist::Movement where)
|
||||
{
|
||||
if (Mpd.Move(Playlists->Current().value(), pos, pos+1))
|
||||
{
|
||||
Content->Scroll(wDown);
|
||||
Content->Scroll(NC::wDown);
|
||||
Content->Swap(pos, pos+1);
|
||||
}
|
||||
}
|
||||
@@ -349,7 +351,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
||||
}
|
||||
|
||||
if (!add_n_play)
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
|
||||
void PlaylistEditor::SpacePressed()
|
||||
@@ -361,7 +363,7 @@ void PlaylistEditor::SpacePressed()
|
||||
if (!Playlists->Empty())
|
||||
{
|
||||
Playlists->Current().setSelected(!Playlists->Current().isSelected());
|
||||
Playlists->Scroll(wDown);
|
||||
Playlists->Scroll(NC::wDown);
|
||||
}
|
||||
}
|
||||
else if (w == Content)
|
||||
@@ -369,7 +371,7 @@ void PlaylistEditor::SpacePressed()
|
||||
if (!Content->Empty())
|
||||
{
|
||||
Content->Current().setSelected(!Content->Current().isSelected());
|
||||
Content->Scroll(wDown);
|
||||
Content->Scroll(NC::wDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,11 +393,11 @@ void PlaylistEditor::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = Playlists->Choice();
|
||||
SpacePressed();
|
||||
if (pos < Playlists->Size()-1)
|
||||
Playlists->Scroll(wUp);
|
||||
Playlists->Scroll(NC::wUp);
|
||||
}
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
Content->Clear();
|
||||
}
|
||||
else if (!Content->Empty() && Content->hasCoords(me.x, me.y))
|
||||
@@ -410,13 +412,13 @@ void PlaylistEditor::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = Content->Choice();
|
||||
SpacePressed();
|
||||
if (pos < Content->Size()-1)
|
||||
Content->Scroll(wUp);
|
||||
Content->Scroll(NC::wUp);
|
||||
}
|
||||
else
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,7 +578,7 @@ void PlaylistEditor::Locate(const std::string &name)
|
||||
SwitchTo();
|
||||
}
|
||||
|
||||
List *PlaylistEditor::GetList()
|
||||
NC::List *PlaylistEditor::GetList()
|
||||
{
|
||||
if (w == Playlists)
|
||||
return Playlists;
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
#define _PLAYLIST_EDITOR_H
|
||||
|
||||
#include "playlist.h"
|
||||
#include "ncmpcpp.h"
|
||||
|
||||
class PlaylistEditor : public Screen<Window>, public Filterable, public HasSongs, public Searchable
|
||||
class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
public:
|
||||
virtual void SwitchTo();
|
||||
@@ -60,7 +59,7 @@ class PlaylistEditor : public Screen<Window>, public Filterable, public HasSongs
|
||||
|
||||
virtual void Locate(const std::string &);
|
||||
|
||||
virtual List *GetList();
|
||||
virtual NC::List *GetList();
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
@@ -72,8 +71,8 @@ class PlaylistEditor : public Screen<Window>, public Filterable, public HasSongs
|
||||
bool isPrevColumnAvailable();
|
||||
bool PrevColumn();
|
||||
|
||||
Menu<std::string> *Playlists;
|
||||
Menu<MPD::Song> *Content;
|
||||
NC::Menu<std::string> *Playlists;
|
||||
NC::Menu<MPD::Song> *Content;
|
||||
|
||||
protected:
|
||||
virtual void Init();
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
template <typename T> struct RegexFilter
|
||||
{
|
||||
typedef NCurses::Menu<T> MenuT;
|
||||
typedef typename NCurses::Menu<T>::Item Item;
|
||||
typedef NC::Menu<T> MenuT;
|
||||
typedef typename NC::Menu<T>::Item Item;
|
||||
typedef std::function<bool(const Regex &, const T &)> FilterFunction;
|
||||
|
||||
RegexFilter(const std::string ®ex_, int cflags, FilterFunction filter)
|
||||
@@ -56,8 +56,8 @@ private:
|
||||
|
||||
template <typename T> struct RegexItemFilter
|
||||
{
|
||||
typedef NCurses::Menu<T> MenuT;
|
||||
typedef typename NCurses::Menu<T>::Item Item;
|
||||
typedef NC::Menu<T> MenuT;
|
||||
typedef typename NC::Menu<T>::Item Item;
|
||||
typedef std::function<bool(const Regex &, const Item &)> FilterFunction;
|
||||
|
||||
RegexItemFilter(const std::string ®ex_, int cflags, FilterFunction filter)
|
||||
|
||||
146
src/screen.cpp
146
src/screen.cpp
@@ -20,24 +20,110 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "screen.h"
|
||||
#include "global.h"
|
||||
#include "screen.h"
|
||||
#include "settings.h"
|
||||
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
using Global::myInactiveScreen;
|
||||
|
||||
namespace
|
||||
namespace {//
|
||||
|
||||
void DrawScreenSeparator(int x)
|
||||
{
|
||||
void DrawScreenSeparator(int x)
|
||||
attron(COLOR_PAIR(Config.main_color));
|
||||
mvvline(Global::MainStartY, x, 0, Global::MainHeight);
|
||||
attroff(COLOR_PAIR(Config.main_color));
|
||||
refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GenericMouseButtonPressed(NC::Window *w, MEVENT me)
|
||||
{
|
||||
if (me.bstate & BUTTON2_PRESSED)
|
||||
{
|
||||
attron(COLOR_PAIR(Config.main_color));
|
||||
mvvline(Global::MainStartY, x, 0, Global::MainHeight);
|
||||
attroff(COLOR_PAIR(Config.main_color));
|
||||
refresh();
|
||||
if (Config.mouse_list_scroll_whole_page)
|
||||
w->Scroll(NC::wPageDown);
|
||||
else
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
else if (me.bstate & BUTTON4_PRESSED)
|
||||
{
|
||||
if (Config.mouse_list_scroll_whole_page)
|
||||
w->Scroll(NC::wPageUp);
|
||||
else
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
w->Scroll(NC::wUp);
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollpadMouseButtonPressed(NC::Scrollpad *w, MEVENT me)
|
||||
{
|
||||
if (me.bstate & BUTTON2_PRESSED)
|
||||
{
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
else if (me.bstate & BUTTON4_PRESSED)
|
||||
{
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
w->Scroll(NC::wUp);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void BasicScreen::GetWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen)
|
||||
{
|
||||
width = COLS;
|
||||
x_offset = 0;
|
||||
if (myLockedScreen && myInactiveScreen)
|
||||
{
|
||||
size_t locked_width = COLS*Config.locked_screen_width_part;
|
||||
if (myLockedScreen == this)
|
||||
width = locked_width;
|
||||
else
|
||||
{
|
||||
width = COLS-locked_width-1;
|
||||
x_offset = locked_width+1;
|
||||
|
||||
if (adjust_locked_screen)
|
||||
{
|
||||
myLockedScreen->Resize();
|
||||
myLockedScreen->Refresh();
|
||||
DrawScreenSeparator(x_offset-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BasicScreen::Lock()
|
||||
{
|
||||
if (myLockedScreen)
|
||||
return false;
|
||||
if (isLockable())
|
||||
{
|
||||
myLockedScreen = this;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void BasicScreen::Unlock()
|
||||
{
|
||||
if (myInactiveScreen && myInactiveScreen != myLockedScreen)
|
||||
myScreen = myInactiveScreen;
|
||||
myLockedScreen->SwitchTo();
|
||||
myLockedScreen = 0;
|
||||
myInactiveScreen = 0;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
void ApplyToVisibleWindows(void (BasicScreen::*f)())
|
||||
{
|
||||
if (myLockedScreen && myScreen->isMergable())
|
||||
@@ -85,49 +171,3 @@ bool isVisible(BasicScreen *screen)
|
||||
else
|
||||
return screen == myScreen;
|
||||
}
|
||||
|
||||
void BasicScreen::GetWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen)
|
||||
{
|
||||
width = COLS;
|
||||
x_offset = 0;
|
||||
if (myLockedScreen && myInactiveScreen)
|
||||
{
|
||||
size_t locked_width = COLS*Config.locked_screen_width_part;
|
||||
if (myLockedScreen == this)
|
||||
width = locked_width;
|
||||
else
|
||||
{
|
||||
width = COLS-locked_width-1;
|
||||
x_offset = locked_width+1;
|
||||
|
||||
if (adjust_locked_screen)
|
||||
{
|
||||
myLockedScreen->Resize();
|
||||
myLockedScreen->Refresh();
|
||||
DrawScreenSeparator(x_offset-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BasicScreen::Lock()
|
||||
{
|
||||
if (myLockedScreen)
|
||||
return false;
|
||||
if (isLockable())
|
||||
{
|
||||
myLockedScreen = this;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void BasicScreen::Unlock()
|
||||
{
|
||||
if (myInactiveScreen && myInactiveScreen != myLockedScreen)
|
||||
myScreen = myInactiveScreen;
|
||||
myLockedScreen->SwitchTo();
|
||||
myLockedScreen = 0;
|
||||
myInactiveScreen = 0;
|
||||
}
|
||||
|
||||
59
src/screen.h
59
src/screen.h
@@ -21,16 +21,11 @@
|
||||
#ifndef _SCREEN_H
|
||||
#define _SCREEN_H
|
||||
|
||||
#include "window.h"
|
||||
#include "menu.h"
|
||||
#include "mpdpp.h"
|
||||
#include "helpers.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "scrollpad.h"
|
||||
|
||||
void ApplyToVisibleWindows(void (BasicScreen::*f)());
|
||||
void UpdateInactiveScreen(BasicScreen *);
|
||||
bool isVisible(BasicScreen *);
|
||||
void GenericMouseButtonPressed(NC::Window *w, MEVENT me);
|
||||
void ScrollpadMouseButtonPressed(NC::Scrollpad *w, MEVENT me);
|
||||
|
||||
/// An interface for various instantiations of Screen template class. Since C++ doesn't like
|
||||
/// comparison of two different instantiations of the same template class we need the most
|
||||
@@ -46,7 +41,7 @@ class BasicScreen
|
||||
virtual ~BasicScreen() { }
|
||||
|
||||
/// @see Screen::ActiveWindow()
|
||||
virtual Window *ActiveWindow() = 0;
|
||||
virtual NC::Window *ActiveWindow() = 0;
|
||||
|
||||
/// Method used for switching to screen
|
||||
virtual void SwitchTo() = 0;
|
||||
@@ -69,7 +64,7 @@ class BasicScreen
|
||||
virtual void RefreshWindow() = 0;
|
||||
|
||||
/// @see Screen::Scroll()
|
||||
virtual void Scroll(Where where) = 0;
|
||||
virtual void Scroll(NC::Where where) = 0;
|
||||
|
||||
/// Invoked after Enter was pressed
|
||||
virtual void EnterPressed() = 0;
|
||||
@@ -82,7 +77,7 @@ class BasicScreen
|
||||
|
||||
/// @return pointer to instantiation of Menu template class
|
||||
/// cast to List if available or null pointer otherwise
|
||||
virtual List *GetList() = 0;
|
||||
virtual NC::List *GetList() = 0;
|
||||
|
||||
/// When this is overwritten with a function returning true, the
|
||||
/// screen will be used in tab switching.
|
||||
@@ -129,6 +124,10 @@ class BasicScreen
|
||||
bool isInitialized;
|
||||
};
|
||||
|
||||
void ApplyToVisibleWindows(void (BasicScreen::*f)());
|
||||
void UpdateInactiveScreen(BasicScreen *screen_to_be_set);
|
||||
bool isVisible(BasicScreen *screen);
|
||||
|
||||
/// Class that all screens should derive from. It provides basic interface
|
||||
/// for the screen to be working properly and assumes that we didn't forget
|
||||
/// about anything vital.
|
||||
@@ -143,7 +142,7 @@ template <typename WindowType> class Screen : public BasicScreen
|
||||
/// it's useful to determine the one that is being
|
||||
/// active
|
||||
/// @return address to window object cast to void *
|
||||
virtual Window *ActiveWindow();
|
||||
virtual NC::Window *ActiveWindow();
|
||||
|
||||
/// @return pointer to currently active window
|
||||
WindowType *Main();
|
||||
@@ -158,7 +157,7 @@ template <typename WindowType> class Screen : public BasicScreen
|
||||
/// if fancy scrolling feature is disabled, enters the
|
||||
/// loop that holds main loop until user releases the key
|
||||
/// @param where indicates where one wants to scroll
|
||||
virtual void Scroll(Where where);
|
||||
virtual void Scroll(NC::Where where);
|
||||
|
||||
/// Invoked after there was one of mouse buttons pressed
|
||||
/// @param me struct that contains coords of where the click
|
||||
@@ -173,7 +172,7 @@ template <typename WindowType> class Screen : public BasicScreen
|
||||
WindowType *w;
|
||||
};
|
||||
|
||||
template <typename WindowType> Window *Screen<WindowType>::ActiveWindow()
|
||||
template <typename WindowType> NC::Window *Screen<WindowType>::ActiveWindow()
|
||||
{
|
||||
return w;
|
||||
}
|
||||
@@ -193,46 +192,22 @@ template <typename WindowType> void Screen<WindowType>::RefreshWindow()
|
||||
w->Display();
|
||||
}
|
||||
|
||||
template <typename WindowType> void Screen<WindowType>::Scroll(Where where)
|
||||
template <typename WindowType> void Screen<WindowType>::Scroll(NC::Where where)
|
||||
{
|
||||
w->Scroll(where);
|
||||
}
|
||||
|
||||
template <typename WindowType> void Screen<WindowType>::MouseButtonPressed(MEVENT me)
|
||||
{
|
||||
if (me.bstate & BUTTON2_PRESSED)
|
||||
{
|
||||
if (Config.mouse_list_scroll_whole_page)
|
||||
Scroll(wPageDown);
|
||||
else
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
Scroll(wDown);
|
||||
}
|
||||
else if (me.bstate & BUTTON4_PRESSED)
|
||||
{
|
||||
if (Config.mouse_list_scroll_whole_page)
|
||||
Scroll(wPageUp);
|
||||
else
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
Scroll(wUp);
|
||||
}
|
||||
GenericMouseButtonPressed(w, me);
|
||||
}
|
||||
|
||||
/// Specialization for Screen<Scrollpad>::MouseButtonPressed, that should
|
||||
/// not scroll whole page, but rather a few lines (the number of them is
|
||||
/// defined in the config)
|
||||
template <> inline void Screen<Scrollpad>::MouseButtonPressed(MEVENT me)
|
||||
template <> inline void Screen<NC::Scrollpad>::MouseButtonPressed(MEVENT me)
|
||||
{
|
||||
if (me.bstate & BUTTON2_PRESSED)
|
||||
{
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
Scroll(wDown);
|
||||
}
|
||||
else if (me.bstate & BUTTON4_PRESSED)
|
||||
{
|
||||
for (size_t i = 0; i < Config.lines_scrolled; ++i)
|
||||
Scroll(wUp);
|
||||
}
|
||||
ScrollpadMouseButtonPressed(w, me);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "scrollpad.h"
|
||||
|
||||
using namespace NCurses;
|
||||
namespace NC {//
|
||||
|
||||
Scrollpad::Scrollpad(size_t startx,
|
||||
size_t starty,
|
||||
@@ -208,3 +208,4 @@ Scrollpad &Scrollpad::operator<<(const std::string &s)
|
||||
}
|
||||
#endif // _UTF8
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "window.h"
|
||||
#include "strbuffer.h"
|
||||
|
||||
namespace NCurses
|
||||
namespace NC
|
||||
{
|
||||
/// Scrollpad is specialized window that can hold large portion of text and
|
||||
/// supports scrolling if the amount of it is bigger than the window area.
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "status.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
@@ -66,7 +68,7 @@ namespace pos {//
|
||||
}*/
|
||||
|
||||
std::string SEItemToString(const SEItem &ei);
|
||||
bool SEItemEntryMatcher(const Regex &rx, const Menu<SEItem>::Item &item, bool filter);
|
||||
bool SEItemEntryMatcher(const Regex &rx, const NC::Menu<SEItem>::Item &item, bool filter);
|
||||
|
||||
}
|
||||
|
||||
@@ -99,7 +101,7 @@ size_t SearchEngine::SearchButton = 15;
|
||||
|
||||
void SearchEngine::Init()
|
||||
{
|
||||
w = new Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w->HighlightColor(Config.main_highlight_color);
|
||||
w->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
w->CenteredCursor(Config.centered_cursor);
|
||||
@@ -150,7 +152,7 @@ void SearchEngine::SwitchTo()
|
||||
|
||||
if (!w->Back().value().isSong())
|
||||
{
|
||||
*w << XY(0, 0) << "Updating list...";
|
||||
*w << NC::XY(0, 0) << "Updating list...";
|
||||
UpdateFoundList();
|
||||
}
|
||||
}
|
||||
@@ -171,23 +173,23 @@ void SearchEngine::EnterPressed()
|
||||
if (option < ConstraintsNumber)
|
||||
{
|
||||
std::string constraint = ConstraintsNames[option];
|
||||
Statusbar() << fmtBold << constraint << fmtBoldEnd << ": ";
|
||||
Statusbar() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
|
||||
itsConstraints[option] = Global::wFooter->GetString(itsConstraints[option]);
|
||||
w->Current().value().buffer().Clear();
|
||||
constraint.resize(13, ' ');
|
||||
w->Current().value().buffer() << fmtBold << constraint << fmtBoldEnd << ": ";
|
||||
w->Current().value().buffer() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
|
||||
ShowTag(w->Current().value().buffer(), itsConstraints[option]);
|
||||
}
|
||||
else if (option == ConstraintsNumber+1)
|
||||
{
|
||||
Config.search_in_db = !Config.search_in_db;
|
||||
w->Current().value().buffer() << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
||||
w->Current().value().buffer() << NC::fmtBold << "Search in:" << NC::fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
||||
}
|
||||
else if (option == ConstraintsNumber+2)
|
||||
{
|
||||
if (!*++SearchMode)
|
||||
SearchMode = &SearchModes[0];
|
||||
w->Current().value().buffer() << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << *SearchMode;
|
||||
w->Current().value().buffer() << NC::fmtBold << "Search mode:" << NC::fmtBoldEnd << ' ' << *SearchMode;
|
||||
}
|
||||
else if (option == SearchButton)
|
||||
{
|
||||
@@ -204,15 +206,15 @@ void SearchEngine::EnterPressed()
|
||||
found += 3; // don't count options inserted below
|
||||
w->InsertSeparator(ResetButton+1);
|
||||
w->InsertItem(ResetButton+2, SEItem(), 1, 1);
|
||||
w->at(ResetButton+2).value().mkBuffer() << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault;
|
||||
w->at(ResetButton+2).value().mkBuffer() << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << NC::clDefault;
|
||||
w->InsertSeparator(ResetButton+3);
|
||||
UpdateFoundList();
|
||||
ShowMessage("Searching finished");
|
||||
if (Config.block_search_constraints_change)
|
||||
for (size_t i = 0; i < StaticOptions-4; ++i)
|
||||
w->at(i).setInactive(true);
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
else
|
||||
ShowMessage("No results found");
|
||||
@@ -239,13 +241,13 @@ void SearchEngine::SpacePressed()
|
||||
if (Config.space_selects)
|
||||
{
|
||||
w->Current().setSelected(!w->Current().isSelected());
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
return;
|
||||
}
|
||||
|
||||
bool res = myPlaylist->Add(w->Current().value().song(), w->Current().isBold(), 0);
|
||||
w->Current().setBold(res);
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
}
|
||||
|
||||
void SearchEngine::MouseButtonPressed(MEVENT me)
|
||||
@@ -266,14 +268,14 @@ void SearchEngine::MouseButtonPressed(MEVENT me)
|
||||
size_t pos = w->Choice();
|
||||
SpacePressed();
|
||||
if (pos < w->Size()-1)
|
||||
w->Scroll(wUp);
|
||||
w->Scroll(NC::wUp);
|
||||
}
|
||||
else
|
||||
EnterPressed();
|
||||
}
|
||||
}
|
||||
else
|
||||
Screen< Menu<SEItem> >::MouseButtonPressed(me);
|
||||
Screen< NC::Menu<SEItem> >::MouseButtonPressed(me);
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -386,12 +388,12 @@ void SearchEngine::Prepare()
|
||||
{
|
||||
std::string constraint = ConstraintsNames[i];
|
||||
constraint.resize(13, ' ');
|
||||
(*w)[i].value().mkBuffer() << fmtBold << constraint << fmtBoldEnd << ": ";
|
||||
(*w)[i].value().mkBuffer() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
|
||||
ShowTag((*w)[i].value().buffer(), itsConstraints[i]);
|
||||
}
|
||||
|
||||
w->at(ConstraintsNumber+1).value().mkBuffer() << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
||||
w->at(ConstraintsNumber+2).value().mkBuffer() << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << *SearchMode;
|
||||
w->at(ConstraintsNumber+1).value().mkBuffer() << NC::fmtBold << "Search in:" << NC::fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
||||
w->at(ConstraintsNumber+2).value().mkBuffer() << NC::fmtBold << "Search mode:" << NC::fmtBoldEnd << ' ' << *SearchMode;
|
||||
|
||||
w->at(SearchButton).value().mkBuffer() << "Search";
|
||||
w->at(ResetButton).value().mkBuffer() << "Reset";
|
||||
@@ -615,7 +617,7 @@ std::string SEItemToString(const SEItem &ei)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SEItemEntryMatcher(const Regex &rx, const Menu<SEItem>::Item &item, bool filter)
|
||||
bool SEItemEntryMatcher(const Regex &rx, const NC::Menu<SEItem>::Item &item, bool filter)
|
||||
{
|
||||
if (item.isSeparator() || !item.value().isSong())
|
||||
return filter;
|
||||
|
||||
@@ -25,13 +25,12 @@
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "mpdpp.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct SEItem
|
||||
{
|
||||
SEItem() : isThisSong(false), itsBuffer(0) { }
|
||||
SEItem(Buffer *buf) : isThisSong(false), itsBuffer(buf) { }
|
||||
SEItem(NC::Buffer *buf) : isThisSong(false), itsBuffer(buf) { }
|
||||
SEItem(const MPD::Song &s) : isThisSong(true), itsSong(s) { }
|
||||
SEItem(const SEItem &ei) { *this = ei; }
|
||||
~SEItem() {
|
||||
@@ -39,19 +38,19 @@ struct SEItem
|
||||
delete itsBuffer;
|
||||
}
|
||||
|
||||
Buffer &mkBuffer() {
|
||||
NC::Buffer &mkBuffer() {
|
||||
assert(!isThisSong);
|
||||
delete itsBuffer;
|
||||
itsBuffer = new Buffer();
|
||||
itsBuffer = new NC::Buffer();
|
||||
return *itsBuffer;
|
||||
}
|
||||
|
||||
bool isSong() const { return isThisSong; }
|
||||
|
||||
Buffer &buffer() { assert(!isThisSong && itsBuffer); return *itsBuffer; }
|
||||
NC::Buffer &buffer() { assert(!isThisSong && itsBuffer); return *itsBuffer; }
|
||||
MPD::Song &song() { assert(isThisSong); return itsSong; }
|
||||
|
||||
const Buffer &buffer() const { assert(!isThisSong && itsBuffer); return *itsBuffer; }
|
||||
const NC::Buffer &buffer() const { assert(!isThisSong && itsBuffer); return *itsBuffer; }
|
||||
const MPD::Song &song() const { assert(isThisSong); return itsSong; }
|
||||
|
||||
SEItem &operator=(const SEItem &se) {
|
||||
@@ -61,7 +60,7 @@ struct SEItem
|
||||
if (se.isThisSong)
|
||||
itsSong = se.itsSong;
|
||||
else if (se.itsBuffer)
|
||||
itsBuffer = new Buffer(*se.itsBuffer);
|
||||
itsBuffer = new NC::Buffer(*se.itsBuffer);
|
||||
else
|
||||
itsBuffer = 0;
|
||||
return *this;
|
||||
@@ -70,11 +69,11 @@ struct SEItem
|
||||
private:
|
||||
bool isThisSong;
|
||||
|
||||
Buffer *itsBuffer;
|
||||
NC::Buffer *itsBuffer;
|
||||
MPD::Song itsSong;
|
||||
};
|
||||
|
||||
class SearchEngine : public Screen< Menu<SEItem> >, public Filterable, public HasSongs, public Searchable
|
||||
class SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
public:
|
||||
virtual void Resize();
|
||||
@@ -105,7 +104,7 @@ class SearchEngine : public Screen< Menu<SEItem> >, public Filterable, public Ha
|
||||
virtual void removeSelection();
|
||||
virtual MPD::SongList getSelectedSongs();
|
||||
|
||||
virtual List *GetList() { return w->Size() >= StaticOptions ? w : 0; }
|
||||
virtual NC::List *GetList() { return w->Size() >= StaticOptions ? w : 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "playlist.h"
|
||||
#include "playlist_editor.h"
|
||||
#include "sel_items_adder.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
@@ -39,13 +41,13 @@ SelectedItemsAdder *mySelectedItemsAdder = new SelectedItemsAdder;
|
||||
void SelectedItemsAdder::Init()
|
||||
{
|
||||
SetDimensions();
|
||||
itsPlaylistSelector = new Menu<std::string>((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "Add selected item(s) to...", Config.main_color, Config.window_border);
|
||||
itsPlaylistSelector = new NC::Menu<std::string>((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "Add selected item(s) to...", Config.main_color, Config.window_border);
|
||||
itsPlaylistSelector->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
itsPlaylistSelector->CenteredCursor(Config.centered_cursor);
|
||||
itsPlaylistSelector->HighlightColor(Config.main_highlight_color);
|
||||
itsPlaylistSelector->setItemDisplayer(Display::Default<std::string>);
|
||||
|
||||
itsPositionSelector = new Menu<std::string>((COLS-itsPSWidth)/2, (MainHeight-itsPSHeight)/2+MainStartY, itsPSWidth, itsPSHeight, "Where?", Config.main_color, Config.window_border);
|
||||
itsPositionSelector = new NC::Menu<std::string>((COLS-itsPSWidth)/2, (MainHeight-itsPSHeight)/2+MainStartY, itsPSWidth, itsPSHeight, "Where?", Config.main_color, Config.window_border);
|
||||
itsPositionSelector->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
itsPositionSelector->CenteredCursor(Config.centered_cursor);
|
||||
itsPositionSelector->HighlightColor(Config.main_highlight_color);
|
||||
@@ -259,7 +261,7 @@ void SelectedItemsAdder::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen< Menu<std::string> >::MouseButtonPressed(me);
|
||||
Screen< NC::Menu<std::string> >::MouseButtonPressed(me);
|
||||
}
|
||||
|
||||
void SelectedItemsAdder::SetDimensions()
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
#ifndef _SEL_ITEMS_ADDER_H
|
||||
#define _SEL_ITEMS_ADDER_H
|
||||
|
||||
#include "ncmpcpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
class SelectedItemsAdder : public Screen< Menu<std::string> >
|
||||
class SelectedItemsAdder : public Screen< NC::Menu<std::string> >
|
||||
{
|
||||
public:
|
||||
SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { }
|
||||
@@ -41,7 +40,7 @@ class SelectedItemsAdder : public Screen< Menu<std::string> >
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return w; }
|
||||
virtual NC::List *GetList() { return w; }
|
||||
|
||||
virtual bool isMergable() { return false; }
|
||||
|
||||
@@ -52,8 +51,8 @@ class SelectedItemsAdder : public Screen< Menu<std::string> >
|
||||
private:
|
||||
void SetDimensions();
|
||||
|
||||
Menu<std::string> *itsPlaylistSelector;
|
||||
Menu<std::string> *itsPositionSelector;
|
||||
NC::Menu<std::string> *itsPlaylistSelector;
|
||||
NC::Menu<std::string> *itsPositionSelector;
|
||||
|
||||
size_t itsPSWidth;
|
||||
size_t itsPSHeight;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <iomanip>
|
||||
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "server_info.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
@@ -33,7 +34,7 @@ ServerInfo *myServerInfo = new ServerInfo;
|
||||
void ServerInfo::Init()
|
||||
{
|
||||
SetDimensions();
|
||||
w = new Scrollpad((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "MPD server info", Config.main_color, Config.window_border);
|
||||
w = new NC::Scrollpad((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "MPD server info", Config.main_color, Config.window_border);
|
||||
|
||||
itsURLHandlers = Mpd.GetURLHandlers();
|
||||
itsTagTypes = Mpd.GetTagTypes();
|
||||
@@ -99,26 +100,26 @@ void ServerInfo::Update()
|
||||
Mpd.UpdateStats();
|
||||
w->Clear();
|
||||
|
||||
*w << fmtBold << U("Version: ") << fmtBoldEnd << U("0.") << Mpd.Version() << U(".*\n");
|
||||
*w << fmtBold << U("Uptime: ") << fmtBoldEnd;
|
||||
*w << NC::fmtBold << U("Version: ") << NC::fmtBoldEnd << U("0.") << Mpd.Version() << U(".*\n");
|
||||
*w << NC::fmtBold << U("Uptime: ") << NC::fmtBoldEnd;
|
||||
ShowTime(*w, Mpd.Uptime(), 1);
|
||||
*w << '\n';
|
||||
*w << fmtBold << U("Time playing: ") << fmtBoldEnd << MPD::Song::ShowTime(Mpd.PlayTime()) << '\n';
|
||||
*w << NC::fmtBold << U("Time playing: ") << NC::fmtBoldEnd << MPD::Song::ShowTime(Mpd.PlayTime()) << '\n';
|
||||
*w << '\n';
|
||||
*w << fmtBold << U("Total playtime: ") << fmtBoldEnd;
|
||||
*w << NC::fmtBold << U("Total playtime: ") << NC::fmtBoldEnd;
|
||||
ShowTime(*w, Mpd.DBPlayTime(), 1);
|
||||
*w << '\n';
|
||||
*w << fmtBold << U("Artist names: ") << fmtBoldEnd << Mpd.NumberOfArtists() << '\n';
|
||||
*w << fmtBold << U("Album names: ") << fmtBoldEnd << Mpd.NumberOfAlbums() << '\n';
|
||||
*w << fmtBold << U("Songs in database: ") << fmtBoldEnd << Mpd.NumberOfSongs() << '\n';
|
||||
*w << NC::fmtBold << U("Artist names: ") << NC::fmtBoldEnd << Mpd.NumberOfArtists() << '\n';
|
||||
*w << NC::fmtBold << U("Album names: ") << NC::fmtBoldEnd << Mpd.NumberOfAlbums() << '\n';
|
||||
*w << NC::fmtBold << U("Songs in database: ") << NC::fmtBoldEnd << Mpd.NumberOfSongs() << '\n';
|
||||
*w << '\n';
|
||||
*w << fmtBold << U("Last DB update: ") << fmtBoldEnd << Timestamp(Mpd.DBUpdateTime()) << '\n';
|
||||
*w << NC::fmtBold << U("Last DB update: ") << NC::fmtBoldEnd << Timestamp(Mpd.DBUpdateTime()) << '\n';
|
||||
*w << '\n';
|
||||
*w << fmtBold << U("URL Handlers:") << fmtBoldEnd;
|
||||
*w << NC::fmtBold << U("URL Handlers:") << NC::fmtBoldEnd;
|
||||
for (auto it = itsURLHandlers.begin(); it != itsURLHandlers.end(); ++it)
|
||||
*w << (it != itsURLHandlers.begin() ? U(", ") : U(" ")) << *it;
|
||||
*w << U("\n\n");
|
||||
*w << fmtBold << U("Tag Types:") << fmtBoldEnd;
|
||||
*w << NC::fmtBold << U("Tag Types:") << NC::fmtBoldEnd;
|
||||
for (auto it = itsTagTypes.begin(); it != itsTagTypes.end(); ++it)
|
||||
*w << (it != itsTagTypes.begin() ? U(", ") : U(" ")) << *it;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
class ServerInfo : public Screen<Scrollpad>
|
||||
class ServerInfo : public Screen<NC::Scrollpad>
|
||||
{
|
||||
public:
|
||||
virtual void SwitchTo();
|
||||
@@ -38,7 +38,7 @@ class ServerInfo : public Screen<Scrollpad>
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return false; }
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
#endif // WIN32
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
@@ -58,33 +59,33 @@ KeyConfiguration Keys;
|
||||
|
||||
namespace
|
||||
{
|
||||
NCurses::Color stringToColor(const std::string &color)
|
||||
NC::Color stringToColor(const std::string &color)
|
||||
{
|
||||
NCurses::Color result = NCurses::clDefault;
|
||||
NC::Color result = NC::clDefault;
|
||||
|
||||
if (color == "black")
|
||||
result = NCurses::clBlack;
|
||||
result = NC::clBlack;
|
||||
else if (color == "red")
|
||||
result = NCurses::clRed;
|
||||
result = NC::clRed;
|
||||
else if (color == "green")
|
||||
result = NCurses::clGreen;
|
||||
result = NC::clGreen;
|
||||
else if (color == "yellow")
|
||||
result = NCurses::clYellow;
|
||||
result = NC::clYellow;
|
||||
else if (color == "blue")
|
||||
result = NCurses::clBlue;
|
||||
result = NC::clBlue;
|
||||
else if (color == "magenta")
|
||||
result = NCurses::clMagenta;
|
||||
result = NC::clMagenta;
|
||||
else if (color == "cyan")
|
||||
result = NCurses::clCyan;
|
||||
result = NC::clCyan;
|
||||
else if (color == "white")
|
||||
result = NCurses::clWhite;
|
||||
result = NC::clWhite;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Border stringToBorder(const std::string &border)
|
||||
NC::Border stringToBorder(const std::string &border)
|
||||
{
|
||||
return Border(stringToColor(border));
|
||||
return NC::Border(stringToColor(border));
|
||||
}
|
||||
|
||||
BasicScreen *intToScreen(int n)
|
||||
@@ -308,31 +309,31 @@ void Configuration::SetDefaults()
|
||||
tag_editor_album_format = "{{(%y) }%b}";
|
||||
new_header_first_line = "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}";
|
||||
new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}";
|
||||
browser_playlist_prefix << clRed << "(playlist)" << clEnd << ' ';
|
||||
browser_playlist_prefix << NC::clRed << "(playlist)" << NC::clEnd << ' ';
|
||||
progressbar = U("=>\0");
|
||||
visualizer_chars = U("◆│");
|
||||
pattern = "%n - %t";
|
||||
selected_item_prefix << clMagenta;
|
||||
selected_item_suffix << clEnd;
|
||||
now_playing_prefix << fmtBold;
|
||||
now_playing_suffix << fmtBoldEnd;
|
||||
color1 = clWhite;
|
||||
color2 = clGreen;
|
||||
empty_tags_color = clCyan;
|
||||
header_color = clDefault;
|
||||
volume_color = clDefault;
|
||||
state_line_color = clDefault;
|
||||
state_flags_color = clDefault;
|
||||
main_color = clYellow;
|
||||
selected_item_prefix << NC::clMagenta;
|
||||
selected_item_suffix << NC::clEnd;
|
||||
now_playing_prefix << NC::fmtBold;
|
||||
now_playing_suffix << NC::fmtBoldEnd;
|
||||
color1 = NC::clWhite;
|
||||
color2 = NC::clGreen;
|
||||
empty_tags_color = NC::clCyan;
|
||||
header_color = NC::clDefault;
|
||||
volume_color = NC::clDefault;
|
||||
state_line_color = NC::clDefault;
|
||||
state_flags_color = NC::clDefault;
|
||||
main_color = NC::clYellow;
|
||||
main_highlight_color = main_color;
|
||||
progressbar_color = clDefault;
|
||||
progressbar_elapsed_color = clDefault;
|
||||
statusbar_color = clDefault;
|
||||
alternative_ui_separator_color = clBlack;
|
||||
active_column_color = clRed;
|
||||
window_border = brGreen;
|
||||
active_window_border = brRed;
|
||||
visualizer_color = clYellow;
|
||||
progressbar_color = NC::clDefault;
|
||||
progressbar_elapsed_color = NC::clDefault;
|
||||
statusbar_color = NC::clDefault;
|
||||
alternative_ui_separator_color = NC::clBlack;
|
||||
active_column_color = NC::clRed;
|
||||
window_border = NC::brGreen;
|
||||
active_window_border = NC::brRed;
|
||||
visualizer_color = NC::clYellow;
|
||||
media_lib_primary_tag = MPD_TAG_ARTIST;
|
||||
enable_idle_notifications = true;
|
||||
colors_enabled = true;
|
||||
@@ -567,7 +568,7 @@ void Configuration::Read()
|
||||
// make version without colors
|
||||
if (song_status_format.find("$") != std::string::npos)
|
||||
{
|
||||
Buffer status_no_colors;
|
||||
NC::Buffer status_no_colors;
|
||||
String2Buffer(song_status_format, status_no_colors);
|
||||
song_status_format_no_colors = status_no_colors.Str();
|
||||
}
|
||||
@@ -682,7 +683,7 @@ void Configuration::Read()
|
||||
{
|
||||
selected_item_prefix.Clear();
|
||||
String2Buffer(v, selected_item_prefix);
|
||||
selected_item_prefix_length = Window::Length(TO_WSTRING(selected_item_prefix.Str()));
|
||||
selected_item_prefix_length = NC::Window::Length(TO_WSTRING(selected_item_prefix.Str()));
|
||||
}
|
||||
}
|
||||
else if (name == "selected_item_suffix")
|
||||
@@ -691,7 +692,7 @@ void Configuration::Read()
|
||||
{
|
||||
selected_item_suffix.Clear();
|
||||
String2Buffer(v, selected_item_suffix);
|
||||
selected_item_suffix_length = Window::Length(TO_WSTRING(selected_item_suffix.Str()));
|
||||
selected_item_suffix_length = NC::Window::Length(TO_WSTRING(selected_item_suffix.Str()));
|
||||
}
|
||||
}
|
||||
else if (name == "now_playing_prefix")
|
||||
@@ -700,7 +701,7 @@ void Configuration::Read()
|
||||
{
|
||||
now_playing_prefix.Clear();
|
||||
String2Buffer(v, now_playing_prefix);
|
||||
now_playing_prefix_length = Window::Length(TO_WSTRING(now_playing_prefix.Str()));
|
||||
now_playing_prefix_length = NC::Window::Length(TO_WSTRING(now_playing_prefix.Str()));
|
||||
}
|
||||
}
|
||||
else if (name == "now_playing_suffix")
|
||||
@@ -709,7 +710,7 @@ void Configuration::Read()
|
||||
{
|
||||
now_playing_suffix.Clear();
|
||||
String2Buffer(TO_WSTRING(v), now_playing_suffix);
|
||||
now_playing_suffix_length = Window::Length(now_playing_suffix.Str());
|
||||
now_playing_suffix_length = NC::Window::Length(now_playing_suffix.Str());
|
||||
}
|
||||
}
|
||||
else if (name == "color1")
|
||||
@@ -1172,7 +1173,7 @@ void Configuration::GenerateColumns()
|
||||
// generate format for converting tags in columns to string for Playlist::SongInColumnsToString()
|
||||
char tag[] = "{% }|";
|
||||
song_in_columns_to_string_format = "{";
|
||||
for (std::vector<Column>::const_iterator it = columns.begin(); it != columns.end(); ++it)
|
||||
for (auto it = columns.begin(); it != columns.end(); ++it)
|
||||
{
|
||||
for (std::string::const_iterator j = it->type.begin(); j != it->type.end(); ++j)
|
||||
{
|
||||
@@ -1193,7 +1194,7 @@ void Configuration::MakeProperPath(std::string &dir)
|
||||
return;
|
||||
if (dir[0] == '~')
|
||||
dir.replace(0, 1, home_directory);
|
||||
replace(dir.begin(), dir.end(), '\\', '/');
|
||||
std::replace(dir.begin(), dir.end(), '\\', '/');
|
||||
if (*dir.rbegin() != '/')
|
||||
dir += '/';
|
||||
}
|
||||
|
||||
@@ -23,11 +23,9 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
#include <mpd/client.h>
|
||||
|
||||
#include "actions.h"
|
||||
#include "ncmpcpp.h"
|
||||
#include "strbuffer.h"
|
||||
|
||||
class BasicScreen; // forward declaration for screens sequence
|
||||
|
||||
@@ -41,7 +39,7 @@ struct Column
|
||||
std::string type;
|
||||
int width;
|
||||
int stretch_limit;
|
||||
Color color;
|
||||
NC::Color color;
|
||||
bool fixed;
|
||||
bool right_alignment;
|
||||
bool display_empty_tag;
|
||||
@@ -126,30 +124,30 @@ struct Configuration
|
||||
|
||||
std::vector<Column> columns;
|
||||
|
||||
Buffer browser_playlist_prefix;
|
||||
Buffer selected_item_prefix;
|
||||
Buffer selected_item_suffix;
|
||||
Buffer now_playing_prefix;
|
||||
basic_buffer<my_char_t> now_playing_suffix;
|
||||
NC::Buffer browser_playlist_prefix;
|
||||
NC::Buffer selected_item_prefix;
|
||||
NC::Buffer selected_item_suffix;
|
||||
NC::Buffer now_playing_prefix;
|
||||
NC::basic_buffer<my_char_t> now_playing_suffix;
|
||||
|
||||
Color color1;
|
||||
Color color2;
|
||||
Color empty_tags_color;
|
||||
Color header_color;
|
||||
Color volume_color;
|
||||
Color state_line_color;
|
||||
Color state_flags_color;
|
||||
Color main_color;
|
||||
Color main_highlight_color;
|
||||
Color progressbar_color;
|
||||
Color progressbar_elapsed_color;
|
||||
Color statusbar_color;
|
||||
Color alternative_ui_separator_color;
|
||||
Color active_column_color;
|
||||
Color visualizer_color;
|
||||
NC::Color color1;
|
||||
NC::Color color2;
|
||||
NC::Color empty_tags_color;
|
||||
NC::Color header_color;
|
||||
NC::Color volume_color;
|
||||
NC::Color state_line_color;
|
||||
NC::Color state_flags_color;
|
||||
NC::Color main_color;
|
||||
NC::Color main_highlight_color;
|
||||
NC::Color progressbar_color;
|
||||
NC::Color progressbar_elapsed_color;
|
||||
NC::Color statusbar_color;
|
||||
NC::Color alternative_ui_separator_color;
|
||||
NC::Color active_column_color;
|
||||
NC::Color visualizer_color;
|
||||
|
||||
Border window_border;
|
||||
Border active_window_border;
|
||||
NC::Border window_border;
|
||||
NC::Border active_window_border;
|
||||
|
||||
mpd_tag_type media_lib_primary_tag;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <mpd/client.h>
|
||||
|
||||
@@ -85,6 +86,8 @@ struct Song
|
||||
size_t m_hash;
|
||||
};
|
||||
|
||||
typedef std::vector<Song> SongList;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,9 +19,15 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "song_info.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
# include "fileref.h"
|
||||
# include "tag.h"
|
||||
#endif // HAVE_TAGLIB_H
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
@@ -45,7 +51,7 @@ const SongInfo::Metadata SongInfo::Tags[] =
|
||||
|
||||
void SongInfo::Init()
|
||||
{
|
||||
w = new Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
@@ -109,24 +115,24 @@ void SongInfo::PrepareSong(MPD::Song &s)
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|
||||
*w << fmtBold << Config.color1 << U("Filename: ") << fmtBoldEnd << Config.color2 << s.getName() << '\n' << clEnd;
|
||||
*w << fmtBold << U("Directory: ") << fmtBoldEnd << Config.color2;
|
||||
*w << NC::fmtBold << Config.color1 << U("Filename: ") << NC::fmtBoldEnd << Config.color2 << s.getName() << '\n' << NC::clEnd;
|
||||
*w << NC::fmtBold << U("Directory: ") << NC::fmtBoldEnd << Config.color2;
|
||||
ShowTag(*w, s.getDirectory());
|
||||
*w << U("\n\n") << clEnd;
|
||||
*w << fmtBold << U("Length: ") << fmtBoldEnd << Config.color2 << s.getLength() << '\n' << clEnd;
|
||||
*w << U("\n\n") << NC::clEnd;
|
||||
*w << NC::fmtBold << U("Length: ") << NC::fmtBoldEnd << Config.color2 << s.getLength() << '\n' << NC::clEnd;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (!f.isNull())
|
||||
{
|
||||
*w << fmtBold << U("Bitrate: ") << fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << U(" kbps\n") << clEnd;
|
||||
*w << fmtBold << U("Sample rate: ") << fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << U(" Hz\n") << clEnd;
|
||||
*w << fmtBold << U("Channels: ") << fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? U("Mono") : U("Stereo")) << '\n' << clDefault;
|
||||
*w << NC::fmtBold << U("Bitrate: ") << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << U(" kbps\n") << NC::clEnd;
|
||||
*w << NC::fmtBold << U("Sample rate: ") << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << U(" Hz\n") << NC::clEnd;
|
||||
*w << NC::fmtBold << U("Channels: ") << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? U("Mono") : U("Stereo")) << '\n' << NC::clDefault;
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
*w << clDefault;
|
||||
*w << NC::clDefault;
|
||||
|
||||
for (const Metadata *m = Tags; m->Name; ++m)
|
||||
{
|
||||
*w << fmtBold << '\n' << TO_WSTRING(m->Name) << U(": ") << fmtBoldEnd;
|
||||
*w << NC::fmtBold << '\n' << TO_WSTRING(m->Name) << U(": ") << NC::fmtBoldEnd;
|
||||
ShowTag(*w, s.getTags(m->Get));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "screen.h"
|
||||
#include "mutable_song.h"
|
||||
|
||||
class SongInfo : public Screen<Scrollpad>
|
||||
class SongInfo : public Screen<NC::Scrollpad>
|
||||
{
|
||||
public:
|
||||
struct Metadata
|
||||
@@ -44,7 +44,7 @@ class SongInfo : public Screen<Scrollpad>
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
myPlaylist->NowPlaying = -1;
|
||||
if (Config.new_design)
|
||||
{
|
||||
*wHeader << XY(0, 0) << wclrtoeol << XY(0, 1) << wclrtoeol;
|
||||
*wHeader << NC::XY(0, 0) << wclrtoeol << NC::XY(0, 1) << wclrtoeol;
|
||||
player_state = "[stopped]";
|
||||
changed.Volume = 1;
|
||||
changed.StatusFlags = 1;
|
||||
@@ -362,20 +362,20 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
}
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
if (myScreen == myVisualizer)
|
||||
wFooter->SetTimeout(state == MPD::psPlay ? Visualizer::WindowTimeout : ncmpcpp_window_timeout);
|
||||
wFooter->SetTimeout(state == MPD::psPlay ? Visualizer::WindowTimeout : 500);
|
||||
# endif // ENABLE_VISUALIZER
|
||||
if (Config.new_design)
|
||||
{
|
||||
*wHeader << XY(0, 1) << fmtBold << player_state << fmtBoldEnd;
|
||||
*wHeader << NC::XY(0, 1) << NC::fmtBold << player_state << NC::fmtBoldEnd;
|
||||
wHeader->Refresh();
|
||||
}
|
||||
else if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
{
|
||||
*wFooter << XY(0, 1);
|
||||
*wFooter << NC::XY(0, 1);
|
||||
if (player_state.empty())
|
||||
*wFooter << wclrtoeol;
|
||||
else
|
||||
*wFooter << fmtBold << player_state << fmtBoldEnd;
|
||||
*wFooter << NC::fmtBold << player_state << NC::fmtBoldEnd;
|
||||
}
|
||||
}
|
||||
if (changed.SongID)
|
||||
@@ -442,28 +442,28 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
tracklength += " kbps";
|
||||
}
|
||||
|
||||
basic_buffer<my_char_t> first, second;
|
||||
NC::basic_buffer<my_char_t> first, second;
|
||||
String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.new_header_first_line, "$"))), first);
|
||||
String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.new_header_second_line, "$"))), second);
|
||||
|
||||
size_t first_len = Window::Length(first.Str());
|
||||
size_t first_len = NC::Window::Length(first.Str());
|
||||
size_t first_margin = (std::max(tracklength.length()+1, VolumeState.length()))*2;
|
||||
size_t first_start = first_len < COLS-first_margin ? (COLS-first_len)/2 : tracklength.length()+1;
|
||||
|
||||
size_t second_len = Window::Length(second.Str());
|
||||
size_t second_len = NC::Window::Length(second.Str());
|
||||
size_t second_margin = (std::max(player_state.length(), size_t(8))+1)*2;
|
||||
size_t second_start = second_len < COLS-second_margin ? (COLS-second_len)/2 : player_state.length()+1;
|
||||
|
||||
if (!Global::SeekingInProgress)
|
||||
*wHeader << XY(0, 0) << wclrtoeol << tracklength;
|
||||
*wHeader << XY(first_start, 0);
|
||||
*wHeader << NC::XY(0, 0) << wclrtoeol << tracklength;
|
||||
*wHeader << NC::XY(first_start, 0);
|
||||
first.Write(*wHeader, first_line_scroll_begin, COLS-tracklength.length()-VolumeState.length()-1, U(" ** "));
|
||||
|
||||
*wHeader << XY(0, 1) << wclrtoeol << fmtBold << player_state << fmtBoldEnd;
|
||||
*wHeader << XY(second_start, 1);
|
||||
*wHeader << NC::XY(0, 1) << wclrtoeol << NC::fmtBold << player_state << NC::fmtBoldEnd;
|
||||
*wHeader << NC::XY(second_start, 1);
|
||||
second.Write(*wHeader, second_line_scroll_begin, COLS-player_state.length()-8-2, U(" ** "));
|
||||
|
||||
*wHeader << XY(wHeader->GetWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState << clEnd;
|
||||
*wHeader << NC::XY(wHeader->GetWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState << NC::clEnd;
|
||||
|
||||
changed.StatusFlags = 1;
|
||||
}
|
||||
@@ -494,11 +494,11 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
tracklength += MPD::Song::ShowTime(Mpd.GetElapsedTime());
|
||||
tracklength += "]";
|
||||
}
|
||||
basic_buffer<my_char_t> np_song;
|
||||
NC::basic_buffer<my_char_t> np_song;
|
||||
String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.song_status_format, "$"))), np_song);
|
||||
*wFooter << XY(0, 1) << wclrtoeol << fmtBold << player_state << fmtBoldEnd;
|
||||
*wFooter << NC::XY(0, 1) << wclrtoeol << NC::fmtBold << player_state << NC::fmtBoldEnd;
|
||||
np_song.Write(*wFooter, playing_song_scroll_begin, wFooter->GetWidth()-player_state.length()-tracklength.length(), U(" ** "));
|
||||
*wFooter << fmtBold << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength << fmtBoldEnd;
|
||||
*wFooter << NC::fmtBold << NC::XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength << NC::fmtBoldEnd;
|
||||
}
|
||||
if (!block_progressbar_update)
|
||||
DrawProgressbar(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
|
||||
@@ -507,7 +507,7 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
else
|
||||
{
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
*wFooter << XY(0, 1) << wclrtoeol;
|
||||
*wFooter << NC::XY(0, 1) << wclrtoeol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,12 +571,12 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
switch_state += mpd_crossfade ? mpd_crossfade : '-';
|
||||
switch_state += mpd_db_updating ? mpd_db_updating : '-';
|
||||
switch_state += ']';
|
||||
*wHeader << XY(COLS-switch_state.length(), 1) << fmtBold << Config.state_flags_color << switch_state << clEnd << fmtBoldEnd;
|
||||
*wHeader << NC::XY(COLS-switch_state.length(), 1) << NC::fmtBold << Config.state_flags_color << switch_state << NC::clEnd << NC::fmtBoldEnd;
|
||||
if (Config.new_design && !Config.header_visibility) // in this case also draw separator
|
||||
{
|
||||
*wHeader << fmtBold << clBlack;
|
||||
*wHeader << NC::fmtBold << NC::clBlack;
|
||||
mvwhline(wHeader->Raw(), 2, 0, 0, COLS);
|
||||
*wHeader << clEnd << fmtBoldEnd;
|
||||
*wHeader << NC::clEnd << NC::fmtBoldEnd;
|
||||
}
|
||||
wHeader->Refresh();
|
||||
}
|
||||
@@ -625,8 +625,8 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
VolumeState += "%";
|
||||
}
|
||||
*wHeader << Config.volume_color;
|
||||
*wHeader << XY(wHeader->GetWidth()-VolumeState.length(), 0) << VolumeState;
|
||||
*wHeader << clEnd;
|
||||
*wHeader << NC::XY(wHeader->GetWidth()-VolumeState.length(), 0) << VolumeState;
|
||||
*wHeader << NC::clEnd;
|
||||
wHeader->Refresh();
|
||||
}
|
||||
if (changed.Outputs)
|
||||
@@ -642,9 +642,9 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
|
||||
ApplyToVisibleWindows(&BasicScreen::RefreshWindow);
|
||||
}
|
||||
|
||||
Window &Statusbar()
|
||||
NC::Window &Statusbar()
|
||||
{
|
||||
*wFooter << XY(0, Config.statusbar_visibility) << wclrtoeol;
|
||||
*wFooter << NC::XY(0, Config.statusbar_visibility) << wclrtoeol;
|
||||
return *wFooter;
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ void DrawProgressbar(unsigned elapsed, unsigned time)
|
||||
unsigned pb_width = wFooter->GetWidth();
|
||||
unsigned howlong = time ? pb_width*elapsed/time : 0;
|
||||
if (Config.progressbar_boldness)
|
||||
*wFooter << fmtBold;
|
||||
*wFooter << NC::fmtBold;
|
||||
*wFooter << Config.progressbar_color;
|
||||
if (Config.progressbar[2] != '\0')
|
||||
{
|
||||
@@ -672,11 +672,11 @@ void DrawProgressbar(unsigned elapsed, unsigned time)
|
||||
*wFooter << Config.progressbar[0];
|
||||
if (howlong < wFooter->GetWidth())
|
||||
*wFooter << Config.progressbar[1];
|
||||
*wFooter << clEnd;
|
||||
*wFooter << NC::clEnd;
|
||||
}
|
||||
*wFooter << clEnd;
|
||||
*wFooter << NC::clEnd;
|
||||
if (Config.progressbar_boldness)
|
||||
*wFooter << fmtBoldEnd;
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
}
|
||||
|
||||
void ShowMessage(const char *format, ...)
|
||||
@@ -690,7 +690,7 @@ void ShowMessage(const char *format, ...)
|
||||
else
|
||||
block_progressbar_update = 1;
|
||||
wFooter->GotoXY(0, Config.statusbar_visibility);
|
||||
*wFooter << fmtBoldEnd;
|
||||
*wFooter << NC::fmtBoldEnd;
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
wmove(wFooter->Raw(), Config.statusbar_visibility, 0);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "mpdpp.h"
|
||||
#include "ncmpcpp.h"
|
||||
|
||||
#ifndef USE_PDCURSES
|
||||
void WindowTitle(const std::string &);
|
||||
@@ -41,7 +40,7 @@ void TraceMpdStatus();
|
||||
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges, void *);
|
||||
void NcmpcppErrorCallback(MPD::Connection *, int, const char *, void *);
|
||||
|
||||
Window &Statusbar();
|
||||
NC::Window &Statusbar();
|
||||
void DrawProgressbar(unsigned elapsed, unsigned time);
|
||||
void ShowMessage(const char *, ...) GNUC_PRINTF(1, 2);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace NCurses {
|
||||
namespace NC {
|
||||
|
||||
/// Buffer template class that can store text along with its
|
||||
/// format attributes. The content can be easily printed to
|
||||
@@ -234,8 +234,6 @@ typedef basic_buffer<char> Buffer;
|
||||
///
|
||||
typedef basic_buffer<wchar_t> WBuffer;
|
||||
|
||||
|
||||
|
||||
template <typename C> basic_buffer<C>::basic_buffer(const basic_buffer &b)
|
||||
: itsString(b.itsString), itsFormat(b.itsFormat) { }
|
||||
|
||||
|
||||
@@ -32,15 +32,21 @@
|
||||
#include "mpegfile.h"
|
||||
#include "vorbisfile.h"
|
||||
#include "flacfile.h"
|
||||
#include "xiphcomment.h"
|
||||
#include "fileref.h"
|
||||
#include "tag.h"
|
||||
|
||||
#include "browser.h"
|
||||
#include "charset.h"
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "song_info.h"
|
||||
#include "playlist.h"
|
||||
#include "utility/comparators.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
using Global::myScreen;
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -83,8 +89,8 @@ std::string GenerateFilename(const MPD::MutableSong &s, const std::string &patte
|
||||
std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview);
|
||||
|
||||
std::string SongToString(const MPD::MutableSong &s);
|
||||
bool DirEntryMatcher(const Regex &rx, const string_pair &dir, bool filter);
|
||||
bool AlbumEntryMatcher(const Regex &rx, const string_pair &dir);
|
||||
bool DirEntryMatcher(const Regex &rx, const std::pair<std::string, std::string> &dir, bool filter);
|
||||
bool AlbumEntryMatcher(const Regex &rx, const std::pair<std::string, std::string> &dir);
|
||||
bool SongEntryMatcher(const Regex &rx, const MPD::MutableSong &s);
|
||||
|
||||
}
|
||||
@@ -94,13 +100,13 @@ void TagEditor::Init()
|
||||
PatternsFile = Config.ncmpcpp_directory + "patterns.list";
|
||||
SetDimensions(0, COLS);
|
||||
|
||||
Albums = new Menu<string_pair>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, brNone);
|
||||
Albums = new NC::Menu< std::pair<std::string, std::string> >(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::brNone);
|
||||
Albums->HighlightColor(Config.active_column_color);
|
||||
Albums->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Albums->CenteredCursor(Config.centered_cursor);
|
||||
Albums->setItemDisplayer(Display::Pair<std::string, std::string>);
|
||||
|
||||
Dirs = new Menu<string_pair>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Directories" : "", Config.main_color, brNone);
|
||||
Dirs = new NC::Menu< std::pair<std::string, std::string> >(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Directories" : "", Config.main_color, NC::brNone);
|
||||
Dirs->HighlightColor(Config.active_column_color);
|
||||
Dirs->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Dirs->CenteredCursor(Config.centered_cursor);
|
||||
@@ -108,7 +114,7 @@ void TagEditor::Init()
|
||||
|
||||
LeftColumn = Config.albums_in_tag_editor ? Albums : Dirs;
|
||||
|
||||
TagTypes = new Menu<std::string>(MiddleColumnStartX, MainStartY, MiddleColumnWidth, MainHeight, Config.titles_visibility ? "Tag types" : "", Config.main_color, brNone);
|
||||
TagTypes = new NC::Menu<std::string>(MiddleColumnStartX, MainStartY, MiddleColumnWidth, MainHeight, Config.titles_visibility ? "Tag types" : "", Config.main_color, NC::brNone);
|
||||
TagTypes->HighlightColor(Config.main_highlight_color);
|
||||
TagTypes->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
TagTypes->CenteredCursor(Config.centered_cursor);
|
||||
@@ -128,7 +134,7 @@ void TagEditor::Init()
|
||||
TagTypes->AddItem("Reset");
|
||||
TagTypes->AddItem("Save");
|
||||
|
||||
Tags = new Menu<MPD::MutableSong>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Tags" : "", Config.main_color, brNone);
|
||||
Tags = new NC::Menu<MPD::MutableSong>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Tags" : "", Config.main_color, NC::brNone);
|
||||
Tags->HighlightColor(Config.main_highlight_color);
|
||||
Tags->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
Tags->CenteredCursor(Config.centered_cursor);
|
||||
@@ -136,7 +142,7 @@ void TagEditor::Init()
|
||||
Tags->SetSelectSuffix(Config.selected_item_suffix);
|
||||
Tags->setItemDisplayer(Display::Tags);
|
||||
|
||||
FParserDialog = new Menu<std::string>((COLS-FParserDialogWidth)/2, (MainHeight-FParserDialogHeight)/2+MainStartY, FParserDialogWidth, FParserDialogHeight, "", Config.main_color, Config.window_border);
|
||||
FParserDialog = new NC::Menu<std::string>((COLS-FParserDialogWidth)/2, (MainHeight-FParserDialogHeight)/2+MainStartY, FParserDialogWidth, FParserDialogHeight, "", Config.main_color, Config.window_border);
|
||||
FParserDialog->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
FParserDialog->CenteredCursor(Config.centered_cursor);
|
||||
FParserDialog->setItemDisplayer(Display::Default<std::string>);
|
||||
@@ -145,14 +151,14 @@ void TagEditor::Init()
|
||||
FParserDialog->AddSeparator();
|
||||
FParserDialog->AddItem("Cancel");
|
||||
|
||||
FParser = new Menu<std::string>((COLS-FParserWidth)/2, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthOne, FParserHeight, "_", Config.main_color, Config.active_window_border);
|
||||
FParser = new NC::Menu<std::string>((COLS-FParserWidth)/2, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthOne, FParserHeight, "_", Config.main_color, Config.active_window_border);
|
||||
FParser->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
FParser->CenteredCursor(Config.centered_cursor);
|
||||
FParser->setItemDisplayer(Display::Default<std::string>);
|
||||
|
||||
FParserLegend = new Scrollpad((COLS-FParserWidth)/2+FParserWidthOne, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthTwo, FParserHeight, "Legend", Config.main_color, Config.window_border);
|
||||
FParserLegend = new NC::Scrollpad((COLS-FParserWidth)/2+FParserWidthOne, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthTwo, FParserHeight, "Legend", Config.main_color, Config.window_border);
|
||||
|
||||
FParserPreview = new Scrollpad((COLS-FParserWidth)/2+FParserWidthOne, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthTwo, FParserHeight, "Preview", Config.main_color, Config.window_border);
|
||||
FParserPreview = new NC::Scrollpad((COLS-FParserWidth)/2+FParserWidthOne, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthTwo, FParserHeight, "Preview", Config.main_color, Config.window_border);
|
||||
|
||||
w = LeftColumn;
|
||||
isInitialized = 1;
|
||||
@@ -261,7 +267,7 @@ void TagEditor::Update()
|
||||
Tags->Clear();
|
||||
if (Config.albums_in_tag_editor)
|
||||
{
|
||||
*Albums << XY(0, 0) << "Fetching albums...";
|
||||
*Albums << NC::XY(0, 0) << "Fetching albums...";
|
||||
Albums->Window::Refresh();
|
||||
Mpd.BlockIdle(true); // for the same reason as in media library
|
||||
auto albums = Mpd.GetList(MPD_TAG_ALBUM);
|
||||
@@ -382,9 +388,9 @@ void TagEditor::EnterPressed()
|
||||
*FParserLegend << U("%p - performer\n");
|
||||
*FParserLegend << U("%d - disc\n");
|
||||
*FParserLegend << U("%C - comment\n\n");
|
||||
*FParserLegend << fmtBold << U("Files:\n") << fmtBoldEnd;
|
||||
*FParserLegend << NC::fmtBold << U("Files:\n") << NC::fmtBoldEnd;
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
*FParserLegend << Config.color2 << U(" * ") << clEnd << (*it)->getName() << '\n';
|
||||
*FParserLegend << Config.color2 << U(" * ") << NC::clEnd << (*it)->getName() << '\n';
|
||||
FParserLegend->Flush();
|
||||
|
||||
if (!Patterns.empty())
|
||||
@@ -445,7 +451,7 @@ void TagEditor::EnterPressed()
|
||||
{
|
||||
if (FParserUsePreview)
|
||||
{
|
||||
*FParserPreview << fmtBold << s.getName() << U(":\n") << fmtBoldEnd;
|
||||
*FParserPreview << NC::fmtBold << s.getName() << U(":\n") << NC::fmtBoldEnd;
|
||||
*FParserPreview << ParseFilename(s, Config.pattern, FParserUsePreview) << '\n';
|
||||
}
|
||||
else
|
||||
@@ -465,9 +471,9 @@ void TagEditor::EnterPressed()
|
||||
}
|
||||
if (!FParserUsePreview)
|
||||
s.setNewURI(new_file + extension);
|
||||
*FParserPreview << file << Config.color2 << U(" -> ") << clEnd;
|
||||
*FParserPreview << file << Config.color2 << U(" -> ") << NC::clEnd;
|
||||
if (new_file.empty())
|
||||
*FParserPreview << Config.empty_tags_color << Config.empty_tag << clEnd;
|
||||
*FParserPreview << Config.empty_tags_color << Config.empty_tag << NC::clEnd;
|
||||
else
|
||||
*FParserPreview << new_file << extension;
|
||||
*FParserPreview << '\n' << '\n';
|
||||
@@ -558,7 +564,7 @@ void TagEditor::EnterPressed()
|
||||
if (id > 0 && w == TagTypes)
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << TagTypes->Current().value() << fmtBoldEnd << ": ";
|
||||
Statusbar() << NC::fmtBold << TagTypes->Current().value() << NC::fmtBoldEnd << ": ";
|
||||
std::string new_tag = wFooter->GetString(Tags->Current().value().getTags(get));
|
||||
UnlockStatusbar();
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
@@ -567,12 +573,12 @@ void TagEditor::EnterPressed()
|
||||
else if (w == Tags)
|
||||
{
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << TagTypes->Current().value() << fmtBoldEnd << ": ";
|
||||
Statusbar() << NC::fmtBold << TagTypes->Current().value() << NC::fmtBoldEnd << ": ";
|
||||
std::string new_tag = wFooter->GetString(Tags->Current().value().getTags(get));
|
||||
UnlockStatusbar();
|
||||
if (new_tag != Tags->Current().value().getTags(get))
|
||||
Tags->Current().value().setTag(set, new_tag);
|
||||
Tags->Scroll(wDown);
|
||||
Tags->Scroll(NC::wDown);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -597,12 +603,12 @@ void TagEditor::EnterPressed()
|
||||
std::string extension = old_name.substr(last_dot);
|
||||
old_name = old_name.substr(0, last_dot);
|
||||
LockStatusbar();
|
||||
Statusbar() << fmtBold << "New filename: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "New filename: " << NC::fmtBoldEnd;
|
||||
std::string new_name = wFooter->GetString(old_name);
|
||||
UnlockStatusbar();
|
||||
if (!new_name.empty() && new_name != old_name)
|
||||
s.setNewURI(new_name + extension);
|
||||
Tags->Scroll(wDown);
|
||||
Tags->Scroll(NC::wDown);
|
||||
}
|
||||
}
|
||||
else if (id == 16) // capitalize first letters
|
||||
@@ -660,7 +666,7 @@ void TagEditor::SpacePressed()
|
||||
if (w == Tags && !Tags->Empty())
|
||||
{
|
||||
Tags->Current().setSelected(!Tags->Current().isSelected());
|
||||
w->Scroll(wDown);
|
||||
w->Scroll(NC::wDown);
|
||||
return;
|
||||
}
|
||||
if (w != LeftColumn)
|
||||
@@ -686,7 +692,7 @@ void TagEditor::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
}
|
||||
else if (w == FParser || w == FParserHelper)
|
||||
@@ -702,13 +708,13 @@ void TagEditor::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
else if (FParserHelper->hasCoords(me.x, me.y))
|
||||
{
|
||||
if (w != FParserHelper)
|
||||
NextColumn();
|
||||
reinterpret_cast<Screen<Scrollpad> *>(this)->Screen<Scrollpad>::MouseButtonPressed(me);
|
||||
ScrollpadMouseButtonPressed(FParserHelper, me);
|
||||
}
|
||||
}
|
||||
else if (!LeftColumn->Empty() && LeftColumn->hasCoords(me.x, me.y))
|
||||
@@ -727,7 +733,7 @@ void TagEditor::MouseButtonPressed(MEVENT me)
|
||||
SpacePressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
Tags->Clear();
|
||||
}
|
||||
else if (!TagTypes->Empty() && TagTypes->hasCoords(me.x, me.y))
|
||||
@@ -744,7 +750,7 @@ void TagEditor::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
else if (!Tags->Empty() && Tags->hasCoords(me.x, me.y))
|
||||
{
|
||||
@@ -761,7 +767,7 @@ void TagEditor::MouseButtonPressed(MEVENT me)
|
||||
EnterPressed();
|
||||
}
|
||||
else
|
||||
Screen<Window>::MouseButtonPressed(me);
|
||||
Screen<NC::Window>::MouseButtonPressed(me);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,9 +777,9 @@ std::string TagEditor::currentFilter()
|
||||
{
|
||||
std::string filter;
|
||||
if (w == Dirs)
|
||||
filter = RegexFilter<string_pair>::currentFilter(*Dirs);
|
||||
filter = RegexFilter< std::pair<std::string, std::string> >::currentFilter(*Dirs);
|
||||
else if (w == Albums)
|
||||
filter = RegexFilter<string_pair>::currentFilter(*Albums);
|
||||
filter = RegexFilter< std::pair<std::string, std::string> >::currentFilter(*Albums);
|
||||
else if (w == Tags)
|
||||
filter = RegexFilter<MPD::MutableSong>::currentFilter(*Tags);
|
||||
return filter;
|
||||
@@ -785,13 +791,13 @@ void TagEditor::applyFilter(const std::string &filter)
|
||||
{
|
||||
Dirs->ShowAll();
|
||||
auto fun = std::bind(DirEntryMatcher, _1, _2, true);
|
||||
auto rx = RegexFilter<string_pair>(filter, Config.regex_type, fun);
|
||||
auto rx = RegexFilter< std::pair<std::string, std::string> >(filter, Config.regex_type, fun);
|
||||
Dirs->filter(Dirs->Begin(), Dirs->End(), rx);
|
||||
}
|
||||
else if (w == Albums)
|
||||
{
|
||||
Albums->ShowAll();
|
||||
auto rx = RegexFilter<string_pair>(filter, Config.regex_type, AlbumEntryMatcher);
|
||||
auto rx = RegexFilter< std::pair<std::string, std::string> >(filter, Config.regex_type, AlbumEntryMatcher);
|
||||
Albums->filter(Albums->Begin(), Albums->End(), rx);
|
||||
}
|
||||
else if (w == Tags)
|
||||
@@ -810,12 +816,12 @@ bool TagEditor::search(const std::string &constraint)
|
||||
if (w == Dirs)
|
||||
{
|
||||
auto fun = std::bind(DirEntryMatcher, _1, _2, false);
|
||||
auto rx = RegexFilter<string_pair>(constraint, Config.regex_type, fun);
|
||||
auto rx = RegexFilter< std::pair<std::string, std::string> >(constraint, Config.regex_type, fun);
|
||||
result = Dirs->search(Dirs->Begin(), Dirs->End(), rx);
|
||||
}
|
||||
else if (w == Albums)
|
||||
{
|
||||
auto rx = RegexFilter<string_pair>(constraint, Config.regex_type, AlbumEntryMatcher);
|
||||
auto rx = RegexFilter< std::pair<std::string, std::string> >(constraint, Config.regex_type, AlbumEntryMatcher);
|
||||
result = Albums->search(Albums->Begin(), Albums->End(), rx);
|
||||
}
|
||||
else if (w == Tags)
|
||||
@@ -898,7 +904,7 @@ MPD::SongList TagEditor::getSelectedSongs()
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
List *TagEditor::GetList()
|
||||
NC::List *TagEditor::GetList()
|
||||
{
|
||||
if (w == LeftColumn)
|
||||
return LeftColumn;
|
||||
@@ -1392,14 +1398,14 @@ std::string SongToString(const MPD::MutableSong &s)
|
||||
return result.empty() ? Config.empty_tag : result;
|
||||
}
|
||||
|
||||
bool DirEntryMatcher(const Regex &rx, const string_pair &dir, bool filter)
|
||||
bool DirEntryMatcher(const Regex &rx, const std::pair<std::string, std::string> &dir, bool filter)
|
||||
{
|
||||
if (dir.first == "." || dir.first == "..")
|
||||
return filter;
|
||||
return rx.match(dir.first);
|
||||
}
|
||||
|
||||
bool AlbumEntryMatcher(const Regex &rx, const string_pair &dir)
|
||||
bool AlbumEntryMatcher(const Regex &rx, const std::pair<std::string, std::string> &dir)
|
||||
{
|
||||
return rx.match(dir.first);
|
||||
}
|
||||
|
||||
@@ -27,17 +27,13 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
// taglib headers
|
||||
#include "xiphcomment.h"
|
||||
#include "fileref.h"
|
||||
#include "tag.h"
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "mpdpp.h"
|
||||
#include "mutable_song.h"
|
||||
#include "regex_filter.h"
|
||||
#include "screen.h"
|
||||
|
||||
class TagEditor : public Screen<Window>, public Filterable, public HasSongs, public Searchable
|
||||
class TagEditor : public Screen<NC::Window>, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
public:
|
||||
TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/") { }
|
||||
@@ -73,7 +69,7 @@ class TagEditor : public Screen<Window>, public Filterable, public HasSongs, pub
|
||||
virtual void removeSelection();
|
||||
virtual MPD::SongList getSelectedSongs();
|
||||
|
||||
virtual List *GetList();
|
||||
virtual NC::List *GetList();
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
@@ -84,11 +80,11 @@ class TagEditor : public Screen<Window>, public Filterable, public HasSongs, pub
|
||||
|
||||
void LocateSong(const MPD::Song &s);
|
||||
|
||||
Menu<string_pair> *LeftColumn;
|
||||
Menu<string_pair> *Albums;
|
||||
Menu<string_pair> *Dirs;
|
||||
Menu<std::string> *TagTypes;
|
||||
Menu<MPD::MutableSong> *Tags;
|
||||
NC::Menu< std::pair<std::string, std::string> > *LeftColumn;
|
||||
NC::Menu< std::pair<std::string, std::string> > *Albums;
|
||||
NC::Menu< std::pair<std::string, std::string> > *Dirs;
|
||||
NC::Menu<std::string> *TagTypes;
|
||||
NC::Menu<MPD::MutableSong> *Tags;
|
||||
|
||||
/// NOTICE: this string is always in utf8, no need to convert it
|
||||
const std::string &CurrentDir() { return itsBrowsedDir; }
|
||||
@@ -104,11 +100,11 @@ class TagEditor : public Screen<Window>, public Filterable, public HasSongs, pub
|
||||
void SetDimensions(size_t, size_t);
|
||||
|
||||
std::vector<MPD::MutableSong *> EditedSongs;
|
||||
Menu<std::string> *FParserDialog;
|
||||
Menu<std::string> *FParser;
|
||||
Scrollpad *FParserHelper;
|
||||
Scrollpad *FParserLegend;
|
||||
Scrollpad *FParserPreview;
|
||||
NC::Menu<std::string> *FParserDialog;
|
||||
NC::Menu<std::string> *FParser;
|
||||
NC::Scrollpad *FParserHelper;
|
||||
NC::Scrollpad *FParserLegend;
|
||||
NC::Scrollpad *FParserPreview;
|
||||
bool FParserUsePreview;
|
||||
|
||||
std::string itsBrowsedDir;
|
||||
|
||||
@@ -26,10 +26,12 @@
|
||||
#include "mpegfile.h"
|
||||
#include "vorbisfile.h"
|
||||
#include "flacfile.h"
|
||||
#include "fileref.h"
|
||||
|
||||
#include "browser.h"
|
||||
#include "charset.h"
|
||||
#include "display.h"
|
||||
#include "helpers.h"
|
||||
#include "global.h"
|
||||
#include "song_info.h"
|
||||
#include "playlist.h"
|
||||
@@ -44,11 +46,11 @@ TinyTagEditor *myTinyTagEditor = new TinyTagEditor;
|
||||
|
||||
void TinyTagEditor::Init()
|
||||
{
|
||||
w = new Menu<Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, brNone);
|
||||
w = new NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w->HighlightColor(Config.main_highlight_color);
|
||||
w->CyclicScrolling(Config.use_cyclic_scrolling);
|
||||
w->CenteredCursor(Config.centered_cursor);
|
||||
w->setItemDisplayer(Display::Default<Buffer>);
|
||||
w->setItemDisplayer(Display::Default<NC::Buffer>);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
@@ -108,15 +110,15 @@ void TinyTagEditor::EnterPressed()
|
||||
if (option < 19) // separator after comment
|
||||
{
|
||||
size_t pos = option-8;
|
||||
Statusbar() << fmtBold << SongInfo::Tags[pos].Name << ": " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << SongInfo::Tags[pos].Name << ": " << NC::fmtBoldEnd;
|
||||
itsEdited.setTag(SongInfo::Tags[pos].Set, Global::wFooter->GetString(itsEdited.getTags(SongInfo::Tags[pos].Get)));
|
||||
w->at(option).value().Clear();
|
||||
w->at(option).value() << fmtBold << SongInfo::Tags[pos].Name << ':' << fmtBoldEnd << ' ';
|
||||
w->at(option).value() << NC::fmtBold << SongInfo::Tags[pos].Name << ':' << NC::fmtBoldEnd << ' ';
|
||||
ShowTag(w->at(option).value(), itsEdited.getTags(SongInfo::Tags[pos].Get));
|
||||
}
|
||||
else if (option == 20)
|
||||
{
|
||||
Statusbar() << fmtBold << "Filename: " << fmtBoldEnd;
|
||||
Statusbar() << NC::fmtBold << "Filename: " << NC::fmtBoldEnd;
|
||||
std::string filename = itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI();
|
||||
size_t dot = filename.rfind(".");
|
||||
std::string extension = filename.substr(dot);
|
||||
@@ -124,7 +126,7 @@ void TinyTagEditor::EnterPressed()
|
||||
std::string new_name = Global::wFooter->GetString(filename);
|
||||
itsEdited.setNewURI(new_name + extension);
|
||||
w->at(option).value().Clear();
|
||||
w->at(option).value() << fmtBold << "Filename:" << fmtBoldEnd << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
|
||||
w->at(option).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
|
||||
}
|
||||
UnlockStatusbar();
|
||||
|
||||
@@ -166,7 +168,7 @@ void TinyTagEditor::MouseButtonPressed(MEVENT me)
|
||||
}
|
||||
}
|
||||
else
|
||||
Screen< Menu<Buffer> >::MouseButtonPressed(me);
|
||||
Screen< NC::Menu<NC::Buffer> >::MouseButtonPressed(me);
|
||||
}
|
||||
|
||||
void TinyTagEditor::SetEdited(const MPD::Song &s)
|
||||
@@ -214,23 +216,23 @@ bool TinyTagEditor::getTags()
|
||||
|
||||
w->Highlight(8);
|
||||
|
||||
w->at(0).value() << fmtBold << Config.color1 << "Song name: " << fmtBoldEnd << Config.color2 << itsEdited.getName() << clEnd;
|
||||
w->at(1).value() << fmtBold << Config.color1 << "Location in DB: " << fmtBoldEnd << Config.color2;
|
||||
w->at(0).value() << NC::fmtBold << Config.color1 << "Song name: " << NC::fmtBoldEnd << Config.color2 << itsEdited.getName() << NC::clEnd;
|
||||
w->at(1).value() << NC::fmtBold << Config.color1 << "Location in DB: " << NC::fmtBoldEnd << Config.color2;
|
||||
ShowTag(w->at(1).value(), itsEdited.getDirectory());
|
||||
w->at(1).value() << clEnd;
|
||||
w->at(3).value() << fmtBold << Config.color1 << "Length: " << fmtBoldEnd << Config.color2 << itsEdited.getLength() << clEnd;
|
||||
w->at(4).value() << fmtBold << Config.color1 << "Bitrate: " << fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps" << clEnd;
|
||||
w->at(5).value() << fmtBold << Config.color1 << "Sample rate: " << fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz" << clEnd;
|
||||
w->at(6).value() << fmtBold << Config.color1 << "Channels: " << fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << clDefault;
|
||||
w->at(1).value() << NC::clEnd;
|
||||
w->at(3).value() << NC::fmtBold << Config.color1 << "Length: " << NC::fmtBoldEnd << Config.color2 << itsEdited.getLength() << NC::clEnd;
|
||||
w->at(4).value() << NC::fmtBold << Config.color1 << "Bitrate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps" << NC::clEnd;
|
||||
w->at(5).value() << NC::fmtBold << Config.color1 << "Sample rate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz" << NC::clEnd;
|
||||
w->at(6).value() << NC::fmtBold << Config.color1 << "Channels: " << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << NC::clDefault;
|
||||
|
||||
unsigned pos = 8;
|
||||
for (const SongInfo::Metadata *m = SongInfo::Tags; m->Name; ++m, ++pos)
|
||||
{
|
||||
w->at(pos).value() << fmtBold << m->Name << ":" << fmtBoldEnd << ' ';
|
||||
w->at(pos).value() << NC::fmtBold << m->Name << ":" << NC::fmtBoldEnd << ' ';
|
||||
ShowTag(w->at(pos).value(), itsEdited.getTags(m->Get));
|
||||
}
|
||||
|
||||
w->at(20).value() << fmtBold << "Filename:" << fmtBoldEnd << ' ' << itsEdited.getName();
|
||||
w->at(20).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << itsEdited.getName();
|
||||
|
||||
w->at(22).value() << "Save";
|
||||
w->at(23).value() << "Cancel";
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "mutable_song.h"
|
||||
#include "screen.h"
|
||||
|
||||
class TinyTagEditor : public Screen< Menu<Buffer> >
|
||||
class TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
|
||||
{
|
||||
public:
|
||||
virtual void Resize();
|
||||
@@ -45,7 +45,7 @@ class TinyTagEditor : public Screen< Menu<Buffer> >
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
virtual List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool isMergable() { return true; }
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#ifdef ENABLE_VISUALIZER
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@@ -33,6 +31,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
|
||||
using Global::MainStartY;
|
||||
using Global::MainHeight;
|
||||
|
||||
@@ -42,7 +44,7 @@ const int Visualizer::WindowTimeout = 1000/25; /* 25 fps */
|
||||
|
||||
void Visualizer::Init()
|
||||
{
|
||||
w = new Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, brNone);
|
||||
w = new NC::Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, NC::brNone);
|
||||
|
||||
ResetFD();
|
||||
itsSamples = Config.visualizer_in_stereo ? 4096 : 2048;
|
||||
@@ -173,7 +175,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
||||
point_pos /= samples_per_col;
|
||||
point_pos /= std::numeric_limits<int16_t>::max();
|
||||
point_pos *= half_height;
|
||||
*w << XY(i, y_offset+half_height+point_pos) << Config.visualizer_chars[0];
|
||||
*w << NC::XY(i, y_offset+half_height+point_pos) << Config.visualizer_chars[0];
|
||||
if (i && abs(prev_point_pos-point_pos) > 2)
|
||||
{
|
||||
// if gap is too big. intermediate values are needed
|
||||
@@ -181,7 +183,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
||||
const int breakpoint = std::max(prev_point_pos, point_pos);
|
||||
const int half = (prev_point_pos+point_pos)/2;
|
||||
for (int k = std::min(prev_point_pos, point_pos)+1; k < breakpoint; k += 2)
|
||||
*w << XY(i-(k < half), y_offset+half_height+k) << Config.visualizer_chars[0];
|
||||
*w << NC::XY(i-(k < half), y_offset+half_height+k) << Config.visualizer_chars[0];
|
||||
}
|
||||
prev_point_pos = point_pos;
|
||||
}
|
||||
@@ -215,7 +217,7 @@ void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t samples, size_t y_o
|
||||
const size_t start_y = y_offset > 0 ? y_offset : height-bar_height;
|
||||
const size_t stop_y = std::min(bar_height+start_y, w->GetHeight());
|
||||
for (size_t j = start_y; j < stop_y; ++j)
|
||||
*w << XY(i, j) << Config.visualizer_chars[1];
|
||||
*w << NC::XY(i, j) << Config.visualizer_chars[1];
|
||||
}
|
||||
}
|
||||
#endif // HAVE_FFTW3_H
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
#ifndef _VISUALIZER_H
|
||||
#define _VISUALIZER_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ENABLE_VISUALIZER
|
||||
|
||||
@@ -34,7 +32,7 @@
|
||||
# include <fftw3.h>
|
||||
#endif
|
||||
|
||||
class Visualizer : public Screen<Window>
|
||||
class Visualizer : public Screen<NC::Window>
|
||||
{
|
||||
public:
|
||||
virtual void SwitchTo();
|
||||
@@ -43,14 +41,14 @@ class Visualizer : public Screen<Window>
|
||||
virtual std::basic_string<my_char_t> Title();
|
||||
|
||||
virtual void Update();
|
||||
virtual void Scroll(Where) { }
|
||||
virtual void Scroll(NC::Where) { }
|
||||
|
||||
virtual void EnterPressed() { }
|
||||
virtual void SpacePressed();
|
||||
virtual void MouseButtonPressed(MEVENT) { }
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
virtual NCurses::List *GetList() { return 0; }
|
||||
virtual NC::List *GetList() { return 0; }
|
||||
|
||||
virtual bool allowsSelection() { return false; }
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
#include "utility/string.h"
|
||||
#include "window.h"
|
||||
|
||||
using namespace NCurses;
|
||||
namespace NC {//
|
||||
|
||||
void NCurses::InitScreen(GNUC_UNUSED const char *window_title, bool enable_colors)
|
||||
void InitScreen(GNUC_UNUSED const char *window_title, bool enable_colors)
|
||||
{
|
||||
const int ColorsTable[] =
|
||||
{
|
||||
@@ -65,7 +65,7 @@ void NCurses::InitScreen(GNUC_UNUSED const char *window_title, bool enable_color
|
||||
curs_set(0);
|
||||
}
|
||||
|
||||
void NCurses::DestroyScreen()
|
||||
void DestroyScreen()
|
||||
{
|
||||
curs_set(1);
|
||||
endwin();
|
||||
@@ -919,7 +919,7 @@ size_t Window::Length(const std::wstring &ws)
|
||||
# endif // WIN32
|
||||
}
|
||||
|
||||
void Window::Cut (std::wstring &ws, size_t max_len)
|
||||
void Window::Cut(std::wstring &ws, size_t max_len)
|
||||
{
|
||||
size_t i = 0;
|
||||
int remained_len = max_len;
|
||||
@@ -933,3 +933,5 @@ void Window::Cut (std::wstring &ws, size_t max_len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -118,10 +118,10 @@
|
||||
# define wcwidth(x) int(!iscntrl(x))
|
||||
#endif
|
||||
|
||||
/// NCurses namespace provides set of easy-to-use
|
||||
/// NC namespace provides set of easy-to-use
|
||||
/// wrappers over original curses library
|
||||
///
|
||||
namespace NCurses
|
||||
namespace NC
|
||||
{
|
||||
/// Colors used by NCurses
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user