Replace highlight colors with prefixes and suffixes

This commit is contained in:
Andrzej Rybczak
2017-03-28 11:31:09 +02:00
parent 8134e6e23b
commit 19d32648ed
32 changed files with 364 additions and 155 deletions

1
NEWS
View File

@@ -33,6 +33,7 @@ ncmpcpp-0.8 (????-??-??)
* Added configuration option 'media_library_albums_split_by_date' that determines whether albums in media library should be split by date. * Added configuration option 'media_library_albums_split_by_date' that determines whether albums in media library should be split by date.
* Added configuration option 'ignore_diacritics' that allows for ignoring diacritics while searching (boost compiled with ICU support is required). * Added configuration option 'ignore_diacritics' that allows for ignoring diacritics while searching (boost compiled with ICU support is required).
* Added support for reading multiple bindings files (the ones in ~/.ncmpcpp/bindings and $XDG_CONFIG_HOME/ncmpcpp/bindings are read by default). * Added support for reading multiple bindings files (the ones in ~/.ncmpcpp/bindings and $XDG_CONFIG_HOME/ncmpcpp/bindings are read by default).
* 'main_window_highlight_color' and 'active_column_color' configuration options are now deprecated in favor of 'current_item_prefix'/'current_item_suffix' and 'current_item_inactive_column_prefix'/'current_item_inactive_column_suffix' (note that now highlight of inactive column is customizable instead of the active one in presence of multiple columns).
ncmpcpp-0.7.7 (2016-10-31) ncmpcpp-0.7.7 (2016-10-31)
* Fixed compilation on 32bit platforms. * Fixed compilation on 32bit platforms.

View File

@@ -188,11 +188,18 @@
# #
#song_library_format = {%n - }{%t}|{%f} #song_library_format = {%n - }{%t}|{%f}
# #
#
#alternative_header_first_line_format = $b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b #alternative_header_first_line_format = $b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b
# #
#alternative_header_second_line_format = {{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D} #alternative_header_second_line_format = {{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}
# #
#current_item_prefix = $(yellow)$r
#
#current_item_suffix = $/r$(end)
#
#current_item_inactive_column_prefix = $(white)$r
#
#current_item_inactive_column_suffix = $/r$(end)
#
#now_playing_prefix = $b #now_playing_prefix = $b
# #
#now_playing_suffix = $/b #now_playing_suffix = $/b
@@ -519,8 +526,6 @@
# #
#color2 = green #color2 = green
# #
#main_window_highlight_color = yellow
#
#progressbar_color = black:b #progressbar_color = black:b
# #
#progressbar_elapsed_color = green:b #progressbar_elapsed_color = green:b
@@ -533,8 +538,6 @@
# #
#alternative_ui_separator_color = black:b #alternative_ui_separator_color = black:b
# #
#active_column_color = red
#
#window_border_color = green #window_border_color = green
# #
#active_window_border = red #active_window_border = red

View File

@@ -121,6 +121,18 @@ Now playing song format for the first line in alternative user interface header
.B alternative_header_second_line_format = TEXT .B alternative_header_second_line_format = TEXT
Now playing song format for the second line in alternative user interface header window. Now playing song format for the second line in alternative user interface header window.
.TP .TP
.B current_item_prefix = TEXT
Prefix for currently selected item.
.TP
.B current_item_suffix = TEXT
Suffix for currently selected item.
.TP
.B current_item_inactive_column_prefix = TEXT
Prefix for currently selected item in the inactive column.
.TP
.B current_item_inactive_column_suffix = TEXT
Suffix for currently selected item in the inactive column.
.TP
.B now_playing_prefix = TEXT .B now_playing_prefix = TEXT
Prefix for currently playing song. Prefix for currently playing song.
.TP .TP
@@ -378,9 +390,6 @@ One of colors used in Song info, Tiny tag editor and Search engine.
.B color2 = COLOR .B color2 = COLOR
One of colors used in Song info, Tiny tag editor and Search engine. One of colors used in Song info, Tiny tag editor and Search engine.
.TP .TP
.B main_window_highlight_color = COLOR
Color of main window's highlight.
.TP
.B progressbar_color = COLOR .B progressbar_color = COLOR
Color of progressbar. Color of progressbar.
.TP .TP
@@ -399,9 +408,6 @@ Color of player state shown in statusbar.
.B alternative_ui_separator_color = COLOR .B alternative_ui_separator_color = COLOR
Color of separators used in alternative user interface. Color of separators used in alternative user interface.
.TP .TP
.B active_column_color = COLOR
Color of active column's highlight.
.TP
.B window_border_color = BORDER .B window_border_color = BORDER
Border color of pop-up windows. If set to 'none', no border will be shown. Border color of pop-up windows. If set to 'none', no border will be shown.
.TP .TP

View File

@@ -91,6 +91,7 @@ noinst_HEADERS = \
utility/option_parser.h \ utility/option_parser.h \
utility/readline.h \ utility/readline.h \
utility/scoped_value.h \ utility/scoped_value.h \
utility/storage_kind.h \
utility/shared_resource.h \ utility/shared_resource.h \
utility/string.h \ utility/string.h \
utility/type_conversions.h \ utility/type_conversions.h \

View File

@@ -2977,7 +2977,7 @@ void seek(SearchDirection sd)
*wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1) *wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1)
<< Config.statusbar_time_color << Config.statusbar_time_color
<< tracklength << tracklength
<< NC::FormattedColor::End(Config.statusbar_time_color); << NC::FormattedColor::End<>(Config.statusbar_time_color);
break; break;
case Design::Alternative: case Design::Alternative:
if (Config.display_remaining_time) if (Config.display_remaining_time)
@@ -2992,7 +2992,7 @@ void seek(SearchDirection sd)
*wHeader << NC::XY(0, 0) *wHeader << NC::XY(0, 0)
<< Config.statusbar_time_color << Config.statusbar_time_color
<< tracklength << tracklength
<< NC::FormattedColor::End(Config.statusbar_time_color) << NC::FormattedColor::End<>(Config.statusbar_time_color)
<< " "; << " ";
wHeader->refresh(); wHeader->refresh();
break; break;

