summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions.cpp28
-rw-r--r--src/browser.cpp2
-rw-r--r--src/clock.cpp12
-rw-r--r--src/display.cpp14
-rw-r--r--src/help.cpp8
-rw-r--r--src/helpers.h18
-rw-r--r--src/lastfm.cpp4
-rw-r--r--src/lastfm_service.cpp4
-rw-r--r--src/lyrics.cpp6
-rw-r--r--src/media_library.cpp6
-rw-r--r--src/menu.h10
-rw-r--r--src/ncmpcpp.cpp6
-rw-r--r--src/outputs.cpp2
-rw-r--r--src/playlist.cpp2
-rw-r--r--src/playlist_editor.cpp4
-rw-r--r--src/screen.cpp4
-rw-r--r--src/search_engine.cpp18
-rw-r--r--src/server_info.cpp20
-rw-r--r--src/settings.cpp73
-rw-r--r--src/song_info.cpp20
-rw-r--r--src/status.cpp32
-rw-r--r--src/statusbar.cpp10
-rw-r--r--src/tag_editor.cpp22
-rw-r--r--src/tiny_tag_editor.cpp28
-rw-r--r--src/title.cpp10
-rw-r--r--src/utility/type_conversions.cpp44
-rw-r--r--src/utility/type_conversions.h4
-rw-r--r--src/visualizer.cpp2
-rw-r--r--src/window.cpp76
-rw-r--r--src/window.h32
30 files changed, 270 insertions, 251 deletions
diff --git a/src/actions.cpp b/src/actions.cpp
index f9a1d3dc..8106c619 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -268,7 +268,7 @@ bool askYesNoQuestion(const std::string &question, void (*callback)())
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << question << " [" << NC::fmtBold << 'y' << NC::fmtBoldEnd << '/' << NC::fmtBold << 'n' << NC::fmtBoldEnd << "]";
+ Statusbar::put() << question << " [" << NC::Format::Bold << 'y' << NC::Format::NoBold << '/' << NC::Format::Bold << 'n' << NC::Format::NoBold << "]";
wFooter->refresh();
int answer = 0;
do
@@ -816,7 +816,7 @@ void ExecuteCommand::run()
{
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << ":" << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << ":" << NC::Format::NoBold;
wFooter->setGetStringHelper(Statusbar::Helpers::TryExecuteImmediateCommand());
std::string name = wFooter->getString();
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
@@ -1236,7 +1236,7 @@ void EditLibraryTag::run()
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << tagTypeToString(Config.media_lib_primary_tag) << NC::fmtBoldEnd << ": ";
+ Statusbar::put() << NC::Format::Bold << tagTypeToString(Config.media_lib_primary_tag) << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->getString(myLibrary->Tags.current().value().tag());
Statusbar::unlock();
if (!new_tag.empty() && new_tag != myLibrary->Tags.current().value().tag())
@@ -1292,7 +1292,7 @@ void EditLibraryAlbum::run()
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << "Album: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "Album: " << NC::Format::NoBold;
std::string new_album = wFooter->getString(myLibrary->Albums.current().value().entry().album());
Statusbar::unlock();
if (!new_album.empty() && new_album != myLibrary->Albums.current().value().entry().album())
@@ -1350,7 +1350,7 @@ void EditDirectoryName::run()
{
std::string old_dir = myBrowser->main().current().value().name;
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "Directory: " << NC::Format::NoBold;
std::string new_dir = wFooter->getString(old_dir);
Statusbar::unlock();
if (!new_dir.empty() && new_dir != old_dir)
@@ -1384,7 +1384,7 @@ void EditDirectoryName::run()
{
std::string old_dir = myTagEditor->Dirs->current().value().first;
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << "Directory: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "Directory: " << NC::Format::NoBold;
std::string new_dir = wFooter->getString(old_dir);
Statusbar::unlock();
if (!new_dir.empty() && new_dir != old_dir)
@@ -1426,7 +1426,7 @@ void EditPlaylistName::run()
else
old_name = myBrowser->main().current().value().name;
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << "Playlist: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "Playlist: " << NC::Format::NoBold;
std::string new_name = wFooter->getString(old_name);
Statusbar::unlock();
if (!new_name.empty() && new_name != old_name)
@@ -1765,7 +1765,7 @@ void ApplyFilter::run()
std::string filter = f->currentFilter();
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << "Apply filter: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "Apply filter: " << NC::Format::NoBold;
wFooter->setGetStringHelper(Statusbar::Helpers::ApplyFilterImmediately(f, ToWString(filter)));
wFooter->getString(filter);
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
@@ -1811,7 +1811,7 @@ void Find::run()
Statusbar::msg("Searching...");
auto s = static_cast<Screen<NC::Scrollpad> *>(myScreen);
s->main().removeProperties();
- Statusbar::msg("%s", findme.empty() || s->main().setProperties(NC::fmtReverse, findme, NC::fmtReverseEnd) ? "Done" : "No matching patterns found");
+ Statusbar::msg("%s", findme.empty() || s->main().setProperties(NC::Format::Reverse, findme, NC::Format::NoReverse) ? "Done" : "No matching patterns found");
s->main().flush();
}
@@ -1874,7 +1874,7 @@ void ToggleReplayGainMode::run()
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << "Replay gain mode? [" << NC::fmtBold << 'o' << NC::fmtBoldEnd << "ff/" << NC::fmtBold << 't' << NC::fmtBoldEnd << "rack/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "lbum]";
+ Statusbar::put() << "Replay gain mode? [" << NC::Format::Bold << 'o' << NC::Format::NoBold << "ff/" << NC::Format::Bold << 't' << NC::Format::NoBold << "rack/" << NC::Format::Bold << 'a' << NC::Format::NoBold << "lbum]";
wFooter->refresh();
int answer = 0;
do
@@ -1918,7 +1918,7 @@ void AddRandomItems::run()
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << "Add random? [" << NC::fmtBold << 's' << NC::fmtBoldEnd << "ongs/" << NC::fmtBold << 'a' << NC::fmtBoldEnd << "rtists/al" << NC::fmtBold << 'b' << NC::fmtBoldEnd << "ums] ";
+ Statusbar::put() << "Add random? [" << NC::Format::Bold << 's' << NC::Format::NoBold << "ongs/" << NC::Format::Bold << 'a' << NC::Format::NoBold << "rtists/al" << NC::Format::Bold << 'b' << NC::Format::NoBold << "ums] ";
wFooter->refresh();
int answer = 0;
do
@@ -1988,7 +1988,7 @@ void ToggleLibraryTagType::run()
using Global::wFooter;
Statusbar::lock();
- Statusbar::put() << "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] ";
+ Statusbar::put() << "Tag type? [" << NC::Format::Bold << 'a' << NC::Format::NoBold << "rtist/album" << NC::Format::Bold << 'A' << NC::Format::NoBold << "rtist/" << NC::Format::Bold << 'y' << NC::Format::NoBold << "ear/" << NC::Format::Bold << 'g' << NC::Format::NoBold << "enre/" << NC::Format::Bold << 'c' << NC::Format::NoBold << "omposer/" << NC::Format::Bold << 'p' << NC::Format::NoBold << "erformer] ";
wFooter->refresh();
int answer = 0;
do
@@ -2603,7 +2603,7 @@ void seek()
else
break;
- *wFooter << NC::fmtBold;
+ *wFooter << NC::Format::Bold;
std::string tracklength;
if (Config.new_design)
{
@@ -2634,7 +2634,7 @@ void seek()
tracklength += "]";
*wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength;
}
- *wFooter << NC::fmtBoldEnd;
+ *wFooter << NC::Format::NoBold;
Progressbar::draw(songpos, Mpd.GetTotalTime());
wFooter->refresh();
}
diff --git a/src/browser.cpp b/src/browser.cpp
index 56990b75..e39f4f4e 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -65,7 +65,7 @@ bool BrowserEntryMatcher(const Regex &rx, const MPD::Item &item, bool filter);
Browser::Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/")
{
- w = NC::Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
+ w = NC::Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::Border::None);
w.setHighlightColor(Config.main_highlight_color);
w.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor);
diff --git a/src/clock.cpp b/src/clock.cpp
index 12970323..ff08af43 100644
--- a/src/clock.cpp
+++ b/src/clock.cpp
@@ -57,7 +57,7 @@ Clock::Clock()
{
Width = Config.clock_display_seconds ? 60 : 40;
- m_pane = NC::Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
+ m_pane = NC::Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None);
w = NC::Window((COLS-Width)/2, (MainHeight-Height)/2+MainStartY, Width, Height-1, "", Config.main_color, NC::Border(Config.main_color));
}
@@ -115,7 +115,7 @@ void Clock::update()
myPlaylist->switchTo();
}
- tm *time = localtime(&Global::Timer.tv_sec);
+ std::tm *time = std::localtime(&Global::Timer.tv_sec);
mask = 0;
Set(time->tm_sec % 10, 0);
@@ -128,10 +128,10 @@ void Clock::update()
Set(10, 17);
char buf[64];
- strftime(buf, 64, "%x", time);
- attron(COLOR_PAIR(Config.main_color));
+ std::strftime(buf, 64, "%x", time);
+ attron(COLOR_PAIR(int(Config.main_color)));
mvprintw(w.getStarty()+w.getHeight(), w.getStartX()+(w.getWidth()-strlen(buf))/2, "%s", buf);
- attroff(COLOR_PAIR(Config.main_color));
+ attroff(COLOR_PAIR(int(Config.main_color)));
refresh();
for (int k = 0; k < 6; ++k)
@@ -140,7 +140,7 @@ void Clock::update()
next[k] = 0;
for (int s = 1; s >= 0; --s)
{
- w << (s ? NC::fmtReverse : NC::fmtReverseEnd);
+ w << (s ? NC::Format::Reverse : NC::Format::NoReverse);
for (int i = 0; i < 6; ++i)
{
long a = (newer[i] ^ older[i]) & (s ? newer : older)[i];
diff --git a/src/display.cpp b/src/display.cpp
index aa997331..cf3c330b 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -88,7 +88,7 @@ void setProperties(NC::Menu<T> &menu, const MPD::Song &s, const ProxySongList &p
}
if (separate_albums)
{
- menu << NC::fmtUnderline;
+ menu << NC::Format::Underline;
mvwhline(menu.raw(), menu.getY(), 0, KEY_SPACE, menu.getWidth());
}
@@ -157,7 +157,7 @@ void showSongs(NC::Menu<T> &menu, const MPD::Song &s, const ProxySongList &pl, c
if (is_now_playing)
menu << Config.now_playing_suffix;
if (separate_albums)
- menu << NC::fmtUnderlineEnd;
+ menu << NC::Format::NoUnderline;
}
template <typename T>
@@ -232,7 +232,7 @@ void showSongsInColumns(NC::Menu<T> &menu, const MPD::Song &s, const ProxySongLi
tag = ToWString(Config.empty_tag);
wideCut(tag, width);
- if (!discard_colors && it->color != NC::clDefault)
+ if (!discard_colors && it->color != NC::Color::Default)
menu << it->color;
int x_off = 0;
@@ -252,8 +252,8 @@ void showSongsInColumns(NC::Menu<T> &menu, const MPD::Song &s, const ProxySongLi
remained_width -= width+1;
}
- if (!discard_colors && it->color != NC::clDefault)
- menu << NC::clEnd;
+ if (!discard_colors && it->color != NC::Color::Default)
+ menu << NC::Color::End;
}
// here comes the shitty part, second chapter. here we apply
@@ -272,7 +272,7 @@ void showSongsInColumns(NC::Menu<T> &menu, const MPD::Song &s, const ProxySongLi
menu.goToXY(menu.getWidth() - Config.selected_item_suffix_length, y);
if (separate_albums)
- menu << NC::fmtUnderlineEnd;
+ menu << NC::Format::NoUnderline;
}
}
@@ -374,7 +374,7 @@ void Display::Tags(NC::Menu<MPD::MutableSong> &menu)
menu << Charset::utf8ToLocale(s.getName());
else
menu << Charset::utf8ToLocale(s.getName())
- << Config.color2 << " -> " << NC::clEnd
+ << Config.color2 << " -> " << NC::Color::End
<< Charset::utf8ToLocale(s.getNewURI());
}
}
diff --git a/src/help.cpp b/src/help.cpp
index 8c03e000..47821150 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -97,7 +97,7 @@ std::string keyToString(const Key &key, bool *print_backspace)
}
Help::Help()
-: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
{
GetKeybindings();
w.flush();
@@ -144,8 +144,8 @@ std::string Help::DisplayKeys(const Actions::Type at)
void Help::Section(const char *type_, const char *title_)
{
- w << "\n " << NC::fmtBold << type_ << " - ";
- w << title_ << NC::fmtBoldEnd << "\n\n";
+ w << "\n " << NC::Format::Bold << type_ << " - ";
+ w << title_ << NC::Format::NoBold << "\n\n";
}
void Help::KeyDesc(const Actions::Type at, const char *desc)
@@ -162,7 +162,7 @@ void Help::MouseDesc(std::string action, const char *desc, bool indent)
void Help::MouseColumn(const char *column)
{
- w << NC::fmtBold << " " << column << " column:\n" << NC::fmtBoldEnd;
+ w << NC::Format::Bold << " " << column << " column:\n" << NC::Format::NoBold;
}
void Help::GetKeybindings()
diff --git a/src/helpers.h b/src/helpers.h
index 6f5f1b34..b81721a7 100644
--- a/src/helpers.h
+++ b/src/helpers.h
@@ -358,16 +358,16 @@ void stringToBuffer(Iterator first, Iterator last, NC::BasicBuffer<typename Iter
switch (*it)
{
case 'b':
- buf << NC::fmtBold;
+ buf << NC::Format::Bold;
break;
case 'u':
- buf << NC::fmtUnderline;
+ buf << NC::Format::Underline;
break;
case 'a':
- buf << NC::fmtAltCharset;
+ buf << NC::Format::AltCharset;
break;
case 'r':
- buf << NC::fmtReverse;
+ buf << NC::Format::Reverse;
break;
case '/':
if (++it == last)
@@ -378,16 +378,16 @@ void stringToBuffer(Iterator first, Iterator last, NC::BasicBuffer<typename Iter
switch (*it)
{
case 'b':
- buf << NC::fmtBoldEnd;
+ buf << NC::Format::NoBold;
break;
case 'u':
- buf << NC::fmtUnderlineEnd;
+ buf << NC::Format::NoUnderline;
break;
case 'a':
- buf << NC::fmtAltCharsetEnd;
+ buf << NC::Format::NoAltCharset;
break;
case 'r':
- buf << NC::fmtReverseEnd;
+ buf << NC::Format::NoReverse;
break;
default:
buf << '$' << *--it;
@@ -464,7 +464,7 @@ template <typename T> void ShowTime(T &buf, size_t length, bool short_names)
template <typename BufferT> void ShowTag(BufferT &buf, const std::string &tag)
{
if (tag.empty())
- buf << Config.empty_tags_color << Config.empty_tag << NC::clEnd;
+ buf << Config.empty_tags_color << Config.empty_tag << NC::Color::End;
else
buf << tag;
}
diff --git a/src/lastfm.cpp b/src/lastfm.cpp
index 85a68333..93896793 100644
--- a/src/lastfm.cpp
+++ b/src/lastfm.cpp
@@ -47,7 +47,7 @@ using Global::MainStartY;
Lastfm *myLastfm;
Lastfm::Lastfm()
-: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
, isReadyToTake(0), isDownloadInProgress(0)
{ }
@@ -174,7 +174,7 @@ void Lastfm::Download()
itsService->colorizeOutput(w);
}
else
- w << NC::clRed << result.second << NC::clEnd;
+ w << NC::Color::Red << result.second << NC::Color::End;
isReadyToTake = 1;
}
diff --git a/src/lastfm_service.cpp b/src/lastfm_service.cpp
index cb30635e..c2e32516 100644
--- a/src/lastfm_service.cpp
+++ b/src/lastfm_service.cpp
@@ -104,8 +104,8 @@ bool ArtistInfo::checkArgs(const Args &args)
void ArtistInfo::colorizeOutput(NC::Scrollpad &w)
{
- w.setProperties(NC::fmtBold, "\n\nSimilar artists:\n", NC::fmtBoldEnd, 0);
- w.setProperties(Config.color2, "\n * ", NC::clEnd, 0);
+ w.setProperties(NC::Format::Bold, "\n\nSimilar artists:\n", NC::Format::NoBold, 0);
+ w.setProperties(Config.color2, "\n * ", NC::Color::End, 0);
}
bool ArtistInfo::parse(std::string &data)
diff --git a/src/lyrics.cpp b/src/lyrics.cpp
index 77b2df41..b14b5d0c 100644
--- a/src/lyrics.cpp
+++ b/src/lyrics.cpp
@@ -50,7 +50,7 @@ size_t Lyrics::itsWorkersNumber = 0;
Lyrics *myLyrics;
Lyrics::Lyrics()
-: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
, ReloadNP(0),
#ifdef HAVE_CURL_CURL_H
isReadyToTake(0), isDownloadInProgress(0),
@@ -235,10 +235,10 @@ void *Lyrics::Download()
bool fetcher_defined = itsFetcher && *itsFetcher;
for (LyricsFetcher **plugin = fetcher_defined ? itsFetcher : lyricsPlugins; *plugin != 0; ++plugin)
{
- w << "Fetching lyrics from " << NC::fmtBold << (*plugin)->name() << NC::fmtBoldEnd << "... ";
+ w << "Fetching lyrics from " << NC::Format::Bold << (*plugin)->name() << NC::Format::NoBold << "... ";
result = (*plugin)->fetch(artist, title_);
if (result.first == false)
- w << NC::clRed << result.second << NC::clEnd << '\n';
+ w << NC::Color::Red << result.second << NC::Color::End << '\n';
else
break;
if (fetcher_defined)
diff --git a/src/media_library.cpp b/src/media_library.cpp
index ffea08d5..0e5b4202 100644
--- a/src/media_library.cpp
+++ b/src/media_library.cpp
@@ -147,7 +147,7 @@ MediaLibrary::MediaLibrary()
itsRightColWidth = COLS-COLS/3*2-1;
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
- Tags = NC::Menu<PrimaryTag>(0, MainStartY, itsLeftColWidth, MainHeight, Config.titles_visibility ? tagTypeToString(Config.media_lib_primary_tag) + "s" : "", Config.main_color, NC::brNone);
+ Tags = NC::Menu<PrimaryTag>(0, MainStartY, itsLeftColWidth, MainHeight, Config.titles_visibility ? tagTypeToString(Config.media_lib_primary_tag) + "s" : "", Config.main_color, NC::Border::None);
Tags.setHighlightColor(Config.active_column_color);
Tags.cyclicScrolling(Config.use_cyclic_scrolling);
Tags.centeredCursor(Config.centered_cursor);
@@ -161,7 +161,7 @@ MediaLibrary::MediaLibrary()
menu << Charset::utf8ToLocale(tag);
});
- Albums = NC::Menu<AlbumEntry>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::brNone);
+ Albums = NC::Menu<AlbumEntry>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::Border::None);
Albums.setHighlightColor(Config.main_highlight_color);
Albums.cyclicScrolling(Config.use_cyclic_scrolling);
Albums.centeredCursor(Config.centered_cursor);
@@ -171,7 +171,7 @@ MediaLibrary::MediaLibrary()
menu << Charset::utf8ToLocale(AlbumToString(menu.drawn()->value()));
});
- Songs = NC::Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, NC::brNone);
+ Songs = NC::Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, NC::Border::None);
Songs.setHighlightColor(Config.main_highlight_color);
Songs.cyclicScrolling(Config.use_cyclic_scrolling);
Songs.centeredCursor(Config.centered_cursor);
diff --git a/src/menu.h b/src/menu.h
index ab1a9f7e..b3a2e2c3 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -631,10 +631,10 @@ template <typename T> void Menu<T>::refresh()
continue;
}
if ((*m_options_ptr)[i]->isBold())
- *this << fmtBold;
+ *this << Format::Bold;
if (m_highlight_enabled && i == m_highlight)
{
- *this << fmtReverse;
+ *this << Format::Reverse;
*this << m_highlight_color;
}
mvwhline(m_window, line, 0, KEY_SPACE, m_width);
@@ -646,11 +646,11 @@ template <typename T> void Menu<T>::refresh()
*this << m_selected_suffix;
if (m_highlight_enabled && i == m_highlight)
{
- *this << clEnd;
- *this << fmtReverseEnd;
+ *this << Color::End;
+ *this << Format::NoReverse;
}
if ((*m_options_ptr)[i]->isBold())
- *this << fmtBoldEnd;
+ *this << Format::NoBold;
}
Window::refresh();
}
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp
index 9f33f7c3..a54c50cc 100644
--- a/src/ncmpcpp.cpp
+++ b/src/ncmpcpp.cpp
@@ -145,7 +145,7 @@ int main(int argc, char **argv)
Actions::OriginalStatusbarVisibility = Config.statusbar_visibility;
if (!Config.titles_visibility)
- wattron(stdscr, COLOR_PAIR(Config.main_color));
+ wattron(stdscr, COLOR_PAIR(int(Config.main_color)));
if (Config.new_design)
Config.statusbar_visibility = 0;
@@ -154,11 +154,11 @@ int main(int argc, char **argv)
Actions::validateScreenSize();
Actions::initializeScreens();
- wHeader = new NC::Window(0, 0, COLS, Actions::HeaderHeight, "", Config.header_color, NC::brNone);
+ wHeader = new NC::Window(0, 0, COLS, Actions::HeaderHeight, "", Config.header_color, NC::Border::None);
if (Config.header_visibility || Config.new_design)
wHeader->display();
- wFooter = new NC::Window(0, Actions::FooterStartY, COLS, Actions::FooterHeight, "", Config.statusbar_color, NC::brNone);
+ wFooter = new NC::Window(0, Actions::FooterStartY, COLS, Actions::FooterHeight, "", Config.statusbar_color, NC::Border::None);
wFooter->setTimeout(500);
wFooter->setGetStringHelper(Statusbar::Helpers::getString);
if (Mpd.SupportsIdle())
diff --git a/src/outputs.cpp b/src/outputs.cpp
index b8dfbd9f..60709423 100644
--- a/src/outputs.cpp
+++ b/src/outputs.cpp
@@ -38,7 +38,7 @@ using Global::myScreen;
Outputs *myOutputs;
Outputs::Outputs()
-: Screen(NC::Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
{
w.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor);
diff --git a/src/playlist.cpp b/src/playlist.cpp
index 092d91a9..cef21dfb 100644
--- a/src/playlist.cpp
+++ b/src/playlist.cpp
@@ -53,7 +53,7 @@ bool playlistEntryMatcher(const Regex &rx, const MPD::Song &s);
Playlist::Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0)
{
- w = NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
+ w = NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::Border::None);
w.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor);
w.setHighlightColor(Config.main_highlight_color);
diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp
index ff9ff170..8ee45a7c 100644
--- a/src/playlist_editor.cpp
+++ b/src/playlist_editor.cpp
@@ -62,7 +62,7 @@ PlaylistEditor::PlaylistEditor()
RightColumnStartX = LeftColumnWidth+1;
RightColumnWidth = COLS-LeftColumnWidth-1;
- Playlists = NC::Menu<std::string>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Playlists" : "", Config.main_color, NC::brNone);
+ Playlists = NC::Menu<std::string>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Playlists" : "", Config.main_color, NC::Border::None);
Playlists.setHighlightColor(Config.active_column_color);
Playlists.cyclicScrolling(Config.use_cyclic_scrolling);
Playlists.centeredCursor(Config.centered_cursor);
@@ -72,7 +72,7 @@ PlaylistEditor::PlaylistEditor()
menu << Charset::utf8ToLocale(menu.drawn()->value());
});
- Content = NC::Menu<MPD::Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Playlist content" : "", Config.main_color, NC::brNone);
+ Content = NC::Menu<MPD::Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Playlist content" : "", Config.main_color, NC::Border::None);
Content.setHighlightColor(Config.main_highlight_color);
Content.cyclicScrolling(Config.use_cyclic_scrolling);
Content.centeredCursor(Config.centered_cursor);
diff --git a/src/screen.cpp b/src/screen.cpp
index 24869e6a..0dadd4a1 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -32,9 +32,9 @@ namespace {//
void drawScreenSeparator(int x)
{
- attron(COLOR_PAIR(Config.main_color));
+ attron(COLOR_PAIR(int(Config.main_color)));
mvvline(Global::MainStartY, x, 0, Global::MainHeight);
- attroff(COLOR_PAIR(Config.main_color));
+ attroff(COLOR_PAIR(int(Config.main_color)));
refresh();
}
diff --git a/src/search_engine.cpp b/src/search_engine.cpp
index fbfbbb9c..be61a912 100644
--- a/src/search_engine.cpp
+++ b/src/search_engine.cpp
@@ -103,7 +103,7 @@ size_t SearchEngine::ResetButton = 16;
size_t SearchEngine::SearchButton = 15;
SearchEngine::SearchEngine()
-: Screen(NC::Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
{
w.setHighlightColor(Config.main_highlight_color);
w.cyclicScrolling(Config.use_cyclic_scrolling);
@@ -149,23 +149,23 @@ void SearchEngine::enterPressed()
if (option < ConstraintsNumber)
{
std::string constraint = ConstraintsNames[option];
- Statusbar::put() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
+ Statusbar::put() << NC::Format::Bold << constraint << NC::Format::NoBold << ": ";
itsConstraints[option] = Global::wFooter->getString(itsConstraints[option]);
w.current().value().buffer().clear();
constraint.resize(13, ' ');
- w.current().value().buffer() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
+ w.current().value().buffer() << NC::Format::Bold << constraint << NC::Format::NoBold << ": ";
ShowTag(w.current().value().buffer(), itsConstraints[option]);
}
else if (option == ConstraintsNumber+1)
{
Config.search_in_db = !Config.search_in_db;
- w.current().value().buffer() << NC::fmtBold << "Search in:" << NC::fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
+ w.current().value().buffer() << NC::Format::Bold << "Search in:" << NC::Format::NoBold << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
}
else if (option == ConstraintsNumber+2)
{
if (!*++SearchMode)
SearchMode = &SearchModes[0];
- w.current().value().buffer() << NC::fmtBold << "Search mode:" << NC::fmtBoldEnd << ' ' << *SearchMode;
+ w.current().value().buffer() << NC::Format::Bold << "Search mode:" << NC::Format::NoBold << ' ' << *SearchMode;
}
else if (option == SearchButton)
{
@@ -182,7 +182,7 @@ 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") << NC::clDefault;
+ w.at(ResetButton+2).value().mkBuffer() << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << NC::Color::Default;
w.insertSeparator(ResetButton+3);
markSongsInPlaylist(proxySongList());
Statusbar::msg("Searching finished");
@@ -351,12 +351,12 @@ void SearchEngine::Prepare()
{
std::string constraint = ConstraintsNames[i];
constraint.resize(13, ' ');
- w[i].value().mkBuffer() << NC::fmtBold << constraint << NC::fmtBoldEnd << ": ";
+ w[i].value().mkBuffer() << NC::Format::Bold << constraint << NC::Format::NoBold << ": ";
ShowTag(w[i].value().buffer(), itsConstraints[i]);
}
- 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(ConstraintsNumber+1).value().mkBuffer() << NC::Format::Bold << "Search in:" << NC::Format::NoBold << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
+ w.at(ConstraintsNumber+2).value().mkBuffer() << NC::Format::Bold << "Search mode:" << NC::Format::NoBold << ' ' << *SearchMode;
w.at(SearchButton).value().mkBuffer() << "Search";
w.at(ResetButton).value().mkBuffer() << "Reset";
diff --git a/src/server_info.cpp b/src/server_info.cpp
index 7223a72d..c4ea6658 100644
--- a/src/server_info.cpp
+++ b/src/server_info.cpp
@@ -84,26 +84,26 @@ void ServerInfo::update()
w.clear();
- w << NC::fmtBold << "Version: " << NC::fmtBoldEnd << "0." << Mpd.Version() << ".*\n";
- w << NC::fmtBold << "Uptime: " << NC::fmtBoldEnd;
+ w << NC::Format::Bold << "Version: " << NC::Format::NoBold << "0." << Mpd.Version() << ".*\n";
+ w << NC::Format::Bold << "Uptime: " << NC::Format::NoBold;
ShowTime(w, stats.uptime(), 1);
w << '\n';
- w << NC::fmtBold << "Time playing: " << NC::fmtBoldEnd << MPD::Song::ShowTime(stats.playTime()) << '\n';
+ w << NC::Format::Bold << "Time playing: " << NC::Format::NoBold << MPD::Song::ShowTime(stats.playTime()) << '\n';
w << '\n';
- w << NC::fmtBold << "Total playtime: " << NC::fmtBoldEnd;
+ w << NC::Format::Bold << "Total playtime: " << NC::Format::NoBold;
ShowTime(w, stats.dbPlayTime(), 1);
w << '\n';
- w << NC::fmtBold << "Artist names: " << NC::fmtBoldEnd << stats.artists() << '\n';
- w << NC::fmtBold << "Album names: " << NC::fmtBoldEnd << stats.albums() << '\n';
- w << NC::fmtBold << "Songs in database: " << NC::fmtBoldEnd << stats.songs() << '\n';
+ w << NC::Format::Bold << "Artist names: " << NC::Format::NoBold << stats.artists() << '\n';
+ w << NC::Format::Bold << "Album names: " << NC::Format::NoBold << stats.albums() << '\n';
+ w << NC::Format::Bold << "Songs in database: " << NC::Format::NoBold << stats.songs() << '\n';
w << '\n';
- w << NC::fmtBold << "Last DB update: " << NC::fmtBoldEnd << Timestamp(stats.dbUpdateTime()) << '\n';
+ w << NC::Format::Bold << "Last DB update: " << NC::Format::NoBold << Timestamp(stats.dbUpdateTime()) << '\n';
w << '\n';
- w << NC::fmtBold << "URL Handlers:" << NC::fmtBoldEnd;
+ w << NC::Format::Bold << "URL Handlers:" << NC::Format::NoBold;
for (auto it = itsURLHandlers.begin(); it != itsURLHandlers.end(); ++it)
w << (it != itsURLHandlers.begin() ? ", " : " ") << *it;
w << "\n\n";
- w << NC::fmtBold << "Tag Types:" << NC::fmtBoldEnd;
+ w << NC::Format::Bold << "Tag Types:" << NC::Format::NoBold;
for (auto it = itsTagTypes.begin(); it != itsTagTypes.end(); ++it)
w << (it != itsTagTypes.begin() ? ", " : " ") << *it;
diff --git a/src/settings.cpp b/src/settings.cpp
index 07181fee..c97f4327 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -58,35 +58,6 @@ Configuration Config;
namespace
{
- NC::Color stringToColor(const std::string &color)
- {
- NC::Color result = NC::clDefault;
-
- if (color == "black")
- result = NC::clBlack;
- else if (color == "red")
- result = NC::clRed;
- else if (color == "green")
- result = NC::clGreen;
- else if (color == "yellow")
- result = NC::clYellow;
- else if (color == "blue")
- result = NC::clBlue;
- else if (color == "magenta")
- result = NC::clMagenta;
- else if (color == "cyan")
- result = NC::clCyan;
- else if (color == "white")
- result = NC::clWhite;
-
- return result;
- }
-
- NC::Border stringToBorder(const std::string &border)
- {
- return NC::Border(stringToColor(border));
- }
-
ScreenRef intToScreen(int n)
{
switch (n)
@@ -173,32 +144,32 @@ 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 << NC::clRed << "playlist" << NC::clEnd << ' ';
+ browser_playlist_prefix << NC::Color::Red << "playlist" << NC::Color::End << ' ';
progressbar = L"=>\0";
visualizer_chars = L"◆│";
pattern = "%n - %t";
- selected_item_prefix << NC::clMagenta;
- selected_item_suffix << NC::clEnd;
- now_playing_prefix << NC::fmtBold;
- now_playing_suffix << NC::fmtBoldEnd;
- modified_item_prefix << NC::clGreen << "> " << NC::clEnd;
- 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;
+ selected_item_prefix << NC::Color::Magenta;
+ selected_item_suffix << NC::Color::End;
+ now_playing_prefix << NC::Format::Bold;
+ now_playing_suffix << NC::Format::NoBold;
+ modified_item_prefix << NC::Color::Green << "> " << NC::Color::End;
+ color1 = NC::Color::White;
+ color2 = NC::Color::Green;
+ empty_tags_color = NC::Color::Cyan;
+ header_color = NC::Color::Default;
+ volume_color = NC::Color::Default;
+ state_line_color = NC::Color::Default;
+ state_flags_color = NC::Color::Default;
+ main_color = NC::Color::Yellow;
main_highlight_color = main_color;
- 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;
+ progressbar_color = NC::Color::Default;
+ progressbar_elapsed_color = NC::Color::Default;
+ statusbar_color = NC::Color::Default;
+ alternative_ui_separator_color = NC::Color::Black;
+ active_column_color = NC::Color::Red;
+ window_border = NC::Border::Green;
+ active_window_border = NC::Border::Red;
+ visualizer_color = NC::Color::Yellow;
media_lib_primary_tag = MPD_TAG_ARTIST;
enable_idle_notifications = true;
colors_enabled = true;
diff --git a/src/song_info.cpp b/src/song_info.cpp
index 01b907ca..6170ee78 100644
--- a/src/song_info.cpp
+++ b/src/song_info.cpp
@@ -52,7 +52,7 @@ const SongInfo::Metadata SongInfo::Tags[] =
};
SongInfo::SongInfo()
-: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
{ }
void SongInfo::resize()
@@ -101,24 +101,24 @@ void SongInfo::PrepareSong(MPD::Song &s)
TagLib::FileRef f(path_to_file.c_str());
# endif // HAVE_TAGLIB_H
- w << NC::fmtBold << Config.color1 << "Filename: " << NC::fmtBoldEnd << Config.color2 << s.getName() << '\n' << NC::clEnd;
- w << NC::fmtBold << "Directory: " << NC::fmtBoldEnd << Config.color2;
+ w << NC::Format::Bold << Config.color1 << "Filename: " << NC::Format::NoBold << Config.color2 << s.getName() << '\n' << NC::Color::End;
+ w << NC::Format::Bold << "Directory: " << NC::Format::NoBold << Config.color2;
ShowTag(w, s.getDirectory());
- w << "\n\n" << NC::clEnd;
- w << NC::fmtBold << "Length: " << NC::fmtBoldEnd << Config.color2 << s.getLength() << '\n' << NC::clEnd;
+ w << "\n\n" << NC::Color::End;
+ w << NC::Format::Bold << "Length: " << NC::Format::NoBold << Config.color2 << s.getLength() << '\n' << NC::Color::End;
# ifdef HAVE_TAGLIB_H
if (!f.isNull())
{
- w << NC::fmtBold << "Bitrate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << NC::clEnd;
- w << NC::fmtBold << "Sample rate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << NC::clEnd;
- w << NC::fmtBold << "Channels: " << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << '\n' << NC::clDefault;
+ w << NC::Format::Bold << "Bitrate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << NC::Color::End;
+ w << NC::Format::Bold << "Sample rate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << NC::Color::End;
+ w << NC::Format::Bold << "Channels: " << NC::Format::NoBold << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << '\n' << NC::Color::Default;
}
# endif // HAVE_TAGLIB_H
- w << NC::clDefault;
+ w << NC::Color::Default;
for (const Metadata *m = Tags; m->Name; ++m)
{
- w << NC::fmtBold << '\n' << m->Name << ": " << NC::fmtBoldEnd;
+ w << NC::Format::Bold << '\n' << m->Name << ": " << NC::Format::NoBold;
ShowTag(w, s.getTags(m->Get, Config.tags_separator));
}
}
diff --git a/src/status.cpp b/src/status.cpp
index 240093cd..e11e50c4 100644
--- a/src/status.cpp
+++ b/src/status.cpp
@@ -252,7 +252,7 @@ void Status::Changes::playerState()
if (Config.new_design)
{
- *wHeader << NC::XY(0, 1) << NC::fmtBold << player_state << NC::fmtBoldEnd;
+ *wHeader << NC::XY(0, 1) << NC::Format::Bold << player_state << NC::Format::NoBold;
wHeader->refresh();
}
else if (Statusbar::isUnlocked() && Config.statusbar_visibility)
@@ -261,7 +261,7 @@ void Status::Changes::playerState()
if (player_state.empty())
*wFooter << wclrtoeol;
else
- *wFooter << NC::fmtBold << player_state << NC::fmtBoldEnd;
+ *wFooter << NC::Format::Bold << player_state << NC::Format::NoBold;
}
}
@@ -346,11 +346,11 @@ void Status::Changes::elapsedTime()
*wHeader << NC::XY(first_start, 0);
writeCyclicBuffer(first, *wHeader, first_line_scroll_begin, COLS-tracklength.length()-VolumeState.length()-1, L" ** ");
- *wHeader << NC::XY(0, 1) << wclrtoeol << NC::fmtBold << player_state << NC::fmtBoldEnd;
+ *wHeader << NC::XY(0, 1) << wclrtoeol << NC::Format::Bold << player_state << NC::Format::NoBold;
*wHeader << NC::XY(second_start, 1);
writeCyclicBuffer(second, *wHeader, second_line_scroll_begin, COLS-player_state.length()-8-2, L" ** ");
- *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState << NC::clEnd;
+ *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState << NC::Color::End;
flags();
}
@@ -383,9 +383,9 @@ void Status::Changes::elapsedTime()
}
NC::WBuffer np_song;
stringToBuffer(ToWString(Charset::utf8ToLocale(np.toString(Config.song_status_format, Config.tags_separator, "$"))), np_song);
- *wFooter << NC::XY(0, 1) << wclrtoeol << NC::fmtBold << player_state << NC::fmtBoldEnd;
+ *wFooter << NC::XY(0, 1) << wclrtoeol << NC::Format::Bold << player_state << NC::Format::NoBold;
writeCyclicBuffer(np_song, *wFooter, playing_song_scroll_begin, wFooter->getWidth()-player_state.length()-tracklength.length(), L" ** ");
- *wFooter << NC::fmtBold << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength << NC::fmtBoldEnd;
+ *wFooter << NC::Format::Bold << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength << NC::Format::NoBold;
}
if (Progressbar::isUnlocked())
Progressbar::draw(Mpd.GetElapsedTime(), Mpd.GetTotalTime());
@@ -444,12 +444,12 @@ void Status::Changes::flags()
switch_state += mpd_crossfade ? mpd_crossfade : '-';
switch_state += mpd_db_updating ? mpd_db_updating : '-';
switch_state += ']';
- *wHeader << NC::XY(COLS-switch_state.length(), 1) << NC::fmtBold << Config.state_flags_color << switch_state << NC::clEnd << NC::fmtBoldEnd;
+ *wHeader << NC::XY(COLS-switch_state.length(), 1) << NC::Format::Bold << Config.state_flags_color << switch_state << NC::Color::End << NC::Format::NoBold;
if (Config.new_design && !Config.header_visibility) // in this case also draw separator
{
- *wHeader << NC::fmtBold << NC::clBlack;
+ *wHeader << NC::Format::Bold << NC::Color::Black;
mvwhline(wHeader->raw(), 2, 0, 0, COLS);
- *wHeader << NC::clEnd << NC::fmtBoldEnd;
+ *wHeader << NC::Color::End << NC::Format::NoBold;
}
wHeader->refresh();
}
@@ -470,19 +470,19 @@ void Status::Changes::flags()
// this is done by raw ncurses because creating another
// window only for handling this is quite silly
- attrset(A_BOLD|COLOR_PAIR(Config.state_line_color));
+ attrset(A_BOLD|COLOR_PAIR(int(Config.state_line_color)));
mvhline(1, 0, 0, COLS);
if (!switch_state.empty())
{
mvprintw(1, COLS-switch_state.length()-3, "[");
- attroff(COLOR_PAIR(Config.state_line_color));
- attron(COLOR_PAIR(Config.state_flags_color));
+ attroff(COLOR_PAIR(int(Config.state_line_color)));
+ attron(COLOR_PAIR(int(Config.state_flags_color)));
mvprintw(1, COLS-switch_state.length()-2, "%s", switch_state.c_str());
- attroff(COLOR_PAIR(Config.state_flags_color));
- attron(COLOR_PAIR(Config.state_line_color));
+ attroff(COLOR_PAIR(int(Config.state_flags_color)));
+ attron(COLOR_PAIR(int(Config.state_line_color)));
mvprintw(1, COLS-2, "]");
}
- attroff(A_BOLD|COLOR_PAIR(Config.state_line_color));
+ attroff(A_BOLD|COLOR_PAIR(int(Config.state_line_color)));
refresh();
}
}
@@ -503,7 +503,7 @@ void Status::Changes::mixer()
}
*wHeader << Config.volume_color;
*wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << VolumeState;
- *wHeader << NC::clEnd;
+ *wHeader << NC::Color::End;
wHeader->refresh();
}
diff --git a/src/statusbar.cpp b/src/statusbar.cpp
index df6882ac..5b13e694 100644
--- a/src/statusbar.cpp
+++ b/src/statusbar.cpp
@@ -46,7 +46,7 @@ void showMessage(int time, const char *format, va_list list)
else
progressbarBlockUpdate = true;
wFooter->goToXY(0, Config.statusbar_visibility);
- *wFooter << NC::fmtBoldEnd;
+ *wFooter << NC::Format::NoBold;
wmove(wFooter->raw(), Config.statusbar_visibility, 0);
vw_printw(wFooter->raw(), format, list);
wclrtoeol(wFooter->raw());
@@ -76,7 +76,7 @@ void Progressbar::draw(unsigned int elapsed, unsigned int time)
unsigned pb_width = wFooter->getWidth();
unsigned howlong = time ? pb_width*elapsed/time : 0;
if (Config.progressbar_boldness)
- *wFooter << NC::fmtBold;
+ *wFooter << NC::Format::Bold;
*wFooter << Config.progressbar_color;
if (Config.progressbar[2] != '\0')
{
@@ -95,11 +95,11 @@ void Progressbar::draw(unsigned int elapsed, unsigned int time)
*wFooter << Config.progressbar[0];
if (howlong < wFooter->getWidth())
*wFooter << Config.progressbar[1];
- *wFooter << NC::clEnd;
+ *wFooter << NC::Color::End;
}
- *wFooter << NC::clEnd;
+ *wFooter << NC::Color::End;
if (Config.progressbar_boldness)
- *wFooter << NC::fmtBoldEnd;
+ *wFooter << NC::Format::NoBold;
}
void Statusbar::lock()
diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp
index be8b8f7b..9a7d6ade 100644
--- a/src/tag_editor.cpp
+++ b/src/tag_editor.cpp
@@ -90,7 +90,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser
PatternsFile = Config.ncmpcpp_directory + "patterns.list";
SetDimensions(0, COLS);
- Dirs = new NC::Menu< std::pair<std::string, std::string> >(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Directories" : "", Config.main_color, NC::brNone);
+ Dirs = new NC::Menu< std::pair<std::string, std::string> >(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Directories" : "", Config.main_color, NC::Border::None);
Dirs->setHighlightColor(Config.active_column_color);
Dirs->cyclicScrolling(Config.use_cyclic_scrolling);
Dirs->centeredCursor(Config.centered_cursor);
@@ -98,7 +98,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser
menu << Charset::utf8ToLocale(menu.drawn()->value().first);
});
- TagTypes = new NC::Menu<std::string>(MiddleColumnStartX, MainStartY, MiddleColumnWidth, MainHeight, Config.titles_visibility ? "Tag types" : "", Config.main_color, NC::brNone);
+ TagTypes = new NC::Menu<std::string>(MiddleColumnStartX, MainStartY, MiddleColumnWidth, MainHeight, Config.titles_visibility ? "Tag types" : "", Config.main_color, NC::Border::None);
TagTypes->setHighlightColor(Config.main_highlight_color);
TagTypes->cyclicScrolling(Config.use_cyclic_scrolling);
TagTypes->centeredCursor(Config.centered_cursor);
@@ -120,7 +120,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser
TagTypes->addItem("Reset");
TagTypes->addItem("Save");
- Tags = new NC::Menu<MPD::MutableSong>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Tags" : "", Config.main_color, NC::brNone);
+ Tags = new NC::Menu<MPD::MutableSong>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Tags" : "", Config.main_color, NC::Border::None);
Tags->setHighlightColor(Config.main_highlight_color);
Tags->cyclicScrolling(Config.use_cyclic_scrolling);
Tags->centeredCursor(Config.centered_cursor);
@@ -315,9 +315,9 @@ void TagEditor::enterPressed()
*FParserLegend << "%p - performer\n";
*FParserLegend << "%d - disc\n";
*FParserLegend << "%C - comment\n\n";
- *FParserLegend << NC::fmtBold << "Files:\n" << NC::fmtBoldEnd;
+ *FParserLegend << NC::Format::Bold << "Files:\n" << NC::Format::NoBold;
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
- *FParserLegend << Config.color2 << " * " << NC::clEnd << (*it)->getName() << '\n';
+ *FParserLegend << Config.color2 << " * " << NC::Color::End << (*it)->getName() << '\n';
FParserLegend->flush();
if (!Patterns.empty())
@@ -378,7 +378,7 @@ void TagEditor::enterPressed()
{
if (FParserUsePreview)
{
- *FParserPreview << NC::fmtBold << s.getName() << ":\n" << NC::fmtBoldEnd;
+ *FParserPreview << NC::Format::Bold << s.getName() << ":\n" << NC::Format::NoBold;
*FParserPreview << ParseFilename(s, Config.pattern, FParserUsePreview) << '\n';
}
else
@@ -398,9 +398,9 @@ void TagEditor::enterPressed()
}
if (!FParserUsePreview)
s.setNewURI(new_file + extension);
- *FParserPreview << file << Config.color2 << " -> " << NC::clEnd;
+ *FParserPreview << file << Config.color2 << " -> " << NC::Color::End;
if (new_file.empty())
- *FParserPreview << Config.empty_tags_color << Config.empty_tag << NC::clEnd;
+ *FParserPreview << Config.empty_tags_color << Config.empty_tag << NC::Color::End;
else
*FParserPreview << new_file << extension;
*FParserPreview << "\n\n";
@@ -493,7 +493,7 @@ void TagEditor::enterPressed()
if (id > 0 && w == TagTypes)
{
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << TagTypes->current().value() << NC::fmtBoldEnd << ": ";
+ Statusbar::put() << NC::Format::Bold << TagTypes->current().value() << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->getString(Tags->current().value().getTags(get, Config.tags_separator));
Statusbar::unlock();
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
@@ -502,7 +502,7 @@ void TagEditor::enterPressed()
else if (w == Tags)
{
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << TagTypes->current().value() << NC::fmtBoldEnd << ": ";
+ Statusbar::put() << NC::Format::Bold << TagTypes->current().value() << NC::Format::NoBold << ": ";
std::string new_tag = wFooter->getString(Tags->current().value().getTags(get, Config.tags_separator));
Statusbar::unlock();
if (new_tag != Tags->current().value().getTags(get, Config.tags_separator))
@@ -527,7 +527,7 @@ void TagEditor::enterPressed()
std::string extension = old_name.substr(last_dot);
old_name = old_name.substr(0, last_dot);
Statusbar::lock();
- Statusbar::put() << NC::fmtBold << "New filename: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "New filename: " << NC::Format::NoBold;
std::string new_name = wFooter->getString(old_name);
Statusbar::unlock();
if (!new_name.empty() && new_name != old_name)
diff --git a/src/tiny_tag_editor.cpp b/src/tiny_tag_editor.cpp
index 5112d107..d06f314c 100644
--- a/src/tiny_tag_editor.cpp
+++ b/src/tiny_tag_editor.cpp
@@ -46,7 +46,7 @@ using Global::MainStartY;
TinyTagEditor *myTinyTagEditor;
TinyTagEditor::TinyTagEditor()
-: Screen(NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
+: Screen(NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border::None))
{
w.setHighlightColor(Config.main_highlight_color);
w.cyclicScrolling(Config.use_cyclic_scrolling);
@@ -102,16 +102,16 @@ void TinyTagEditor::enterPressed()
if (option < 19) // separator after comment
{
size_t pos = option-8;
- Statusbar::put() << NC::fmtBold << SongInfo::Tags[pos].Name << ": " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << SongInfo::Tags[pos].Name << ": " << NC::Format::NoBold;
itsEdited.setTags(SongInfo::Tags[pos].Set, Global::wFooter->getString(
itsEdited.getTags(SongInfo::Tags[pos].Get, Config.tags_separator)), Config.tags_separator);
w.at(option).value().clear();
- w.at(option).value() << NC::fmtBold << SongInfo::Tags[pos].Name << ':' << NC::fmtBoldEnd << ' ';
+ w.at(option).value() << NC::Format::Bold << SongInfo::Tags[pos].Name << ':' << NC::Format::NoBold << ' ';
ShowTag(w.at(option).value(), itsEdited.getTags(SongInfo::Tags[pos].Get, Config.tags_separator));
}
else if (option == 20)
{
- Statusbar::put() << NC::fmtBold << "Filename: " << NC::fmtBoldEnd;
+ Statusbar::put() << NC::Format::Bold << "Filename: " << NC::Format::NoBold;
std::string filename = itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI();
size_t dot = filename.rfind(".");
std::string extension = filename.substr(dot);
@@ -119,7 +119,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() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
+ w.at(option).value() << NC::Format::Bold << "Filename:" << NC::Format::NoBold << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
}
Statusbar::unlock();
@@ -204,23 +204,23 @@ bool TinyTagEditor::getTags()
w.highlight(8);
- 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;
+ w.at(0).value() << NC::Format::Bold << Config.color1 << "Song name: " << NC::Format::NoBold << Config.color2 << itsEdited.getName() << NC::Color::End;
+ w.at(1).value() << NC::Format::Bold << Config.color1 << "Location in DB: " << NC::Format::NoBold << Config.color2;
ShowTag(w.at(1).value(), itsEdited.getDirectory());
- 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;
+ w.at(1).value() << NC::Color::End;
+ w.at(3).value() << NC::Format::Bold << Config.color1 << "Length: " << NC::Format::NoBold << Config.color2 << itsEdited.getLength() << NC::Color::End;
+ w.at(4).value() << NC::Format::Bold << Config.color1 << "Bitrate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->bitrate() << " kbps" << NC::Color::End;
+ w.at(5).value() << NC::Format::Bold << Config.color1 << "Sample rate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->sampleRate() << " Hz" << NC::Color::End;
+ w.at(6).value() << NC::Format::Bold << Config.color1 << "Channels: " << NC::Format::NoBold << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << NC::Color::Default;
unsigned pos = 8;
for (const SongInfo::Metadata *m = SongInfo::Tags; m->Name; ++m, ++pos)
{
- w.at(pos).value() << NC::fmtBold << m->Name << ":" << NC::fmtBoldEnd << ' ';
+ w.at(pos).value() << NC::Format::Bold << m->Name << ":" << NC::Format::NoBold << ' ';
ShowTag(w.at(pos).value(), itsEdited.getTags(m->Get, Config.tags_separator));
}
- w.at(20).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << itsEdited.getName();
+ w.at(20).value() << NC::Format::Bold << "Filename:" << NC::Format::NoBold << ' ' << itsEdited.getName();
w.at(22).value() << "Save";
w.at(23).value() << "Cancel";
diff --git a/src/title.cpp b/src/title.cpp
index f0832436..a0263f8d 100644
--- a/src/title.cpp
+++ b/src/title.cpp
@@ -47,19 +47,19 @@ void drawHeader()
{
std::wstring title = myScreen->title();
*wHeader << NC::XY(0, 3) << wclrtoeol;
- *wHeader << NC::fmtBold << Config.alternative_ui_separator_color;
+ *wHeader << NC::Format::Bold << Config.alternative_ui_separator_color;
mvwhline(wHeader->raw(), 2, 0, 0, COLS);
mvwhline(wHeader->raw(), 4, 0, 0, COLS);
*wHeader << NC::XY((COLS-wideLength(title))/2, 3);
- *wHeader << Config.header_color << title << NC::clEnd;
- *wHeader << NC::clEnd << NC::fmtBoldEnd;
+ *wHeader << Config.header_color << title << NC::Color::End;
+ *wHeader << NC::Color::End << NC::Format::NoBold;
}
else
{
- *wHeader << NC::XY(0, 0) << wclrtoeol << NC::fmtBold << myScreen->title() << NC::fmtBoldEnd;
+ *wHeader << NC::XY(0, 0) << wclrtoeol << NC::Format::Bold << myScreen->title() << NC::Format::NoBold;
*wHeader << Config.volume_color;
*wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << VolumeState;
- *wHeader << NC::clEnd;
+ *wHeader << NC::Color::End;
}
wHeader->refresh();
}
diff --git a/src/utility/type_conversions.cpp b/src/utility/type_conversions.cpp
index 74669277..0f5b56df 100644
--- a/src/utility/type_conversions.cpp
+++ b/src/utility/type_conversions.cpp
@@ -21,6 +21,50 @@
#include <cassert>
#include "utility/type_conversions.h"
+NC::Color stringToColor(const std::string &color)
+{
+ NC::Color result = NC::Color::Default;
+ if (color == "black")
+ result = NC::Color::Black;
+ else if (color == "red")
+ result = NC::Color::Red;
+ else if (color == "green")
+ result = NC::Color::Green;
+ else if (color == "yellow")
+ result = NC::Color::Yellow;
+ else if (color == "blue")
+ result = NC::Color::Blue;
+ else if (color == "magenta")
+ result = NC::Color::Magenta;
+ else if (color == "cyan")
+ result = NC::Color::Cyan;
+ else if (color == "white")
+ result = NC::Color::White;
+ return result;
+}
+
+NC::Border stringToBorder(const std::string &border)
+{
+ NC::Border result = NC::Border::None;
+ if (border == "black")
+ result = NC::Border::Black;
+ else if (border == "red")
+ result = NC::Border::Red;
+ else if (border == "green")
+ result = NC::Border::Green;
+ else if (border == "yellow")
+ result = NC::Border::Yellow;
+ else if (border == "blue")
+ result = NC::Border::Blue;
+ else if (border == "magenta")
+ result = NC::Border::Magenta;
+ else if (border == "cyan")
+ result = NC::Border::Cyan;
+ else if (border == "white")
+ result = NC::Border::White;
+ return result;
+}
+
std::string tagTypeToString(mpd_tag_type tag)
{
switch (tag)
diff --git a/src/utility/type_conversions.h b/src/utility/type_conversions.h
index be02ed9c..91e67709 100644
--- a/src/utility/type_conversions.h
+++ b/src/utility/type_conversions.h
@@ -23,6 +23,10 @@
#include "mpdpp.h"
#include "mutable_song.h"
+#include "window.h"
+
+NC::Color stringToColor(const std::string &color);
+NC::Border stringToBorder(const std::string &border);
std::string tagTypeToString(mpd_tag_type tag);
MPD::MutableSong::SetFunction tagTypeToSetFunction(mpd_tag_type tag);
diff --git a/src/visualizer.cpp b/src/visualizer.cpp
index 2c1e3611..5d02e319 100644
--- a/src/visualizer.cpp
+++ b/src/visualizer.cpp
@@ -46,7 +46,7 @@ Visualizer *myVisualizer;
const int Visualizer::WindowTimeout = 1000/25; /* 25 fps */
Visualizer::Visualizer()
-: Screen(NC::Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, NC::brNone))
+: Screen(NC::Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, NC::Border::None))
{
ResetFD();
m_samples = Config.visualizer_in_stereo ? 4096 : 2048;
diff --git a/src/window.cpp b/src/window.cpp
index 9d0ac6cf..c521affd 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -87,9 +87,9 @@ Window::Window(size_t startx,
m_height(height),
m_window_timeout(-1),
m_color(color),
- m_bg_color(clDefault),
+ m_bg_color(Color::Default),
m_base_color(color),
- m_base_bg_color(clDefault),
+ m_base_bg_color(Color::Default),
m_border(border),
m_get_string_helper(0),
m_title(title),
@@ -105,10 +105,10 @@ Window::Window(size_t startx,
|| m_height+m_start_y > size_t(LINES))
FatalError("Constructed window is bigger than terminal size");
- if (m_border != brNone)
+ if (m_border != Border::None)
{
m_border_window = newpad(m_height, m_width);
- wattron(m_border_window, COLOR_PAIR(m_border));
+ wattron(m_border_window, COLOR_PAIR(int(m_border)));
box(m_border_window, 0, 0);
m_start_x++;
m_start_y++;
@@ -218,13 +218,13 @@ Window::~Window()
void Window::setColor(Color fg, Color bg)
{
- if (fg == clDefault)
+ if (fg == Color::Default)
fg = m_base_color;
- if (fg != clDefault)
- wattron(m_window, COLOR_PAIR(bg*8+fg));
+ if (fg != Color::Default)
+ wattron(m_window, COLOR_PAIR(int(bg)*8+int(fg)));
else
- wattroff(m_window, COLOR_PAIR(m_color));
+ wattroff(m_window, COLOR_PAIR(int(m_color)));
m_color = fg;
m_bg_color = bg;
}
@@ -237,7 +237,7 @@ void Window::setBaseColor(Color fg, Color bg)
void Window::setBorder(Border border)
{
- if (border == brNone && m_border != brNone)
+ if (border == Border::None && m_border != Border::None)
{
delwin(m_border_window);
m_start_x--;
@@ -246,10 +246,10 @@ void Window::setBorder(Border border)
m_width += 2;
recreate(m_width, m_height);
}
- else if (border != brNone && m_border == brNone)
+ else if (border != Border::None && m_border == Border::None)
{
m_border_window = newpad(m_height, m_width);
- wattron(m_border_window, COLOR_PAIR(border));
+ wattron(m_border_window, COLOR_PAIR(int(border)));
box(m_border_window,0,0);
m_start_x++;
m_start_y++;
@@ -259,7 +259,7 @@ void Window::setBorder(Border border)
}
else
{
- wattron(m_border_window,COLOR_PAIR(border));
+ wattron(m_border_window,COLOR_PAIR(int(border)));
box(m_border_window, 0, 0);
}
m_border = border;
@@ -311,7 +311,7 @@ void Window::moveTo(size_t new_x, size_t new_y)
{
m_start_x = new_x;
m_start_y = new_y;
- if (m_border != brNone)
+ if (m_border != Border::None)
{
m_start_x++;
m_start_y++;
@@ -322,11 +322,11 @@ void Window::moveTo(size_t new_x, size_t new_y)
void Window::adjustDimensions(size_t width, size_t height)
{
- if (m_border != brNone)
+ if (m_border != Border::None)
{
delwin(m_border_window);
m_border_window = newpad(height, width);
- wattron(m_border_window, COLOR_PAIR(m_border));
+ wattron(m_border_window, COLOR_PAIR(int(m_border)));
box(m_border_window, 0, 0);
width -= 2;
height -= 2;
@@ -345,22 +345,22 @@ void Window::resize(size_t new_width, size_t new_height)
void Window::showBorder() const
{
- if (m_border != brNone)
+ if (m_border != Border::None)
{
::refresh();
prefresh(m_border_window, 0, 0, getStarty(), getStartX(), m_start_y+m_height, m_start_x+m_width);
}
if (!m_title.empty())
{
- if (m_border != brNone)
- attron(COLOR_PAIR(m_border));
+ if (m_border != Border::None)
+ attron(COLOR_PAIR(int(m_border)));
else
- attron(COLOR_PAIR(m_base_color));
+ attron(COLOR_PAIR(int(m_base_color)));
mvhline(m_start_y-1, m_start_x, 0, m_width);
attron(A_BOLD);
mvhline(m_start_y-2, m_start_x, 32, m_width); // clear title line
mvaddstr(m_start_y-2, m_start_x, m_title.c_str());
- attroff(COLOR_PAIR(m_border) | A_BOLD);
+ attroff(COLOR_PAIR(int(m_border)) | A_BOLD);
}
::refresh();
}
@@ -741,7 +741,7 @@ bool Window::hasCoords(int &x, int &y)
size_t Window::getWidth() const
{
- if (m_border != brNone)
+ if (m_border != Border::None)
return m_width+2;
else
return m_width;
@@ -750,7 +750,7 @@ size_t Window::getWidth() const
size_t Window::getHeight() const
{
size_t height = m_height;
- if (m_border != brNone)
+ if (m_border != Border::None)
height += 2;
if (!m_title.empty())
height += 2;
@@ -759,7 +759,7 @@ size_t Window::getHeight() const
size_t Window::getStartX() const
{
- if (m_border != brNone)
+ if (m_border != Border::None)
return m_start_x-1;
else
return m_start_x;
@@ -768,7 +768,7 @@ size_t Window::getStartX() const
size_t Window::getStarty() const
{
size_t starty = m_start_y;
- if (m_border != brNone)
+ if (m_border != Border::None)
starty--;
if (!m_title.empty())
starty -= 2;
@@ -823,9 +823,9 @@ void Window::scroll(Scroll where)
Window &Window::operator<<(Colors colors)
{
- if (colors.fg == clEnd || colors.bg == clEnd)
+ if (colors.fg == Color::End || colors.bg == Color::End)
{
- *this << clEnd;
+ *this << Color::End;
return *this;
}
m_color_stack.push(colors);
@@ -837,12 +837,12 @@ Window &Window::operator<<(Color color)
{
switch (color)
{
- case clDefault:
+ case Color::Default:
while (!m_color_stack.empty())
m_color_stack.pop();
setColor(m_base_color, m_base_bg_color);
break;
- case clEnd:
+ case Color::End:
if (!m_color_stack.empty())
m_color_stack.pop();
if (!m_color_stack.empty())
@@ -851,7 +851,7 @@ Window &Window::operator<<(Color color)
setColor(m_base_color, m_base_bg_color);
break;
default:
- m_color_stack.push(Colors(color, clDefault));
+ m_color_stack.push(Colors(color, Color::Default));
setColor(m_color_stack.top().fg, m_color_stack.top().bg);
}
return *this;
@@ -861,36 +861,36 @@ Window &Window::operator<<(Format format)
{
switch (format)
{
- case fmtNone:
+ case Format::None:
bold((m_bold_counter = 0));
reverse((m_reverse_counter = 0));
altCharset((m_alt_charset_counter = 0));
break;
- case fmtBold:
+ case Format::Bold:
bold(++m_bold_counter);
break;
- case fmtBoldEnd:
+ case Format::NoBold:
if (--m_bold_counter <= 0)
bold((m_bold_counter = 0));
break;
- case fmtUnderline:
+ case Format::Underline:
underline(++m_underline_counter);
break;
- case fmtUnderlineEnd:
+ case Format::NoUnderline:
if (--m_underline_counter <= 0)
underline((m_underline_counter = 0));
break;
- case fmtReverse:
+ case Format::Reverse:
reverse(++m_reverse_counter);
break;
- case fmtReverseEnd:
+ case Format::NoReverse:
if (--m_reverse_counter <= 0)
reverse((m_reverse_counter = 0));
break;
- case fmtAltCharset:
+ case Format::AltCharset:
altCharset(++m_alt_charset_counter);
break;
- case fmtAltCharsetEnd:
+ case Format::NoAltCharset:
if (--m_alt_charset_counter <= 0)
altCharset((m_alt_charset_counter = 0));
break;
diff --git a/src/window.h b/src/window.h
index fb73d8a2..cf62334c 100644
--- a/src/window.h
+++ b/src/window.h
@@ -112,19 +112,19 @@
namespace NC {//
/// Colors used by NCurses
-enum Color { clDefault, clBlack, clRed, clGreen, clYellow, clBlue, clMagenta, clCyan, clWhite, clEnd };
+enum class Color { Default, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, End };
/// Format flags used by NCurses
-enum Format {
- fmtNone = clEnd+1,
- fmtBold, fmtBoldEnd,
- fmtUnderline, fmtUnderlineEnd,
- fmtReverse, fmtReverseEnd,
- fmtAltCharset, fmtAltCharsetEnd
+enum class Format {
+ None,
+ Bold, NoBold,
+ Underline, NoUnderline,
+ Reverse, NoReverse,
+ AltCharset, NoAltCharset
};
/// Available border colors for window
-enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite };
+enum class Border { None, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White };
/// This indicates how much the window has to be scrolled
enum class Scroll { Up, Down, PageUp, PageDown, Home, End };
@@ -146,7 +146,7 @@ void destroyScreen();
/// @see Window::operator<<()
struct Colors
{
- Colors(Color one, Color two = clDefault) : fg(one), bg(two) { }
+ Colors(Color one, Color two = Color::Default) : fg(one), bg(two) { }
Color fg;
Color bg;
};
@@ -266,7 +266,7 @@ struct Window
/// Sets window's base color
/// @param fg foregound base color
/// @param bg background base color
- void setBaseColor(Color fg, Color bg = clDefault);
+ void setBaseColor(Color fg, Color bg = Color::Default);
/// Sets window's border
/// @param border new window's border
@@ -351,16 +351,16 @@ struct Window
Window &operator<<(Colors colors);
/// Applies foregound color to window. Note that colors applied
- /// that way are stacked, i.e if you applied clRed, then clGreen
- /// and clEnd, current color would be clRed. If you want to discard
- /// all colors and fall back to base one, pass clDefault.
+ /// that way are stacked, i.e if you applied Color::Red, then Color::Green
+ /// and Color::End, current color would be Color::Red. If you want to discard
+ /// all colors and fall back to base one, pass Color::Default.
/// @param color new color value
/// @return reference to itself
Window &operator<<(Color color);
/// Applies format flag to window. Note that these attributes are
- /// also stacked, so if you applied fmtBold twice, to get rid of
- /// it you have to pass fmtBoldEnd also twice.
+ /// also stacked, so if you applied Format::Bold twice, to get rid of
+ /// it you have to pass Format::NoBold also twice.
/// @param format format flag
/// @return reference to itself
Window &operator<<(Format format);
@@ -419,7 +419,7 @@ protected:
/// @param fg foregound color
/// @param bg background color
///
- void setColor(Color fg, Color bg = clDefault);
+ void setColor(Color fg, Color bg = Color::Default);
/// Refreshes window's border
///