diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2017-03-28 11:31:09 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2017-05-21 15:22:54 +0200 |
commit | 19d32648ed4ad04c4cc09fd7ec6b9250b9387893 (patch) | |
tree | cfcf1b5cc465f6a87b3d846865b641758467c5a9 /src | |
parent | 8134e6e23b2787322fa10e65e44d286da82eea91 (diff) |
Replace highlight colors with prefixes and suffixes
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/actions.cpp | 4 | ||||
-rw-r--r-- | src/curses/formatted_color.h | 32 | ||||
-rw-r--r-- | src/curses/menu.h | 23 | ||||
-rw-r--r-- | src/curses/menu_impl.h | 25 | ||||
-rw-r--r-- | src/curses/scrollpad.cpp | 25 | ||||
-rw-r--r-- | src/curses/scrollpad.h | 10 | ||||
-rw-r--r-- | src/curses/strbuffer.h | 28 | ||||
-rw-r--r-- | src/curses/window.cpp | 1 | ||||
-rw-r--r-- | src/display.cpp | 21 | ||||
-rw-r--r-- | src/helpers.h | 16 | ||||
-rw-r--r-- | src/lastfm_service.cpp | 3 | ||||
-rw-r--r-- | src/screens/browser.cpp | 2 | ||||
-rw-r--r-- | src/screens/media_library.cpp | 22 | ||||
-rw-r--r-- | src/screens/outputs.cpp | 3 | ||||
-rw-r--r-- | src/screens/playlist.cpp | 2 | ||||
-rw-r--r-- | src/screens/playlist_editor.cpp | 12 | ||||
-rw-r--r-- | src/screens/search_engine.cpp | 6 | ||||
-rw-r--r-- | src/screens/sel_items_adder.cpp | 4 | ||||
-rw-r--r-- | src/screens/song_info.cpp | 4 | ||||
-rw-r--r-- | src/screens/tag_editor.cpp | 32 | ||||
-rw-r--r-- | src/screens/tiny_tag_editor.cpp | 7 | ||||
-rw-r--r-- | src/screens/visualizer.cpp | 10 | ||||
-rw-r--r-- | src/settings.cpp | 126 | ||||
-rw-r--r-- | src/settings.h | 10 | ||||
-rw-r--r-- | src/status.cpp | 24 | ||||
-rw-r--r-- | src/statusbar.cpp | 4 | ||||
-rw-r--r-- | src/title.cpp | 4 | ||||
-rw-r--r-- | src/utility/storage_kind.h | 26 |
29 files changed, 343 insertions, 144 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index cb0bf7bf..a8183baa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,6 +91,7 @@ noinst_HEADERS = \ utility/option_parser.h \ utility/readline.h \ utility/scoped_value.h \ + utility/storage_kind.h \ utility/shared_resource.h \ utility/string.h \ utility/type_conversions.h \ diff --git a/src/actions.cpp b/src/actions.cpp index 144d4f02..e4d1d510 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -2977,7 +2977,7 @@ void seek(SearchDirection sd) *wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << Config.statusbar_time_color << tracklength - << NC::FormattedColor::End(Config.statusbar_time_color); + << NC::FormattedColor::End<>(Config.statusbar_time_color); break; case Design::Alternative: if (Config.display_remaining_time) @@ -2992,7 +2992,7 @@ void seek(SearchDirection sd) *wHeader << NC::XY(0, 0) << Config.statusbar_time_color << tracklength - << NC::FormattedColor::End(Config.statusbar_time_color) + << NC::FormattedColor::End<>(Config.statusbar_time_color) << " "; wHeader->refresh(); break; diff --git a/src/curses/formatted_color.h b/src/curses/formatted_color.h index 4b8d71b4..180ffbf0 100644 --- a/src/curses/formatted_color.h +++ b/src/curses/formatted_color.h @@ -23,22 +23,37 @@ #include <boost/optional.hpp> #include <boost/range/adaptor/reversed.hpp> -#include "window.h" +#include "curses/window.h" +#include "utility/storage_kind.h" namespace NC { struct FormattedColor { + template <StorageKind storage = StorageKind::Reference> struct End { - End(const FormattedColor &fc) + explicit End(const FormattedColor &fc) : m_fc(fc) { } const FormattedColor &base() const { return m_fc; } + template <StorageKind otherStorage> + bool operator==(const End<otherStorage> &rhs) const + { + return m_fc == rhs.m_fc; + } + + explicit operator End<StorageKind::Value>() const + { + return End<StorageKind::Value>(m_fc); + } + private: - const FormattedColor &m_fc; + typename std::conditional<storage == StorageKind::Reference, + const FormattedColor &, + FormattedColor>::type m_fc; }; typedef std::vector<Format> Formats; @@ -55,6 +70,12 @@ private: Formats m_formats; }; +inline bool operator==(const FormattedColor &lhs, const FormattedColor &rhs) +{ + return lhs.color() == rhs.color() + && lhs.formats() == rhs.formats(); +} + std::istream &operator>>(std::istream &is, FormattedColor &fc); template <typename OutputStreamT> @@ -66,8 +87,9 @@ OutputStreamT &operator<<(OutputStreamT &os, const FormattedColor &fc) return os; } -template <typename OutputStreamT> -OutputStreamT &operator<<(OutputStreamT &os, const FormattedColor::End &rfc) +template <typename OutputStreamT, StorageKind storage> +OutputStreamT &operator<<(OutputStreamT &os, + const FormattedColor::End<storage> &rfc) { if (rfc.base().color() != Color::Default) os << Color::End; diff --git a/src/curses/menu.h b/src/curses/menu.h index aa457249..d8e5e8ef 100644 --- a/src/curses/menu.h +++ b/src/curses/menu.h @@ -29,9 +29,10 @@ #include <memory> #include <set> +#include "curses/formatted_color.h" +#include "curses/strbuffer.h" +#include "curses/window.h" #include "utility/const.h" -#include "strbuffer.h" -#include "window.h" namespace NC { @@ -367,11 +368,13 @@ struct Menu: Window, List /// Note that the passed variable is not deleted along with menu object. /// @param b pointer to buffer that contains the suffix void setSelectedSuffix(const Buffer &b) { m_selected_suffix = b; } - - /// Sets custom color of highlighted position - /// @param col custom color - void setHighlightColor(Color color) { m_highlight_color = std::move(color); } - + + void setHighlightPrefix(const Buffer &b) { m_highlight_prefix = b; } + void setHighlightSuffix(const Buffer &b) { m_highlight_suffix = b; } + + const Buffer &highlightPrefix() const { return m_highlight_prefix; } + const Buffer &highlightSuffix() const { return m_highlight_suffix; } + /// @return state of highlighting bool isHighlighted() { return m_highlight_enabled; } @@ -496,14 +499,16 @@ private: size_t m_beginning; size_t m_highlight; - Color m_highlight_color; bool m_highlight_enabled; bool m_cyclic_scroll_enabled; bool m_autocenter_cursor; size_t m_drawn_position; - + + Buffer m_highlight_prefix; + Buffer m_highlight_suffix; + Buffer m_selected_prefix; Buffer m_selected_suffix; }; diff --git a/src/curses/menu_impl.h b/src/curses/menu_impl.h index 3053563e..bcb4fd82 100644 --- a/src/curses/menu_impl.h +++ b/src/curses/menu_impl.h @@ -39,16 +39,18 @@ Menu<ItemT>::Menu(size_t startx, const std::string &title, Color color, Border border) - : Window(startx, starty, width, height, title, std::move(color), border) + : Window(startx, starty, width, height, title, color, border) , m_item_displayer(nullptr) , m_filter_predicate(nullptr) , m_beginning(0) , m_highlight(0) - , m_highlight_color(m_base_color) , m_highlight_enabled(true) , m_cyclic_scroll_enabled(false) , m_autocenter_cursor(false) { + auto fc = FormattedColor(m_base_color, {Format::Reverse}); + m_highlight_prefix << fc; + m_highlight_suffix << FormattedColor::End<>(fc); m_items = &m_all_items; } @@ -59,11 +61,12 @@ Menu<ItemT>::Menu(const Menu &rhs) , m_filter_predicate(rhs.m_filter_predicate) , m_beginning(rhs.m_beginning) , m_highlight(rhs.m_highlight) - , m_highlight_color(rhs.m_highlight_color) , m_highlight_enabled(rhs.m_highlight_enabled) , m_cyclic_scroll_enabled(rhs.m_cyclic_scroll_enabled) , m_autocenter_cursor(rhs.m_autocenter_cursor) , m_drawn_position(rhs.m_drawn_position) + , m_highlight_prefix(rhs.m_highlight_prefix) + , m_highlight_suffix(rhs.m_highlight_suffix) , m_selected_prefix(rhs.m_selected_prefix) , m_selected_suffix(rhs.m_selected_suffix) { @@ -83,11 +86,12 @@ Menu<ItemT>::Menu(Menu &&rhs) , m_filtered_items(std::move(rhs.m_filtered_items)) , m_beginning(rhs.m_beginning) , m_highlight(rhs.m_highlight) - , m_highlight_color(rhs.m_highlight_color) , m_highlight_enabled(rhs.m_highlight_enabled) , m_cyclic_scroll_enabled(rhs.m_cyclic_scroll_enabled) , m_autocenter_cursor(rhs.m_autocenter_cursor) , m_drawn_position(rhs.m_drawn_position) + , m_highlight_prefix(std::move(rhs.m_highlight_prefix)) + , m_highlight_suffix(std::move(rhs.m_highlight_suffix)) , m_selected_prefix(std::move(rhs.m_selected_prefix)) , m_selected_suffix(std::move(rhs.m_selected_suffix)) { @@ -107,11 +111,12 @@ Menu<ItemT> &Menu<ItemT>::operator=(Menu rhs) std::swap(m_filtered_items, rhs.m_filtered_items); std::swap(m_beginning, rhs.m_beginning); std::swap(m_highlight, rhs.m_highlight); - std::swap(m_highlight_color, rhs.m_highlight_color); std::swap(m_highlight_enabled, rhs.m_highlight_enabled); std::swap(m_cyclic_scroll_enabled, rhs.m_cyclic_scroll_enabled); std::swap(m_autocenter_cursor, rhs.m_autocenter_cursor); std::swap(m_drawn_position, rhs.m_drawn_position); + std::swap(m_highlight_prefix, rhs.m_highlight_prefix); + std::swap(m_highlight_suffix, rhs.m_highlight_suffix); std::swap(m_selected_prefix, rhs.m_selected_prefix); std::swap(m_selected_suffix, rhs.m_selected_suffix); if (rhs.m_items == &rhs.m_all_items) @@ -211,10 +216,7 @@ void Menu<ItemT>::refresh() continue; } if (m_highlight_enabled && m_drawn_position == m_highlight) - { - *this << Format::Reverse; - *this << m_highlight_color; - } + *this << m_highlight_prefix; if ((*m_items)[m_drawn_position].isSelected()) *this << m_selected_prefix; *this << NC::TermManip::ClearToEOL; @@ -223,10 +225,7 @@ void Menu<ItemT>::refresh() if ((*m_items)[m_drawn_position].isSelected()) *this << m_selected_suffix; if (m_highlight_enabled && m_drawn_position == m_highlight) - { - *this << Color::End; - *this << Format::NoReverse; - } + *this << m_highlight_suffix; } Window::refresh(); } diff --git a/src/curses/scrollpad.cpp b/src/curses/scrollpad.cpp index 0a1683b1..ac21047f 100644 --- a/src/curses/scrollpad.cpp +++ b/src/curses/scrollpad.cpp @@ -22,12 +22,14 @@ #include <boost/regex.hpp> #include <iostream> -#include "scrollpad.h" +#include "curses/scrollpad.h" +#include "utility/storage_kind.h" namespace { -template <typename PropT> -bool regexSearch(NC::Buffer &buf, PropT begin, const std::string &ws, PropT end, boost::regex::flag_type flags, size_t id) +template <typename BeginT, typename EndT> +bool regexSearch(NC::Buffer &buf, const BeginT &begin, const std::string &ws, + const EndT &end, boost::regex::flag_type flags, size_t id) { try { boost::regex rx(ws, flags); @@ -269,16 +271,29 @@ void Scrollpad::reset() m_beginning = 0; } -bool Scrollpad::setProperties(Color begin, const std::string &s, Color end, size_t flags, size_t id) +bool Scrollpad::setProperties(const Color &begin, const std::string &s, + const Color &end, size_t flags, size_t id) { return regexSearch(m_buffer, std::move(begin), s, std::move(end), id, flags); } -bool Scrollpad::setProperties(Format begin, const std::string &s, Format end, size_t flags, size_t id) +bool Scrollpad::setProperties(const Format &begin, const std::string &s, + const Format &end, size_t flags, size_t id) { return regexSearch(m_buffer, begin, s, end, flags, id); } +bool Scrollpad::setProperties(const FormattedColor &fc, const std::string &s, + size_t flags, size_t id) +{ + return regexSearch(m_buffer, + fc, + s, + FormattedColor::End<StorageKind::Value>(fc), + flags, + id); +} + void Scrollpad::removeProperties(size_t id) { m_buffer.removeProperties(id); diff --git a/src/curses/scrollpad.h b/src/curses/scrollpad.h index 14126a83..bb2c056c 100644 --- a/src/curses/scrollpad.h +++ b/src/curses/scrollpad.h @@ -21,8 +21,8 @@ #ifndef NCMPCPP_SCROLLPAD_H #define NCMPCPP_SCROLLPAD_H -#include "window.h" -#include "strbuffer.h" +#include "curses/window.h" +#include "curses/strbuffer.h" namespace NC { @@ -46,9 +46,11 @@ struct Scrollpad: public Window void flush(); void reset(); - bool setProperties(Color begin, const std::string &s, Color end, + bool setProperties(const Color &begin, const std::string &s, const Color &end, size_t flags, size_t id = -2); - bool setProperties(Format begin, const std::string &s, Format end, + bool setProperties(const Format &begin, const std::string &s, const Format &end, + size_t flags, size_t id = -2); + bool setProperties(const FormattedColor &fc, const std::string &s, size_t flags, size_t id = -2); void removeProperties(size_t id = -2); diff --git a/src/curses/strbuffer.h b/src/curses/strbuffer.h index bb059e65..ab91cd31 100644 --- a/src/curses/strbuffer.h +++ b/src/curses/strbuffer.h @@ -24,7 +24,8 @@ #include <boost/lexical_cast.hpp> #include <boost/variant.hpp> #include <map> -#include "window.h" +#include "curses/formatted_color.h" +#include "curses/window.h" namespace NC { @@ -40,6 +41,11 @@ template <typename CharT> class BasicBuffer size_t id() const { return m_id; } + bool operator==(const Property &rhs) const + { + return m_id == rhs.m_id && m_impl == rhs.m_impl; + } + template <typename OutputStreamT> friend OutputStreamT &operator<<(OutputStreamT &os, const Property &p) { @@ -48,7 +54,11 @@ template <typename CharT> class BasicBuffer } private: - boost::variant<Color, Format> m_impl; + boost::variant<Color, + Format, + FormattedColor, + FormattedColor::End<StorageKind::Value> + > m_impl; size_t m_id; }; @@ -131,18 +141,18 @@ public: return *this; } - BasicBuffer<CharT> &operator<<(Color color) + BasicBuffer<CharT> &operator<<(const Color &color) { addProperty(m_string.size(), color); return *this; } - BasicBuffer<CharT> &operator<<(Format format) + BasicBuffer<CharT> &operator<<(const Format &format) { addProperty(m_string.size(), format); return *this; } - + // static variadic initializer. used instead of a proper constructor because // it's too polymorphic and would end up invoked as a copy/move constructor. template <typename... Args> @@ -169,6 +179,14 @@ private: typedef BasicBuffer<char> Buffer; typedef BasicBuffer<wchar_t> WBuffer; +template <typename CharT> +bool operator==(const BasicBuffer<CharT> &lhs, const BasicBuffer<CharT> &rhs) +{ + return lhs.str() == rhs.str() + && lhs.properties() == rhs.properties(); +} + + template <typename OutputStreamT, typename CharT> OutputStreamT &operator<<(OutputStreamT &os, const BasicBuffer<CharT> &buffer) { diff --git a/src/curses/window.cpp b/src/curses/window.cpp index 7fc20eab..5a83b59c 100644 --- a/src/curses/window.cpp +++ b/src/curses/window.cpp @@ -510,6 +510,7 @@ Window::Window(const Window &rhs) , m_reverse_counter(rhs.m_reverse_counter) , m_alt_charset_counter(rhs.m_alt_charset_counter) { + setColor(m_color); } Window::Window(Window &&rhs) diff --git a/src/display.cpp b/src/display.cpp index 329b061b..3ca63201 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -143,6 +143,13 @@ void showSongs(NC::Menu<T> &menu, const MPD::Song &s, const SongList &list, cons if (!right_aligned.str().empty()) { size_t x_off = menu.getWidth() - wideLength(ToWString(right_aligned.str())); + if (menu.isHighlighted() && list.currentS()->song() == &s) + { + if (menu.highlightSuffix() == Config.current_item_suffix) + x_off -= Config.current_item_suffix_length; + else + x_off -= Config.current_item_inactive_column_suffix_length; + } if (is_now_playing) x_off -= Config.now_playing_suffix_length; if (is_selected) @@ -164,6 +171,18 @@ void showSongsInColumns(NC::Menu<T> &menu, const MPD::Song &s, const SongList &l is_in_playlist, discard_colors); int menu_width = menu.getWidth(); + if (menu.isHighlighted() && list.currentS()->song() == &s) + { + if (menu.highlightPrefix() == Config.current_item_prefix) + menu_width -= Config.current_item_prefix_length; + else + menu_width -= Config.current_item_inactive_column_prefix_length; + + if (menu.highlightSuffix() == Config.current_item_suffix) + menu_width -= Config.current_item_suffix_length; + else + menu_width -= Config.current_item_inactive_column_suffix_length; + } if (is_now_playing) { menu_width -= Config.now_playing_prefix_length; @@ -343,7 +362,7 @@ void Display::Tags(NC::Menu<MPD::MutableSong> &menu) menu << Charset::utf8ToLocale(s.getName()) << Config.color2 << " -> " - << NC::FormattedColor::End(Config.color2) + << NC::FormattedColor::End<>(Config.color2) << Charset::utf8ToLocale(s.getNewName()); } } diff --git a/src/helpers.h b/src/helpers.h index 5cef8f06..09a4ea7c 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -497,7 +497,7 @@ void ShowTag(BufferT &buf, const std::string &tag) if (tag.empty()) buf << Config.empty_tags_color << Config.empty_tag - << NC::FormattedColor::End(Config.empty_tags_color); + << NC::FormattedColor::End<>(Config.empty_tags_color); else buf << tag; } @@ -509,6 +509,20 @@ inline NC::Buffer ShowTag(const std::string &tag) return result; } +template <typename T> +void setHighlightFixes(NC::Menu<T> &m) +{ + m.setHighlightPrefix(Config.current_item_prefix); + m.setHighlightSuffix(Config.current_item_suffix); +} + +template <typename T> +void setHighlightInactiveColumnFixes(NC::Menu<T> &m) +{ + m.setHighlightPrefix(Config.current_item_inactive_column_prefix); + m.setHighlightSuffix(Config.current_item_inactive_column_suffix); +} + inline const char *withErrors(bool success) { return success ? "" : " " "(with errors)"; diff --git a/src/lastfm_service.cpp b/src/lastfm_service.cpp index 3d6b173d..d2da4230 100644 --- a/src/lastfm_service.cpp +++ b/src/lastfm_service.cpp @@ -94,8 +94,7 @@ void ArtistInfo::beautifyOutput(NC::Scrollpad &w) { w.setProperties(NC::Format::Bold, "\n\nSimilar artists:\n", NC::Format::NoBold, 0); w.setProperties(NC::Format::Bold, "\n\nSimilar tags:\n", NC::Format::NoBold, 0); - w.setProperties(Config.color2.color(), "\n * ", NC::Color::End, 0, - boost::regex::literal); + w.setProperties(Config.color2, "\n * ", boost::regex::literal); } Service::Result ArtistInfo::processData(const std::string &data) diff --git a/src/screens/browser.cpp b/src/screens/browser.cpp index 784e3491..9eca6264 100644 --- a/src/screens/browser.cpp +++ b/src/screens/browser.cpp @@ -135,7 +135,7 @@ Browser::Browser() , m_current_directory("/") { w = NC::Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.browser_display_mode == DisplayMode::Columns && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::Border()); - w.setHighlightColor(Config.main_highlight_color); + setHighlightFixes(w); w.cyclicScrolling(Config.use_cyclic_scrolling); w.centeredCursor(Config.centered_cursor); w.setSelectedPrefix(Config.selected_item_prefix); diff --git a/src/screens/media_library.cpp b/src/screens/media_library.cpp index fcb2d0af..aad516eb 100644 --- a/src/screens/media_library.cpp +++ b/src/screens/media_library.cpp @@ -189,7 +189,7 @@ MediaLibrary::MediaLibrary() 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::Border()); - Tags.setHighlightColor(Config.active_column_color); + setHighlightFixes(Tags); Tags.cyclicScrolling(Config.use_cyclic_scrolling); Tags.centeredCursor(Config.centered_cursor); Tags.setSelectedPrefix(Config.selected_item_prefix); @@ -203,7 +203,7 @@ MediaLibrary::MediaLibrary() }); Albums = NC::Menu<AlbumEntry>(itsMiddleColStartX, MainStartY, itsMiddleColWidth, MainHeight, Config.titles_visibility ? "Albums" : "", Config.main_color, NC::Border()); - Albums.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Albums); Albums.cyclicScrolling(Config.use_cyclic_scrolling); Albums.centeredCursor(Config.centered_cursor); Albums.setSelectedPrefix(Config.selected_item_prefix); @@ -213,7 +213,7 @@ MediaLibrary::MediaLibrary() }); Songs = NC::Menu<MPD::Song>(itsRightColStartX, MainStartY, itsRightColWidth, MainHeight, Config.titles_visibility ? "Songs" : "", Config.main_color, NC::Border()); - Songs.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Songs); Songs.cyclicScrolling(Config.use_cyclic_scrolling); Songs.centeredCursor(Config.centered_cursor); Songs.setSelectedPrefix(Config.selected_item_prefix); @@ -814,17 +814,17 @@ void MediaLibrary::previousColumn() { if (isActiveWindow(Songs)) { - Songs.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Songs); w->refresh(); w = &Albums; - Albums.setHighlightColor(Config.active_column_color); + setHighlightFixes(Albums); } else if (isActiveWindow(Albums) && !hasTwoColumns) { - Albums.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Albums); w->refresh(); w = &Tags; - Tags.setHighlightColor(Config.active_column_color); + setHighlightFixes(Tags); } } @@ -850,17 +850,17 @@ void MediaLibrary::nextColumn() { if (isActiveWindow(Tags)) { - Tags.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Tags); w->refresh(); w = &Albums; - Albums.setHighlightColor(Config.active_column_color); + setHighlightFixes(Albums); } else if (isActiveWindow(Albums)) { - Albums.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Albums); w->refresh(); w = &Songs; - Songs.setHighlightColor(Config.active_column_color); + setHighlightFixes(Songs); } } diff --git a/src/screens/outputs.cpp b/src/screens/outputs.cpp index f9aa5945..21280537 100644 --- a/src/screens/outputs.cpp +++ b/src/screens/outputs.cpp @@ -26,6 +26,7 @@ #include "charset.h" #include "display.h" #include "global.h" +#include "helpers.h" #include "settings.h" #include "status.h" #include "statusbar.h" @@ -43,7 +44,7 @@ Outputs::Outputs() { w.cyclicScrolling(Config.use_cyclic_scrolling); w.centeredCursor(Config.centered_cursor); - w.setHighlightColor(Config.main_highlight_color); + setHighlightFixes(w); w.setItemDisplayer([](NC::Menu<MPD::Output> &menu) { auto &output = menu.drawn()->value(); if (output.enabled()) diff --git a/src/screens/playlist.cpp b/src/screens/playlist.cpp index b393460c..7fc582a0 100644 --- a/src/screens/playlist.cpp +++ b/src/screens/playlist.cpp @@ -59,7 +59,7 @@ Playlist::Playlist() w = NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.playlist_display_mode == DisplayMode::Columns && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::Border()); w.cyclicScrolling(Config.use_cyclic_scrolling); w.centeredCursor(Config.centered_cursor); - w.setHighlightColor(Config.main_highlight_color); + setHighlightFixes(w); w.setSelectedPrefix(Config.selected_item_prefix); w.setSelectedSuffix(Config.selected_item_suffix); switch (Config.playlist_display_mode) diff --git a/src/screens/playlist_editor.cpp b/src/screens/playlist_editor.cpp index c49de354..4943a73f 100644 --- a/src/screens/playlist_editor.cpp +++ b/src/screens/playlist_editor.cpp @@ -71,7 +71,7 @@ PlaylistEditor::PlaylistEditor() RightColumnWidth = COLS-LeftColumnWidth-1; Playlists = NC::Menu<MPD::Playlist>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Playlists" : "", Config.main_color, NC::Border()); - Playlists.setHighlightColor(Config.active_column_color); + setHighlightFixes(Playlists); Playlists.cyclicScrolling(Config.use_cyclic_scrolling); Playlists.centeredCursor(Config.centered_cursor); Playlists.setSelectedPrefix(Config.selected_item_prefix); @@ -81,7 +81,7 @@ PlaylistEditor::PlaylistEditor() }); Content = NC::Menu<MPD::Song>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Content" : "", Config.main_color, NC::Border()); - Content.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Content); Content.cyclicScrolling(Config.use_cyclic_scrolling); Content.centeredCursor(Config.centered_cursor); Content.setSelectedPrefix(Config.selected_item_prefix); @@ -431,10 +431,10 @@ void PlaylistEditor::previousColumn() { if (isActiveWindow(Content)) { - Content.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Content); w->refresh(); w = &Playlists; - Playlists.setHighlightColor(Config.active_column_color); + setHighlightFixes(Playlists); } } @@ -453,10 +453,10 @@ void PlaylistEditor::nextColumn() { if (isActiveWindow(Playlists)) { - Playlists.setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(Playlists); w->refresh(); w = &Content; - Content.setHighlightColor(Config.active_column_color); + setHighlightFixes(Content); } } diff --git a/src/screens/search_engine.cpp b/src/screens/search_engine.cpp index 1f31a03d..73c27a1a 100644 --- a/src/screens/search_engine.cpp +++ b/src/screens/search_engine.cpp @@ -175,7 +175,7 @@ size_t SearchEngine::SearchButton = 15; SearchEngine::SearchEngine() : Screen(NC::Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border())) { - w.setHighlightColor(Config.main_highlight_color); + setHighlightFixes(w); w.cyclicScrolling(Config.use_cyclic_scrolling); w.centeredCursor(Config.centered_cursor); w.setItemDisplayer(std::bind(Display::SEItems, ph::_1, std::cref(w))); @@ -351,10 +351,10 @@ void SearchEngine::runAction() << NC::Format::Bold << Config.color1 << "Search results: " - << NC::FormattedColor::End(Config.color1) + << NC::FormattedColor::End<>(Config.color1) << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") - << NC::FormattedColor::End(Config.color2) + << NC::FormattedColor::End<>(Config.color2) << NC::Format::NoBold; w.insertSeparator(ResetButton+3); Statusbar::print("Searching finished"); diff --git a/src/screens/sel_items_adder.cpp b/src/screens/sel_items_adder.cpp index 52487d11..02128537 100644 --- a/src/screens/sel_items_adder.cpp +++ b/src/screens/sel_items_adder.cpp @@ -69,7 +69,7 @@ SelectedItemsAdder::SelectedItemsAdder() ); m_playlist_selector.cyclicScrolling(Config.use_cyclic_scrolling); m_playlist_selector.centeredCursor(Config.centered_cursor); - m_playlist_selector.setHighlightColor(Config.main_highlight_color); + setHighlightFixes(m_playlist_selector); m_playlist_selector.setItemDisplayer(DisplayComponent); m_position_selector = Component( @@ -83,7 +83,7 @@ SelectedItemsAdder::SelectedItemsAdder() ); m_position_selector.cyclicScrolling(Config.use_cyclic_scrolling); m_position_selector.centeredCursor(Config.centered_cursor); - m_position_selector.setHighlightColor(Config.main_highlight_color); + setHighlightFixes(m_position_selector); m_position_selector.setItemDisplayer(DisplayComponent); m_position_selector.addItem(Entry("At the end of playlist", diff --git a/src/screens/song_info.cpp b/src/screens/song_info.cpp index bd9768c8..ff545bc7 100644 --- a/src/screens/song_info.cpp +++ b/src/screens/song_info.cpp @@ -100,12 +100,12 @@ void SongInfo::PrepareSong(const MPD::Song &s) << Config.color1 << key << ":" - << NC::FormattedColor::End(Config.color1) + << NC::FormattedColor::End<>(Config.color1) << NC::Format::NoBold << " " << Config.color2 << value - << NC::FormattedColor::End(Config.color2) + << NC::FormattedColor::End<>(Config.color2) << "\n"; }; diff --git a/src/screens/tag_editor.cpp b/src/screens/tag_editor.cpp index 43644d54..571d9f5e 100644 --- a/src/screens/tag_editor.cpp +++ b/src/screens/tag_editor.cpp @@ -133,7 +133,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser 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::Border()); - Dirs->setHighlightColor(Config.active_column_color); + setHighlightFixes(*Dirs); Dirs->cyclicScrolling(Config.use_cyclic_scrolling); Dirs->centeredCursor(Config.centered_cursor); Dirs->setItemDisplayer([](NC::Menu<std::pair<std::string, std::string>> &menu) { @@ -141,7 +141,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser }); TagTypes = new NC::Menu<std::string>(MiddleColumnStartX, MainStartY, MiddleColumnWidth, MainHeight, Config.titles_visibility ? "Tag types" : "", Config.main_color, NC::Border()); - TagTypes->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*TagTypes); TagTypes->cyclicScrolling(Config.use_cyclic_scrolling); TagTypes->centeredCursor(Config.centered_cursor); TagTypes->setItemDisplayer([](NC::Menu<std::string> &menu) { @@ -165,7 +165,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser TagTypes->addItem("Save"); Tags = new TagsWindow(NC::Menu<MPD::MutableSong>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Tags" : "", Config.main_color, NC::Border())); - Tags->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*Tags); Tags->cyclicScrolling(Config.use_cyclic_scrolling); Tags->centeredCursor(Config.centered_cursor); Tags->setSelectedPrefix(Config.selected_item_prefix); @@ -554,7 +554,7 @@ void TagEditor::runAction() for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it) *FParserLegend << Config.color2 << " * " - << NC::FormattedColor::End(Config.color2) + << NC::FormattedColor::End<>(Config.color2) << (*it)->getName() << "\n"; FParserLegend->flush(); @@ -639,11 +639,11 @@ void TagEditor::runAction() *FParserPreview << file << Config.color2 << " -> " - << NC::FormattedColor::End(Config.color2); + << NC::FormattedColor::End<>(Config.color2); if (new_file.empty()) *FParserPreview << Config.empty_tags_color << Config.empty_tag - << NC::FormattedColor::End(Config.empty_tags_color); + << NC::FormattedColor::End<>(Config.empty_tags_color); else *FParserPreview << new_file << extension; *FParserPreview << "\n\n"; @@ -810,11 +810,11 @@ void TagEditor::runAction() if (success) { Statusbar::print("Tags updated"); - TagTypes->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*TagTypes); TagTypes->reset(); w->refresh(); w = Dirs; - Dirs->setHighlightColor(Config.active_column_color); + setHighlightFixes(*Dirs); Mpd.UpdateDirectory(getSharedDirectory(Tags->beginV(), Tags->endV())); } else @@ -878,17 +878,17 @@ void TagEditor::previousColumn() { if (w == Tags) { - Tags->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*Tags); w->refresh(); w = TagTypes; - TagTypes->setHighlightColor(Config.active_column_color); + setHighlightFixes(*TagTypes); } else if (w == TagTypes) { - TagTypes->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*TagTypes); w->refresh(); w = Dirs; - Dirs->setHighlightColor(Config.active_column_color); + setHighlightFixes(*Dirs); } else if (w == FParserHelper) { @@ -922,17 +922,17 @@ void TagEditor::nextColumn() { if (w == Dirs) { - Dirs->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*Dirs); w->refresh(); w = TagTypes; - TagTypes->setHighlightColor(Config.active_column_color); + setHighlightFixes(*TagTypes); } else if (w == TagTypes && TagTypes->choice() < 13 && !Tags->empty()) { - TagTypes->setHighlightColor(Config.main_highlight_color); + setHighlightInactiveColumnFixes(*TagTypes); w->refresh(); w = Tags; - Tags->setHighlightColor(Config.active_column_color); + setHighlightFixes(*Tags); } else if (w == FParser) { diff --git a/src/screens/tiny_tag_editor.cpp b/src/screens/tiny_tag_editor.cpp index 7d50c8de..3b2a034c 100644 --- a/src/screens/tiny_tag_editor.cpp +++ b/src/screens/tiny_tag_editor.cpp @@ -52,7 +52,8 @@ TinyTagEditor *myTinyTagEditor; TinyTagEditor::TinyTagEditor() : Screen(NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border())) { - w.setHighlightColor(Config.main_highlight_color); + w.setHighlightPrefix(Config.current_item_prefix); + w.setHighlightSuffix(Config.current_item_suffix); w.cyclicScrolling(Config.use_cyclic_scrolling); w.centeredCursor(Config.centered_cursor); w.setItemDisplayer([](NC::Menu<NC::Buffer> &menu) { @@ -228,12 +229,12 @@ bool TinyTagEditor::getTags() << Config.color1 << key << ":" - << NC::FormattedColor::End(Config.color1) + << NC::FormattedColor::End<>(Config.color1) << NC::Format::NoBold << " " << Config.color2 << value - << NC::FormattedColor::End(Config.color2); + << NC::FormattedColor::End<>(Config.color2); }; print_key_value(w[0].value(), "Filename", itsEdited.getName()); diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp index f5e511e9..e3621612 100644 --- a/src/screens/visualizer.cpp +++ b/src/screens/visualizer.cpp @@ -221,7 +221,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s w << NC::XY(x, base_y+y) << c << Config.visualizer_chars[0] - << NC::FormattedColor::End(c); + << NC::FormattedColor::End<>(c); }; int32_t point_y, prev_point_y = 0; @@ -299,7 +299,7 @@ void Visualizer::DrawSoundWaveFill(int16_t *buf, ssize_t samples, size_t y_offse w << NC::XY(x, y) << c << Config.visualizer_chars[1] - << NC::FormattedColor::End(c); + << NC::FormattedColor::End<>(c); } } } @@ -342,7 +342,7 @@ void Visualizer::DrawSoundEllipse(int16_t *buf, ssize_t samples, size_t, size_t w << NC::XY(half_width + x, half_height + y) << c << Config.visualizer_chars[0] - << NC::FormattedColor::End(c); + << NC::FormattedColor::End<>(c); } } @@ -381,7 +381,7 @@ void Visualizer::DrawSoundEllipseStereo(int16_t *buf_left, int16_t *buf_right, s w << NC::XY(left_half_width + x, top_half_height + y) << c << Config.visualizer_chars[1] - << NC::FormattedColor::End(c); + << NC::FormattedColor::End<>(c); } } @@ -428,7 +428,7 @@ void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t samples, size_t y_o w << NC::XY(x, y) << c << Config.visualizer_chars[1] - << NC::FormattedColor::End(c); + << NC::FormattedColor::End<>(c); } } } diff --git a/src/settings.cpp b/src/settings.cpp index 6079bd9a..92cd2f71 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -35,6 +35,8 @@ # include <langinfo.h> #endif +namespace ph = std::placeholders; + Configuration Config; namespace { @@ -177,12 +179,29 @@ NC::Buffer buffer(const std::string &v) return result; } -void deprecated(const char *option, double version_removal, const char *advice) +NC::Buffer buffer_wlength(const NC::Buffer *target, + size_t &wlength, + const std::string &v) +{ + // Compatibility layer between highlight color and new highlight prefix and + // suffix. Basically, for older configurations if highlight color is provided, + // we don't want to override it with default prefix and suffix. + if (target == nullptr || target->empty()) + { + NC::Buffer result = buffer(v); + wlength = wideLength(ToWString(result.str())); + return result; + } + else + return *target; +} + +void deprecated(const char *option, double version_removal, const std::string &advice) { std::cerr << "WARNING: Variable '" << option << "' is deprecated and will be removed in " << version_removal; - if (advice) + if (!advice.empty()) std::cerr << " (" << advice << ")"; std::cerr << ".\n"; } @@ -193,6 +212,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno { option_parser p; + // Deprecated options. p.add<void>("visualizer_sample_multiplier", nullptr, "", [](std::string v) { if (!v.empty()) deprecated( @@ -208,6 +228,40 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno "use extended progressbar_color and progressbar_elapsed_color instead"); }); + p.add<void>("main_window_highlight_color", nullptr, "", [this](std::string v) { + if (!v.empty()) + { + const std::string current_item_prefix_str = "$(" + v + ")$r"; + const std::string current_item_suffix_str = "$/r$(end)"; + current_item_prefix = buffer_wlength( + nullptr, + current_item_prefix_length, + current_item_prefix_str); + current_item_suffix = buffer_wlength( + nullptr, + current_item_suffix_length, + current_item_suffix_str); + deprecated( + "main_window_highlight_color", + 0.9, + "set current_item_prefix = \"" + + current_item_prefix_str + + "\" and current_item_suffix = \"" + + current_item_suffix_str + + "\" to preserve current behavior"); + }; + }); + p.add<void>("active_column_color", nullptr, "", [this](std::string v) { + if (!v.empty()) + { + deprecated( + "active_column_color", + 0.9, + "replaced by current_item_inactive_column_prefix" + " and current_item_inactive_column_suffix"); + }; + }); + // keep the same order of variables as in configuration file p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory); p.add("lyrics_directory", &lyrics_directory, "~/.lyrics/", adjust_directory); @@ -280,31 +334,49 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno return Format::parse(ToWString(std::move(v)), Format::Flags::All ^ Format::Flags::OutputSwitch); }); - p.add("now_playing_prefix", &now_playing_prefix, - "$b", [this](std::string v) { - NC::Buffer result = buffer(v); - now_playing_prefix_length = wideLength(ToWString(result.str())); - return result; - }); - p.add("now_playing_suffix", &now_playing_suffix, - "$/b", [this](std::string v) { - NC::Buffer result = buffer(v); - now_playing_suffix_length = wideLength(ToWString(result.str())); - return result; - }); + p.add("current_item_prefix", ¤t_item_prefix, "$(yellow)$r", + std::bind(buffer_wlength, + ¤t_item_prefix, + std::ref(current_item_prefix_length), + ph::_1)); + p.add("current_item_suffix", ¤t_item_suffix, "$/r$(end)", + std::bind(buffer_wlength, + ¤t_item_suffix, + std::ref(current_item_suffix_length), + ph::_1)); + p.add("current_item_inactive_column_prefix", ¤t_item_inactive_column_prefix, + "$(white)$r", + std::bind(buffer_wlength, + ¤t_item_inactive_column_prefix, + std::ref(current_item_inactive_column_prefix_length), + ph::_1)); + p.add("current_item_inactive_column_suffix", ¤t_item_inactive_column_suffix, + "$/r$(end)", + std::bind(buffer_wlength, + ¤t_item_inactive_column_suffix, + std::ref(current_item_inactive_column_suffix_length), + ph::_1)); + p.add("now_playing_prefix", &now_playing_prefix, "$b", + std::bind(buffer_wlength, + nullptr, + std::ref(now_playing_prefix_length), + ph::_1)); + p.add("now_playing_suffix", &now_playing_suffix, "$/b", + std::bind(buffer_wlength, + nullptr, + std::ref(now_playing_suffix_length), + ph::_1)); p.add("browser_playlist_prefix", &browser_playlist_prefix, "$2playlist$9 ", buffer); - p.add("selected_item_prefix", &selected_item_prefix, - "$6", [this](std::string v) { - NC::Buffer result = buffer(v); - selected_item_prefix_length = wideLength(ToWString(result.str())); - return result; - }); - p.add("selected_item_suffix", &selected_item_suffix, - "$9", [this](std::string v) { - NC::Buffer result = buffer(v); - selected_item_suffix_length = wideLength(ToWString(result.str())); - return result; - }); + p.add("selected_item_prefix", &selected_item_prefix, "$6", + std::bind(buffer_wlength, + nullptr, + std::ref(selected_item_prefix_length), + ph::_1)); + p.add("selected_item_suffix", &selected_item_suffix, "$9", + std::bind(buffer_wlength, + nullptr, + std::ref(selected_item_suffix_length), + ph::_1)); p.add("modified_item_prefix", &modified_item_prefix, "$3>$9 ", buffer); p.add("song_window_title_format", &song_window_title_format, "{%a - }{%t}|{%f}", [](std::string v) { @@ -506,14 +578,12 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno p.add("main_window_color", &main_color, "yellow"); p.add("color1", &color1, "white"); p.add("color2", &color2, "green"); - p.add("main_window_highlight_color", &main_highlight_color, "yellow"); p.add("progressbar_color", &progressbar_color, "black:b"); p.add("progressbar_elapsed_color", &progressbar_elapsed_color, "green:b"); p.add("statusbar_color", &statusbar_color, "default"); p.add("statusbar_time_color", &statusbar_time_color, "default:b"); p.add("player_state_color", &player_state_color, "default:b"); p.add("alternative_ui_separator_color", &alternative_ui_separator_color, "black:b"); - p.add("active_column_color", &active_column_color, "red"); p.add("window_border_color", &window_border, "green", verbose_lexical_cast<NC::Color>); p.add("active_window_border", &active_window_border, "red", verbose_lexical_cast<NC::Color>); diff --git a/src/settings.h b/src/settings.h index 6563e163..676f278c 100644 --- a/src/settings.h +++ b/src/settings.h @@ -98,12 +98,14 @@ struct Configuration NC::Buffer now_playing_prefix; NC::Buffer now_playing_suffix; NC::Buffer modified_item_prefix; + NC::Buffer current_item_prefix; + NC::Buffer current_item_suffix; + NC::Buffer current_item_inactive_column_prefix; + NC::Buffer current_item_inactive_column_suffix; NC::Color header_color; NC::Color main_color; NC::Color statusbar_color; - NC::Color main_highlight_color; - NC::Color active_column_color; NC::FormattedColor color1; NC::FormattedColor color2; @@ -194,6 +196,10 @@ struct Configuration size_t selected_item_suffix_length; size_t now_playing_prefix_length; size_t now_playing_suffix_length; + size_t current_item_prefix_length; + size_t current_item_suffix_length; + size_t current_item_inactive_column_prefix_length; + size_t current_item_inactive_column_suffix_length; ScreenType startup_screen_type; boost::optional<ScreenType> startup_slave_screen_type; diff --git a/src/status.cpp b/src/status.cpp index bf0bc58d..85246a17 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -630,7 +630,7 @@ void Status::Changes::elapsedTime(bool update_elapsed) << NC::TermManip::ClearToEOL << Config.player_state_color << ps - << NC::FormattedColor::End(Config.player_state_color) + << NC::FormattedColor::End<>(Config.player_state_color) << " "; writeCyclicBuffer( np_song, *wFooter, playing_song_scroll_begin, @@ -638,7 +638,7 @@ void Status::Changes::elapsedTime(bool update_elapsed) *wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << Config.statusbar_time_color << tracklength - << NC::FormattedColor::End(Config.statusbar_time_color); + << NC::FormattedColor::End<>(Config.statusbar_time_color); } break; case Design::Alternative: @@ -681,7 +681,7 @@ void Status::Changes::elapsedTime(bool update_elapsed) << NC::TermManip::ClearToEOL << Config.statusbar_time_color << tracklength - << NC::FormattedColor::End(Config.statusbar_time_color); + << NC::FormattedColor::End<>(Config.statusbar_time_color); *wHeader << NC::XY(first_start, 0); @@ -692,7 +692,7 @@ void Status::Changes::elapsedTime(bool update_elapsed) << NC::TermManip::ClearToEOL << Config.player_state_color << ps - << NC::FormattedColor::End(Config.player_state_color) + << NC::FormattedColor::End<>(Config.player_state_color) << NC::XY(second_start, 1); writeCyclicBuffer(second, *wHeader, second_line_scroll_begin, @@ -701,7 +701,7 @@ void Status::Changes::elapsedTime(bool update_elapsed) *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState - << NC::FormattedColor::End(Config.volume_color); + << NC::FormattedColor::End<>(Config.volume_color); flags(); } @@ -733,19 +733,19 @@ void Status::Changes::flags() *wHeader << Config.state_line_color; mvwhline(wHeader->raw(), 1, 0, 0, COLS); - *wHeader << NC::FormattedColor::End(Config.state_line_color); + *wHeader << NC::FormattedColor::End<>(Config.state_line_color); if (!switch_state.empty()) *wHeader << NC::XY(COLS-switch_state.length()-3, 1) << Config.state_line_color << "[" - << NC::FormattedColor::End(Config.state_line_color) + << NC::FormattedColor::End<>(Config.state_line_color) << Config.state_flags_color << switch_state - << NC::FormattedColor::End(Config.state_flags_color) + << NC::FormattedColor::End<>(Config.state_flags_color) << Config.state_line_color << "]" - << NC::FormattedColor::End(Config.state_line_color); + << NC::FormattedColor::End<>(Config.state_line_color); break; case Design::Alternative: @@ -760,12 +760,12 @@ void Status::Changes::flags() *wHeader << NC::XY(COLS-switch_state.length(), 1) << Config.state_flags_color << switch_state - << NC::FormattedColor::End(Config.state_flags_color); + << NC::FormattedColor::End<>(Config.state_flags_color); if (!Config.header_visibility) // in this case also draw separator { *wHeader << Config.alternative_ui_separator_color; mvwhline(wHeader->raw(), 2, 0, 0, COLS); - *wHeader << NC::FormattedColor::End(Config.alternative_ui_separator_color); + *wHeader << NC::FormattedColor::End<>(Config.alternative_ui_separator_color); } break; } @@ -797,7 +797,7 @@ void Status::Changes::mixer() *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState - << NC::FormattedColor::End(Config.volume_color); + << NC::FormattedColor::End<>(Config.volume_color); wHeader->refresh(); } diff --git a/src/statusbar.cpp b/src/statusbar.cpp index 09e5e4f8..1f0159db 100644 --- a/src/statusbar.cpp +++ b/src/statusbar.cpp @@ -69,7 +69,7 @@ void Progressbar::draw(unsigned int elapsed, unsigned int time) } else mvwhline(wFooter->raw(), 0, 0, 0, pb_width); - *wFooter << NC::FormattedColor::End(Config.progressbar_color); + *wFooter << NC::FormattedColor::End<>(Config.progressbar_color); if (time) { *wFooter << Config.progressbar_elapsed_color; @@ -78,7 +78,7 @@ void Progressbar::draw(unsigned int elapsed, unsigned int time) *wFooter << Config.progressbar[0]; if (howlong < wFooter->getWidth()) *wFooter << Config.progressbar[1]; - *wFooter << NC::FormattedColor::End(Config.progressbar_elapsed_color); + *wFooter << NC::FormattedColor::End<>(Config.progressbar_elapsed_color); } } diff --git a/src/title.cpp b/src/title.cpp index 0e19f0d2..8efb6593 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -51,7 +51,7 @@ void drawHeader() << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState - << NC::FormattedColor::End(Config.volume_color); + << NC::FormattedColor::End<>(Config.volume_color); break; case Design::Alternative: std::wstring title = myScreen->title(); @@ -60,7 +60,7 @@ void drawHeader() << Config.alternative_ui_separator_color; mvwhline(wHeader->raw(), 2, 0, 0, COLS); mvwhline(wHeader->raw(), 4, 0, 0, COLS); - *wHeader << NC::FormattedColor::End(Config.alternative_ui_separator_color) + *wHeader << NC::FormattedColor::End<>(Config.alternative_ui_separator_color) << NC::XY((COLS-wideLength(title))/2, 3) << NC::Format::Bold << title diff --git a/src/utility/storage_kind.h b/src/utility/storage_kind.h new file mode 100644 index 00000000..70d69cbf --- /dev/null +++ b/src/utility/storage_kind.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * Copyright (C) 2008-2017 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_UTILITY_STORAGE_KIND_H +#define NCMPCPP_UTILITY_STORAGE_KIND_H + +enum class StorageKind { Reference, Value }; + +#endif // NCMPCPP_UTILITY_VALUE_TYPE_H |