View File

@@ -23,22 +23,37 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/range/adaptor/reversed.hpp> #include <boost/range/adaptor/reversed.hpp>
#include "window.h" #include "curses/window.h"
#include "utility/storage_kind.h"
namespace NC { namespace NC {
struct FormattedColor struct FormattedColor
{ {
template <StorageKind storage = StorageKind::Reference>
struct End struct End
{ {
End(const FormattedColor &fc) explicit End(const FormattedColor &fc)
: m_fc(fc) : m_fc(fc)
{ } { }
const FormattedColor &base() const { return m_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: private:
const FormattedColor &m_fc; typename std::conditional<storage == StorageKind::Reference,
const FormattedColor &,
FormattedColor>::type m_fc;
}; };
typedef std::vector<Format> Formats; typedef std::vector<Format> Formats;
@@ -55,6 +70,12 @@ private:
Formats m_formats; 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); std::istream &operator>>(std::istream &is, FormattedColor &fc);
template <typename OutputStreamT> template <typename OutputStreamT>
@@ -66,8 +87,9 @@ OutputStreamT &operator<<(OutputStreamT &os, const FormattedColor &fc)
return os; return os;
} }
template <typename OutputStreamT> template <typename OutputStreamT, StorageKind storage>
OutputStreamT &operator<<(OutputStreamT &os, const FormattedColor::End &rfc) OutputStreamT &operator<<(OutputStreamT &os,
const FormattedColor::End<storage> &rfc)
{ {
if (rfc.base().color() != Color::Default) if (rfc.base().color() != Color::Default)
os << Color::End; os << Color::End;

View File

@@ -29,9 +29,10 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include "curses/formatted_color.h"
#include "curses/strbuffer.h"
#include "curses/window.h"
#include "utility/const.h" #include "utility/const.h"
#include "strbuffer.h"
#include "window.h"
namespace NC { namespace NC {
@@ -368,9 +369,11 @@ struct Menu: Window, List
/// @param b pointer to buffer that contains the suffix /// @param b pointer to buffer that contains the suffix
void setSelectedSuffix(const Buffer &b) { m_selected_suffix = b; } void setSelectedSuffix(const Buffer &b) { m_selected_suffix = b; }
/// Sets custom color of highlighted position void setHighlightPrefix(const Buffer &b) { m_highlight_prefix = b; }
/// @param col custom color void setHighlightSuffix(const Buffer &b) { m_highlight_suffix = b; }
void setHighlightColor(Color color) { m_highlight_color = std::move(color); }
const Buffer &highlightPrefix() const { return m_highlight_prefix; }
const Buffer &highlightSuffix() const { return m_highlight_suffix; }
/// @return state of highlighting /// @return state of highlighting
bool isHighlighted() { return m_highlight_enabled; } bool isHighlighted() { return m_highlight_enabled; }
@@ -496,7 +499,6 @@ private:
size_t m_beginning; size_t m_beginning;
size_t m_highlight; size_t m_highlight;
Color m_highlight_color;
bool m_highlight_enabled; bool m_highlight_enabled;
bool m_cyclic_scroll_enabled; bool m_cyclic_scroll_enabled;
@@ -504,6 +506,9 @@ private:
size_t m_drawn_position; size_t m_drawn_position;
Buffer m_highlight_prefix;
Buffer m_highlight_suffix;
Buffer m_selected_prefix; Buffer m_selected_prefix;
Buffer m_selected_suffix; Buffer m_selected_suffix;
}; };

View File

@@ -39,16 +39,18 @@ Menu<ItemT>::Menu(size_t startx,
const std::string &title, const std::string &title,
Color color, Color color,
Border border) 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_item_displayer(nullptr)
, m_filter_predicate(nullptr) , m_filter_predicate(nullptr)
, m_beginning(0) , m_beginning(0)
, m_highlight(0) , m_highlight(0)
, m_highlight_color(m_base_color)
, m_highlight_enabled(true) , m_highlight_enabled(true)
, m_cyclic_scroll_enabled(false) , m_cyclic_scroll_enabled(false)
, m_autocenter_cursor(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; m_items = &m_all_items;
} }
@@ -59,11 +61,12 @@ Menu<ItemT>::Menu(const Menu &rhs)
, m_filter_predicate(rhs.m_filter_predicate) , m_filter_predicate(rhs.m_filter_predicate)
, m_beginning(rhs.m_beginning) , m_beginning(rhs.m_beginning)
, m_highlight(rhs.m_highlight) , m_highlight(rhs.m_highlight)
, m_highlight_color(rhs.m_highlight_color)
, m_highlight_enabled(rhs.m_highlight_enabled) , m_highlight_enabled(rhs.m_highlight_enabled)
, m_cyclic_scroll_enabled(rhs.m_cyclic_scroll_enabled) , m_cyclic_scroll_enabled(rhs.m_cyclic_scroll_enabled)
, m_autocenter_cursor(rhs.m_autocenter_cursor) , m_autocenter_cursor(rhs.m_autocenter_cursor)
, m_drawn_position(rhs.m_drawn_position) , 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_prefix(rhs.m_selected_prefix)
, m_selected_suffix(rhs.m_selected_suffix) , 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_filtered_items(std::move(rhs.m_filtered_items))
, m_beginning(rhs.m_beginning) , m_beginning(rhs.m_beginning)
, m_highlight(rhs.m_highlight) , m_highlight(rhs.m_highlight)
, m_highlight_color(rhs.m_highlight_color)
, m_highlight_enabled(rhs.m_highlight_enabled) , m_highlight_enabled(rhs.m_highlight_enabled)
, m_cyclic_scroll_enabled(rhs.m_cyclic_scroll_enabled) , m_cyclic_scroll_enabled(rhs.m_cyclic_scroll_enabled)
, m_autocenter_cursor(rhs.m_autocenter_cursor) , m_autocenter_cursor(rhs.m_autocenter_cursor)
, m_drawn_position(rhs.m_drawn_position) , 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_prefix(std::move(rhs.m_selected_prefix))
, m_selected_suffix(std::move(rhs.m_selected_suffix)) , 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_filtered_items, rhs.m_filtered_items);
std::swap(m_beginning, rhs.m_beginning); std::swap(m_beginning, rhs.m_beginning);
std::swap(m_highlight, rhs.m_highlight); 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_highlight_enabled, rhs.m_highlight_enabled);
std::swap(m_cyclic_scroll_enabled, rhs.m_cyclic_scroll_enabled); std::swap(m_cyclic_scroll_enabled, rhs.m_cyclic_scroll_enabled);
std::swap(m_autocenter_cursor, rhs.m_autocenter_cursor); std::swap(m_autocenter_cursor, rhs.m_autocenter_cursor);
std::swap(m_drawn_position, rhs.m_drawn_position); 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_prefix, rhs.m_selected_prefix);
std::swap(m_selected_suffix, rhs.m_selected_suffix); std::swap(m_selected_suffix, rhs.m_selected_suffix);
if (rhs.m_items == &rhs.m_all_items) if (rhs.m_items == &rhs.m_all_items)
@@ -211,10 +216,7 @@ void Menu<ItemT>::refresh()
continue; continue;
} }
if (m_highlight_enabled && m_drawn_position == m_highlight) if (m_highlight_enabled && m_drawn_position == m_highlight)
{ *this << m_highlight_prefix;
*this << Format::Reverse;
*this << m_highlight_color;
}
if ((*m_items)[m_drawn_position].isSelected()) if ((*m_items)[m_drawn_position].isSelected())
*this << m_selected_prefix; *this << m_selected_prefix;
*this << NC::TermManip::ClearToEOL; *this << NC::TermManip::ClearToEOL;
@@ -223,10 +225,7 @@ void Menu<ItemT>::refresh()
if ((*m_items)[m_drawn_position].isSelected()) if ((*m_items)[m_drawn_position].isSelected())
*this << m_selected_suffix; *this << m_selected_suffix;
if (m_highlight_enabled && m_drawn_position == m_highlight) if (m_highlight_enabled && m_drawn_position == m_highlight)
{ *this << m_highlight_suffix;
*this << Color::End;
*this << Format::NoReverse;
}
} }
Window::refresh(); Window::refresh();
} }

