1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00

fix(parser): Proper handling of %{R} #585

This commit is contained in:
Michael Carlberg 2017-05-17 23:11:06 +02:00
parent 5af5292808
commit 0bd8f1f69a
5 changed files with 20 additions and 7 deletions

View file

@ -30,9 +30,10 @@ struct alignment_block {
class renderer
: public signal_receiver<SIGN_PRIORITY_RENDERER, signals::ui::request_snapshot, signals::parser::change_background,
signals::parser::change_foreground, signals::parser::change_underline, signals::parser::change_overline,
signals::parser::change_font, signals::parser::change_alignment, signals::parser::offset_pixel,
signals::parser::attribute_set, signals::parser::attribute_unset, signals::parser::attribute_toggle,
signals::parser::action_begin, signals::parser::action_end, signals::parser::text> {
signals::parser::change_font, signals::parser::change_alignment, signals::parser::reverse_colors,
signals::parser::offset_pixel, signals::parser::attribute_set, signals::parser::attribute_unset,
signals::parser::attribute_toggle, signals::parser::action_begin, signals::parser::action_end,
signals::parser::text> {
public:
using make_type = unique_ptr<renderer>;
static make_type make(const bar_settings& bar);
@ -73,6 +74,7 @@ class renderer
bool on(const signals::parser::change_overline& evt);
bool on(const signals::parser::change_font& evt);
bool on(const signals::parser::change_alignment& evt);
bool on(const signals::parser::reverse_colors&);
bool on(const signals::parser::offset_pixel& evt);
bool on(const signals::parser::attribute_set& evt);
bool on(const signals::parser::attribute_unset& evt);

View file

@ -144,6 +144,9 @@ namespace signals {
struct change_alignment : public detail::value_signal<change_alignment, alignment> {
using base_type::base_type;
};
struct reverse_colors : public detail::base_signal<reverse_colors> {
using base_type::base_type;
};
struct offset_pixel : public detail::value_signal<offset_pixel, int> {
using base_type::base_type;
};

View file

@ -48,6 +48,7 @@ namespace signals {
struct change_overline;
struct change_font;
struct change_alignment;
struct reverse_colors;
struct offset_pixel;
struct attribute_set;
struct attribute_unset;

View file

@ -83,7 +83,7 @@ void parser::codeblock(string&& data, const bar_settings& bar) {
switch (tag) {
case 'B': {
m_sig.emit(change_background{parse_color(m_bg, value, 0UL)});
m_sig.emit(change_background{parse_color(m_bg, value, bar.background)});
break;
}
@ -110,8 +110,7 @@ void parser::codeblock(string&& data, const bar_settings& bar) {
break;
case 'R':
m_sig.emit(change_background{parse_color_string(value, bar.foreground)});
m_sig.emit(change_foreground{parse_color_string(value, bar.background)});
m_sig.emit(reverse_colors{});
break;
case 'O':

View file

@ -205,7 +205,7 @@ void renderer::begin(xcb_rectangle_t rect) {
m_align = alignment::NONE;
// Reset colors
m_bg = 0;
m_bg = m_bar.background;
m_fg = m_bar.foreground;
m_ul = m_bar.underline.color;
m_ol = m_bar.overline.color;
@ -700,6 +700,14 @@ bool renderer::on(const signals::parser::change_alignment& evt) {
return true;
}
bool renderer::on(const signals::parser::reverse_colors&) {
m_log.trace_x("renderer: reverse_colors");
m_fg = m_fg + m_bg;
m_bg = m_fg - m_bg;
m_fg = m_fg - m_bg;
return true;
}
bool renderer::on(const signals::parser::offset_pixel& evt) {
m_log.trace_x("renderer: offset_pixel(%f)", evt.cast());
m_blocks[m_align].x += evt.cast();