View File

@@ -22,12 +22,14 @@
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <iostream> #include <iostream>
#include "scrollpad.h" #include "curses/scrollpad.h"
#include "utility/storage_kind.h"
namespace { namespace {
template <typename PropT> template <typename BeginT, typename EndT>
bool regexSearch(NC::Buffer &buf, PropT begin, const std::string &ws, PropT end, boost::regex::flag_type flags, size_t id) bool regexSearch(NC::Buffer &buf, const BeginT &begin, const std::string &ws,
const EndT &end, boost::regex::flag_type flags, size_t id)
{ {
try { try {
boost::regex rx(ws, flags); boost::regex rx(ws, flags);
@@ -269,16 +271,29 @@ void Scrollpad::reset()
m_beginning = 0; 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); 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); 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) void Scrollpad::removeProperties(size_t id)
{ {
m_buffer.removeProperties(id); m_buffer.removeProperties(id);

View File

@@ -21,8 +21,8 @@
#ifndef NCMPCPP_SCROLLPAD_H #ifndef NCMPCPP_SCROLLPAD_H
#define NCMPCPP_SCROLLPAD_H #define NCMPCPP_SCROLLPAD_H
#include "window.h" #include "curses/window.h"
#include "strbuffer.h" #include "curses/strbuffer.h"
namespace NC { namespace NC {
@@ -46,9 +46,11 @@ struct Scrollpad: public Window
void flush(); void flush();
void reset(); 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); 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); size_t flags, size_t id = -2);
void removeProperties(size_t id = -2); void removeProperties(size_t id = -2);

View File

@@ -24,7 +24,8 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <map> #include <map>
#include "window.h" #include "curses/formatted_color.h"
#include "curses/window.h"
namespace NC { namespace NC {
@@ -40,6 +41,11 @@ template <typename CharT> class BasicBuffer
size_t id() const { return m_id; } 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> template <typename OutputStreamT>
friend OutputStreamT &operator<<(OutputStreamT &os, const Property &p) friend OutputStreamT &operator<<(OutputStreamT &os, const Property &p)
{ {
@@ -48,7 +54,11 @@ template <typename CharT> class BasicBuffer
} }
private: private:
boost::variant<Color, Format> m_impl; boost::variant<Color,
Format,
FormattedColor,
FormattedColor::End<StorageKind::Value>
> m_impl;
size_t m_id; size_t m_id;
}; };
@@ -131,13 +141,13 @@ public:
return *this; return *this;
} }
BasicBuffer<CharT> &operator<<(Color color) BasicBuffer<CharT> &operator<<(const Color &color)
{ {
addProperty(m_string.size(), color); addProperty(m_string.size(), color);
return *this; return *this;
} }
BasicBuffer<CharT> &operator<<(Format format) BasicBuffer<CharT> &operator<<(const Format &format)
{ {
addProperty(m_string.size(), format); addProperty(m_string.size(), format);
return *this; return *this;
@@ -169,6 +179,14 @@ private:
typedef BasicBuffer<char> Buffer; typedef BasicBuffer<char> Buffer;
typedef BasicBuffer<wchar_t> WBuffer; 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> template <typename OutputStreamT, typename CharT>
OutputStreamT &operator<<(OutputStreamT &os, const BasicBuffer<CharT> &buffer) OutputStreamT &operator<<(OutputStreamT &os, const BasicBuffer<CharT> &buffer)
{ {

View File

@@ -510,6 +510,7 @@ Window::Window(const Window &rhs)
, m_reverse_counter(rhs.m_reverse_counter) , m_reverse_counter(rhs.m_reverse_counter)
, m_alt_charset_counter(rhs.m_alt_charset_counter) , m_alt_charset_counter(rhs.m_alt_charset_counter)
{ {
setColor(m_color);
} }
Window::Window(Window &&rhs) Window::Window(Window &&rhs)

View File

@@ -143,6 +143,13 @@ void showSongs(NC::Menu<T> &menu, const MPD::Song &s, const SongList &list, cons
if (!right_aligned.str().empty()) if (!right_aligned.str().empty())
{ {
size_t x_off = menu.getWidth() - wideLength(ToWString(right_aligned.str())); 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) if (is_now_playing)
x_off -= Config.now_playing_suffix_length; x_off -= Config.now_playing_suffix_length;
if (is_selected) 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); is_in_playlist, discard_colors);
int menu_width = menu.getWidth(); 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) if (is_now_playing)
{ {
menu_width -= Config.now_playing_prefix_length; menu_width -= Config.now_playing_prefix_length;
@@ -343,7 +362,7 @@ void Display::Tags(NC::Menu<MPD::MutableSong> &menu)
menu << Charset::utf8ToLocale(s.getName()) menu << Charset::utf8ToLocale(s.getName())
<< Config.color2 << Config.color2
<< " -> " << " -> "
<< NC::FormattedColor::End(Config.color2) << NC::FormattedColor::End<>(Config.color2)
<< Charset::utf8ToLocale(s.getNewName()); << Charset::utf8ToLocale(s.getNewName());
} }
} }

View File

@@ -497,7 +497,7 @@ void ShowTag(BufferT &buf, const std::string &tag)
if (tag.empty()) if (tag.empty())
buf << Config.empty_tags_color buf << Config.empty_tags_color
<< Config.empty_tag << Config.empty_tag
<< NC::FormattedColor::End(Config.empty_tags_color); << NC::FormattedColor::End<>(Config.empty_tags_color);
else else
buf << tag; buf << tag;
} }
@@ -509,6 +509,20 @@ inline NC::Buffer ShowTag(const std::string &tag)
return result; 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) inline const char *withErrors(bool success)
{ {
return success ? "" : " " "(with errors)"; return success ? "" : " " "(with errors)";

View File

@@ -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 artists:\n", NC::Format::NoBold, 0);
w.setProperties(NC::Format::Bold, "\n\nSimilar tags:\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, w.setProperties(Config.color2, "\n * ", boost::regex::literal);
boost::regex::literal);
} }
Service::Result ArtistInfo::processData(const std::string &data) Service::Result ArtistInfo::processData(const std::string &data)

View File

@@ -135,7 +135,7 @@ Browser::Browser()
, m_current_directory("/") , 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 = 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.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor); w.centeredCursor(Config.centered_cursor);
w.setSelectedPrefix(Config.selected_item_prefix); w.setSelectedPrefix(Config.selected_item_prefix);

View File

@@ -189,7 +189,7 @@ MediaLibrary::MediaLibrary()
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2; 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 = 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.cyclicScrolling(Config.use_cyclic_scrolling);
Tags.centeredCursor(Config.centered_cursor); Tags.centeredCursor(Config.centered_cursor);
Tags.setSelectedPrefix(Config.selected_item_prefix); 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 = 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.cyclicScrolling(Config.use_cyclic_scrolling);
Albums.centeredCursor(Config.centered_cursor); Albums.centeredCursor(Config.centered_cursor);
Albums.setSelectedPrefix(Config.selected_item_prefix); 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 = 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.cyclicScrolling(Config.use_cyclic_scrolling);
Songs.centeredCursor(Config.centered_cursor); Songs.centeredCursor(Config.centered_cursor);
Songs.setSelectedPrefix(Config.selected_item_prefix); Songs.setSelectedPrefix(Config.selected_item_prefix);
@@ -814,17 +814,17 @@ void MediaLibrary::previousColumn()
{ {
if (isActiveWindow(Songs)) if (isActiveWindow(Songs))
{ {
Songs.setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(Songs);
w->refresh(); w->refresh();
w = &Albums; w = &Albums;
Albums.setHighlightColor(Config.active_column_color); setHighlightFixes(Albums);
} }
else if (isActiveWindow(Albums) && !hasTwoColumns) else if (isActiveWindow(Albums) && !hasTwoColumns)
{ {
Albums.setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(Albums);
w->refresh(); w->refresh();
w = &Tags; w = &Tags;
Tags.setHighlightColor(Config.active_column_color); setHighlightFixes(Tags);
} }
} }
@@ -850,17 +850,17 @@ void MediaLibrary::nextColumn()
{ {
if (isActiveWindow(Tags)) if (isActiveWindow(Tags))
{ {
Tags.setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(Tags);
w->refresh(); w->refresh();
w = &Albums; w = &Albums;
Albums.setHighlightColor(Config.active_column_color); setHighlightFixes(Albums);
} }
else if (isActiveWindow(Albums)) else if (isActiveWindow(Albums))
{ {
Albums.setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(Albums);
w->refresh(); w->refresh();
w = &Songs; w = &Songs;
Songs.setHighlightColor(Config.active_column_color); setHighlightFixes(Songs);
} }
} }

View File

@@ -26,6 +26,7 @@
#include "charset.h" #include "charset.h"
#include "display.h" #include "display.h"
#include "global.h" #include "global.h"
#include "helpers.h"
#include "settings.h" #include "settings.h"
#include "status.h" #include "status.h"
#include "statusbar.h" #include "statusbar.h"
@@ -43,7 +44,7 @@ Outputs::Outputs()
{ {
w.cyclicScrolling(Config.use_cyclic_scrolling); w.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor); w.centeredCursor(Config.centered_cursor);
w.setHighlightColor(Config.main_highlight_color); setHighlightFixes(w);
w.setItemDisplayer([](NC::Menu<MPD::Output> &menu) { w.setItemDisplayer([](NC::Menu<MPD::Output> &menu) {
auto &output = menu.drawn()->value(); auto &output = menu.drawn()->value();
if (output.enabled()) if (output.enabled())

View File

@@ -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 = 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.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor); w.centeredCursor(Config.centered_cursor);
w.setHighlightColor(Config.main_highlight_color); setHighlightFixes(w);
w.setSelectedPrefix(Config.selected_item_prefix); w.setSelectedPrefix(Config.selected_item_prefix);
w.setSelectedSuffix(Config.selected_item_suffix); w.setSelectedSuffix(Config.selected_item_suffix);
switch (Config.playlist_display_mode) switch (Config.playlist_display_mode)

View File

@@ -71,7 +71,7 @@ PlaylistEditor::PlaylistEditor()
RightColumnWidth = COLS-LeftColumnWidth-1; RightColumnWidth = COLS-LeftColumnWidth-1;
Playlists = NC::Menu<MPD::Playlist>(0, MainStartY, LeftColumnWidth, MainHeight, Config.titles_visibility ? "Playlists" : "", Config.main_color, NC::Border()); 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.cyclicScrolling(Config.use_cyclic_scrolling);
Playlists.centeredCursor(Config.centered_cursor); Playlists.centeredCursor(Config.centered_cursor);
Playlists.setSelectedPrefix(Config.selected_item_prefix); 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 = 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.cyclicScrolling(Config.use_cyclic_scrolling);
Content.centeredCursor(Config.centered_cursor); Content.centeredCursor(Config.centered_cursor);
Content.setSelectedPrefix(Config.selected_item_prefix); Content.setSelectedPrefix(Config.selected_item_prefix);
@@ -431,10 +431,10 @@ void PlaylistEditor::previousColumn()
{ {
if (isActiveWindow(Content)) if (isActiveWindow(Content))
{ {
Content.setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(Content);
w->refresh(); w->refresh();
w = &Playlists; w = &Playlists;
Playlists.setHighlightColor(Config.active_column_color); setHighlightFixes(Playlists);
} }
} }
@@ -453,10 +453,10 @@ void PlaylistEditor::nextColumn()
{ {
if (isActiveWindow(Playlists)) if (isActiveWindow(Playlists))
{ {
Playlists.setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(Playlists);
w->refresh(); w->refresh();
w = &Content; w = &Content;
Content.setHighlightColor(Config.active_column_color); setHighlightFixes(Content);
} }
} }

View File

@@ -175,7 +175,7 @@ size_t SearchEngine::SearchButton = 15;
SearchEngine::SearchEngine() SearchEngine::SearchEngine()
: Screen(NC::Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border())) : 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.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor); w.centeredCursor(Config.centered_cursor);
w.setItemDisplayer(std::bind(Display::SEItems, ph::_1, std::cref(w))); w.setItemDisplayer(std::bind(Display::SEItems, ph::_1, std::cref(w)));
@@ -351,10 +351,10 @@ void SearchEngine::runAction()
<< NC::Format::Bold << NC::Format::Bold
<< Config.color1 << Config.color1
<< "Search results: " << "Search results: "
<< NC::FormattedColor::End(Config.color1) << NC::FormattedColor::End<>(Config.color1)
<< Config.color2 << Config.color2
<< "Found " << found << (found > 1 ? " songs" : " song") << "Found " << found << (found > 1 ? " songs" : " song")
<< NC::FormattedColor::End(Config.color2) << NC::FormattedColor::End<>(Config.color2)
<< NC::Format::NoBold; << NC::Format::NoBold;
w.insertSeparator(ResetButton+3); w.insertSeparator(ResetButton+3);
Statusbar::print("Searching finished"); Statusbar::print("Searching finished");

View File

@@ -69,7 +69,7 @@ SelectedItemsAdder::SelectedItemsAdder()
); );
m_playlist_selector.cyclicScrolling(Config.use_cyclic_scrolling); m_playlist_selector.cyclicScrolling(Config.use_cyclic_scrolling);
m_playlist_selector.centeredCursor(Config.centered_cursor); 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_playlist_selector.setItemDisplayer(DisplayComponent);
m_position_selector = Component( m_position_selector = Component(
@@ -83,7 +83,7 @@ SelectedItemsAdder::SelectedItemsAdder()
); );
m_position_selector.cyclicScrolling(Config.use_cyclic_scrolling); m_position_selector.cyclicScrolling(Config.use_cyclic_scrolling);
m_position_selector.centeredCursor(Config.centered_cursor); 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.setItemDisplayer(DisplayComponent);
m_position_selector.addItem(Entry("At the end of playlist", m_position_selector.addItem(Entry("At the end of playlist",

View File

@@ -100,12 +100,12 @@ void SongInfo::PrepareSong(const MPD::Song &s)
<< Config.color1 << Config.color1
<< key << key
<< ":" << ":"
<< NC::FormattedColor::End(Config.color1) << NC::FormattedColor::End<>(Config.color1)
<< NC::Format::NoBold << NC::Format::NoBold
<< " " << " "
<< Config.color2 << Config.color2
<< value << value
<< NC::FormattedColor::End(Config.color2) << NC::FormattedColor::End<>(Config.color2)
<< "\n"; << "\n";
}; };

View File

@@ -133,7 +133,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser
SetDimensions(0, COLS); 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 = 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->cyclicScrolling(Config.use_cyclic_scrolling);
Dirs->centeredCursor(Config.centered_cursor); Dirs->centeredCursor(Config.centered_cursor);
Dirs->setItemDisplayer([](NC::Menu<std::pair<std::string, std::string>> &menu) { 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 = 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->cyclicScrolling(Config.use_cyclic_scrolling);
TagTypes->centeredCursor(Config.centered_cursor); TagTypes->centeredCursor(Config.centered_cursor);
TagTypes->setItemDisplayer([](NC::Menu<std::string> &menu) { TagTypes->setItemDisplayer([](NC::Menu<std::string> &menu) {
@@ -165,7 +165,7 @@ TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParser
TagTypes->addItem("Save"); TagTypes->addItem("Save");
Tags = new TagsWindow(NC::Menu<MPD::MutableSong>(RightColumnStartX, MainStartY, RightColumnWidth, MainHeight, Config.titles_visibility ? "Tags" : "", Config.main_color, NC::Border())); 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->cyclicScrolling(Config.use_cyclic_scrolling);
Tags->centeredCursor(Config.centered_cursor); Tags->centeredCursor(Config.centered_cursor);
Tags->setSelectedPrefix(Config.selected_item_prefix); Tags->setSelectedPrefix(Config.selected_item_prefix);
@@ -554,7 +554,7 @@ void TagEditor::runAction()
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it) for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
*FParserLegend << Config.color2 *FParserLegend << Config.color2
<< " * " << " * "
<< NC::FormattedColor::End(Config.color2) << NC::FormattedColor::End<>(Config.color2)
<< (*it)->getName() << (*it)->getName()
<< "\n"; << "\n";
FParserLegend->flush(); FParserLegend->flush();
@@ -639,11 +639,11 @@ void TagEditor::runAction()
*FParserPreview << file *FParserPreview << file
<< Config.color2 << Config.color2
<< " -> " << " -> "
<< NC::FormattedColor::End(Config.color2); << NC::FormattedColor::End<>(Config.color2);
if (new_file.empty()) if (new_file.empty())
*FParserPreview << Config.empty_tags_color *FParserPreview << Config.empty_tags_color
<< Config.empty_tag << Config.empty_tag
<< NC::FormattedColor::End(Config.empty_tags_color); << NC::FormattedColor::End<>(Config.empty_tags_color);
else else
*FParserPreview << new_file << extension; *FParserPreview << new_file << extension;
*FParserPreview << "\n\n"; *FParserPreview << "\n\n";
@@ -810,11 +810,11 @@ void TagEditor::runAction()
if (success) if (success)
{ {
Statusbar::print("Tags updated"); Statusbar::print("Tags updated");
TagTypes->setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(*TagTypes);
TagTypes->reset(); TagTypes->reset();
w->refresh(); w->refresh();
w = Dirs; w = Dirs;
Dirs->setHighlightColor(Config.active_column_color); setHighlightFixes(*Dirs);
Mpd.UpdateDirectory(getSharedDirectory(Tags->beginV(), Tags->endV())); Mpd.UpdateDirectory(getSharedDirectory(Tags->beginV(), Tags->endV()));
} }
else else
@@ -878,17 +878,17 @@ void TagEditor::previousColumn()
{ {
if (w == Tags) if (w == Tags)
{ {
Tags->setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(*Tags);
w->refresh(); w->refresh();
w = TagTypes; w = TagTypes;
TagTypes->setHighlightColor(Config.active_column_color); setHighlightFixes(*TagTypes);
} }
else if (w == TagTypes) else if (w == TagTypes)
{ {
TagTypes->setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(*TagTypes);
w->refresh(); w->refresh();
w = Dirs; w = Dirs;
Dirs->setHighlightColor(Config.active_column_color); setHighlightFixes(*Dirs);
} }
else if (w == FParserHelper) else if (w == FParserHelper)
{ {
@@ -922,17 +922,17 @@ void TagEditor::nextColumn()
{ {
if (w == Dirs) if (w == Dirs)
{ {
Dirs->setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(*Dirs);
w->refresh(); w->refresh();
w = TagTypes; w = TagTypes;
TagTypes->setHighlightColor(Config.active_column_color); setHighlightFixes(*TagTypes);
} }
else if (w == TagTypes && TagTypes->choice() < 13 && !Tags->empty()) else if (w == TagTypes && TagTypes->choice() < 13 && !Tags->empty())
{ {
TagTypes->setHighlightColor(Config.main_highlight_color); setHighlightInactiveColumnFixes(*TagTypes);
w->refresh(); w->refresh();
w = Tags; w = Tags;
Tags->setHighlightColor(Config.active_column_color); setHighlightFixes(*Tags);
} }
else if (w == FParser) else if (w == FParser)
{ {

View File

@@ -52,7 +52,8 @@ TinyTagEditor *myTinyTagEditor;
TinyTagEditor::TinyTagEditor() TinyTagEditor::TinyTagEditor()
: Screen(NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::Border())) : 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.cyclicScrolling(Config.use_cyclic_scrolling);
w.centeredCursor(Config.centered_cursor); w.centeredCursor(Config.centered_cursor);
w.setItemDisplayer([](NC::Menu<NC::Buffer> &menu) { w.setItemDisplayer([](NC::Menu<NC::Buffer> &menu) {
@@ -228,12 +229,12 @@ bool TinyTagEditor::getTags()
<< Config.color1 << Config.color1
<< key << key
<< ":" << ":"
<< NC::FormattedColor::End(Config.color1) << NC::FormattedColor::End<>(Config.color1)
<< NC::Format::NoBold << NC::Format::NoBold
<< " " << " "
<< Config.color2 << Config.color2
<< value << value
<< NC::FormattedColor::End(Config.color2); << NC::FormattedColor::End<>(Config.color2);
}; };
print_key_value(w[0].value(), "Filename", itsEdited.getName()); print_key_value(w[0].value(), "Filename", itsEdited.getName());

View File

@@ -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) w << NC::XY(x, base_y+y)
<< c << c
<< Config.visualizer_chars[0] << Config.visualizer_chars[0]
<< NC::FormattedColor::End(c); << NC::FormattedColor::End<>(c);
}; };
int32_t point_y, prev_point_y = 0; 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) w << NC::XY(x, y)
<< c << c
<< Config.visualizer_chars[1] << 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) w << NC::XY(half_width + x, half_height + y)
<< c << c
<< Config.visualizer_chars[0] << 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) w << NC::XY(left_half_width + x, top_half_height + y)
<< c << c
<< Config.visualizer_chars[1] << 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) w << NC::XY(x, y)
<< c << c
<< Config.visualizer_chars[1] << Config.visualizer_chars[1]
<< NC::FormattedColor::End(c); << NC::FormattedColor::End<>(c);
} }
} }
} }

View File

@@ -35,6 +35,8 @@
# include <langinfo.h> # include <langinfo.h>
#endif #endif
namespace ph = std::placeholders;
Configuration Config; Configuration Config;
namespace { namespace {
@@ -177,12 +179,29 @@ NC::Buffer buffer(const std::string &v)
return result; 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 std::cerr << "WARNING: Variable '" << option
<< "' is deprecated and will be removed in " << "' is deprecated and will be removed in "
<< version_removal; << version_removal;
if (advice) if (!advice.empty())
std::cerr << " (" << advice << ")"; std::cerr << " (" << advice << ")";
std::cerr << ".\n"; std::cerr << ".\n";
} }
@@ -193,6 +212,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
{ {
option_parser p; option_parser p;
// Deprecated options.
p.add<void>("visualizer_sample_multiplier", nullptr, "", [](std::string v) { p.add<void>("visualizer_sample_multiplier", nullptr, "", [](std::string v) {
if (!v.empty()) if (!v.empty())
deprecated( 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"); "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 // keep the same order of variables as in configuration file
p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory); p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory);
p.add("lyrics_directory", &lyrics_directory, "~/.lyrics/", 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)), return Format::parse(ToWString(std::move(v)),
Format::Flags::All ^ Format::Flags::OutputSwitch); Format::Flags::All ^ Format::Flags::OutputSwitch);
}); });
p.add("now_playing_prefix", &now_playing_prefix, p.add("current_item_prefix", &current_item_prefix, "$(yellow)$r",
"$b", [this](std::string v) { std::bind(buffer_wlength,
NC::Buffer result = buffer(v); &current_item_prefix,
now_playing_prefix_length = wideLength(ToWString(result.str())); std::ref(current_item_prefix_length),
return result; ph::_1));
}); p.add("current_item_suffix", &current_item_suffix, "$/r$(end)",
p.add("now_playing_suffix", &now_playing_suffix, std::bind(buffer_wlength,
"$/b", [this](std::string v) { &current_item_suffix,
NC::Buffer result = buffer(v); std::ref(current_item_suffix_length),
now_playing_suffix_length = wideLength(ToWString(result.str())); ph::_1));
return result; p.add("current_item_inactive_column_prefix", &current_item_inactive_column_prefix,
}); "$(white)$r",
std::bind(buffer_wlength,
&current_item_inactive_column_prefix,
std::ref(current_item_inactive_column_prefix_length),
ph::_1));
p.add("current_item_inactive_column_suffix", &current_item_inactive_column_suffix,
"$/r$(end)",
std::bind(buffer_wlength,
&current_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("browser_playlist_prefix", &browser_playlist_prefix, "$2playlist$9 ", buffer);
p.add("selected_item_prefix", &selected_item_prefix, p.add("selected_item_prefix", &selected_item_prefix, "$6",
"$6", [this](std::string v) { std::bind(buffer_wlength,
NC::Buffer result = buffer(v); nullptr,
selected_item_prefix_length = wideLength(ToWString(result.str())); std::ref(selected_item_prefix_length),
return result; ph::_1));
}); p.add("selected_item_suffix", &selected_item_suffix, "$9",
p.add("selected_item_suffix", &selected_item_suffix, std::bind(buffer_wlength,
"$9", [this](std::string v) { nullptr,
NC::Buffer result = buffer(v); std::ref(selected_item_suffix_length),
selected_item_suffix_length = wideLength(ToWString(result.str())); ph::_1));
return result;
});
p.add("modified_item_prefix", &modified_item_prefix, "$3>$9 ", buffer); p.add("modified_item_prefix", &modified_item_prefix, "$3>$9 ", buffer);
p.add("song_window_title_format", &song_window_title_format, p.add("song_window_title_format", &song_window_title_format,
"{%a - }{%t}|{%f}", [](std::string v) { "{%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("main_window_color", &main_color, "yellow");
p.add("color1", &color1, "white"); p.add("color1", &color1, "white");
p.add("color2", &color2, "green"); 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_color", &progressbar_color, "black:b");
p.add("progressbar_elapsed_color", &progressbar_elapsed_color, "green:b"); p.add("progressbar_elapsed_color", &progressbar_elapsed_color, "green:b");
p.add("statusbar_color", &statusbar_color, "default"); p.add("statusbar_color", &statusbar_color, "default");
p.add("statusbar_time_color", &statusbar_time_color, "default:b"); p.add("statusbar_time_color", &statusbar_time_color, "default:b");
p.add("player_state_color", &player_state_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("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("window_border_color", &window_border, "green", verbose_lexical_cast<NC::Color>);
p.add("active_window_border", &active_window_border, "red", p.add("active_window_border", &active_window_border, "red",
verbose_lexical_cast<NC::Color>); verbose_lexical_cast<NC::Color>);

View File

@@ -98,12 +98,14 @@ struct Configuration
NC::Buffer now_playing_prefix; NC::Buffer now_playing_prefix;
NC::Buffer now_playing_suffix; NC::Buffer now_playing_suffix;
NC::Buffer modified_item_prefix; 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 header_color;
NC::Color main_color; NC::Color main_color;
NC::Color statusbar_color; NC::Color statusbar_color;
NC::Color main_highlight_color;
NC::Color active_column_color;
NC::FormattedColor color1; NC::FormattedColor color1;
NC::FormattedColor color2; NC::FormattedColor color2;
@@ -194,6 +196,10 @@ struct Configuration
size_t selected_item_suffix_length; size_t selected_item_suffix_length;
size_t now_playing_prefix_length; size_t now_playing_prefix_length;
size_t now_playing_suffix_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; ScreenType startup_screen_type;
boost::optional<ScreenType> startup_slave_screen_type; boost::optional<ScreenType> startup_slave_screen_type;

View File

@@ -630,7 +630,7 @@ void Status::Changes::elapsedTime(bool update_elapsed)
<< NC::TermManip::ClearToEOL << NC::TermManip::ClearToEOL
<< Config.player_state_color << Config.player_state_color
<< ps << ps
<< NC::FormattedColor::End(Config.player_state_color) << NC::FormattedColor::End<>(Config.player_state_color)
<< " "; << " ";
writeCyclicBuffer( writeCyclicBuffer(
np_song, *wFooter, playing_song_scroll_begin, 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) *wFooter << NC::XY(wFooter->getWidth()-tracklength.length(), 1)
<< Config.statusbar_time_color << Config.statusbar_time_color
<< tracklength << tracklength
<< NC::FormattedColor::End(Config.statusbar_time_color); << NC::FormattedColor::End<>(Config.statusbar_time_color);
} }
break; break;
case Design::Alternative: case Design::Alternative:
@@ -681,7 +681,7 @@ void Status::Changes::elapsedTime(bool update_elapsed)
<< NC::TermManip::ClearToEOL << NC::TermManip::ClearToEOL
<< Config.statusbar_time_color << Config.statusbar_time_color
<< tracklength << tracklength
<< NC::FormattedColor::End(Config.statusbar_time_color); << NC::FormattedColor::End<>(Config.statusbar_time_color);
*wHeader << NC::XY(first_start, 0); *wHeader << NC::XY(first_start, 0);
@@ -692,7 +692,7 @@ void Status::Changes::elapsedTime(bool update_elapsed)
<< NC::TermManip::ClearToEOL << NC::TermManip::ClearToEOL
<< Config.player_state_color << Config.player_state_color
<< ps << ps
<< NC::FormattedColor::End(Config.player_state_color) << NC::FormattedColor::End<>(Config.player_state_color)
<< NC::XY(second_start, 1); << NC::XY(second_start, 1);
writeCyclicBuffer(second, *wHeader, second_line_scroll_begin, 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) *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0)
<< Config.volume_color << Config.volume_color
<< VolumeState << VolumeState
<< NC::FormattedColor::End(Config.volume_color); << NC::FormattedColor::End<>(Config.volume_color);
flags(); flags();
} }
@@ -733,19 +733,19 @@ void Status::Changes::flags()
*wHeader << Config.state_line_color; *wHeader << Config.state_line_color;
mvwhline(wHeader->raw(), 1, 0, 0, COLS); 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()) if (!switch_state.empty())
*wHeader << NC::XY(COLS-switch_state.length()-3, 1) *wHeader << NC::XY(COLS-switch_state.length()-3, 1)
<< Config.state_line_color << Config.state_line_color
<< "[" << "["
<< NC::FormattedColor::End(Config.state_line_color) << NC::FormattedColor::End<>(Config.state_line_color)
<< Config.state_flags_color << Config.state_flags_color
<< switch_state << switch_state
<< NC::FormattedColor::End(Config.state_flags_color) << NC::FormattedColor::End<>(Config.state_flags_color)
<< Config.state_line_color << Config.state_line_color
<< "]" << "]"
<< NC::FormattedColor::End(Config.state_line_color); << NC::FormattedColor::End<>(Config.state_line_color);
break; break;
case Design::Alternative: case Design::Alternative:
@@ -760,12 +760,12 @@ void Status::Changes::flags()
*wHeader << NC::XY(COLS-switch_state.length(), 1) *wHeader << NC::XY(COLS-switch_state.length(), 1)
<< Config.state_flags_color << Config.state_flags_color
<< switch_state << 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 if (!Config.header_visibility) // in this case also draw separator
{ {
*wHeader << Config.alternative_ui_separator_color; *wHeader << Config.alternative_ui_separator_color;
mvwhline(wHeader->raw(), 2, 0, 0, COLS); 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; break;
} }
@@ -797,7 +797,7 @@ void Status::Changes::mixer()
*wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0)
<< Config.volume_color << Config.volume_color
<< VolumeState << VolumeState
<< NC::FormattedColor::End(Config.volume_color); << NC::FormattedColor::End<>(Config.volume_color);
wHeader->refresh(); wHeader->refresh();
} }

View File

@@ -69,7 +69,7 @@ void Progressbar::draw(unsigned int elapsed, unsigned int time)
} }
else else
mvwhline(wFooter->raw(), 0, 0, 0, pb_width); mvwhline(wFooter->raw(), 0, 0, 0, pb_width);
*wFooter << NC::FormattedColor::End(Config.progressbar_color); *wFooter << NC::FormattedColor::End<>(Config.progressbar_color);
if (time) if (time)
{ {
*wFooter << Config.progressbar_elapsed_color; *wFooter << Config.progressbar_elapsed_color;
@@ -78,7 +78,7 @@ void Progressbar::draw(unsigned int elapsed, unsigned int time)
*wFooter << Config.progressbar[0]; *wFooter << Config.progressbar[0];
if (howlong < wFooter->getWidth()) if (howlong < wFooter->getWidth())
*wFooter << Config.progressbar[1]; *wFooter << Config.progressbar[1];
*wFooter << NC::FormattedColor::End(Config.progressbar_elapsed_color); *wFooter << NC::FormattedColor::End<>(Config.progressbar_elapsed_color);
} }
} }

View File

@@ -51,7 +51,7 @@ void drawHeader()
<< NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << NC::XY(wHeader->getWidth()-VolumeState.length(), 0)
<< Config.volume_color << Config.volume_color
<< VolumeState << VolumeState
<< NC::FormattedColor::End(Config.volume_color); << NC::FormattedColor::End<>(Config.volume_color);
break; break;
case Design::Alternative: case Design::Alternative:
std::wstring title = myScreen->title(); std::wstring title = myScreen->title();
@@ -60,7 +60,7 @@ void drawHeader()
<< Config.alternative_ui_separator_color; << Config.alternative_ui_separator_color;
mvwhline(wHeader->raw(), 2, 0, 0, COLS); mvwhline(wHeader->raw(), 2, 0, 0, COLS);
mvwhline(wHeader->raw(), 4, 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::XY((COLS-wideLength(title))/2, 3)
<< NC::Format::Bold << NC::Format::Bold
<< title << title

View File

@@ -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