refactor: Cleanup handling of syntax tags
This commit is contained in:
parent
199a825494
commit
84d58e7619
25 changed files with 863 additions and 716 deletions
include/components
|
@ -25,88 +25,74 @@ using namespace drawtypes;
|
|||
|
||||
class builder {
|
||||
public:
|
||||
explicit builder(const bar_settings bar, bool lazy = false) : m_bar(bar), m_lazy(lazy) {}
|
||||
|
||||
void set_lazy(bool mode);
|
||||
explicit builder(const bar_settings bar) : m_bar(bar) {}
|
||||
|
||||
string flush();
|
||||
|
||||
void append(string text);
|
||||
|
||||
void node(string str, bool add_space = false);
|
||||
void node(string str, int font_index, bool add_space = false);
|
||||
// void node(progressbar_t bar, float perc, bool add_space = false);
|
||||
void node(label_t label, bool add_space = false);
|
||||
// void node(ramp_t ramp, float perc, bool add_space = false);
|
||||
// void node(animation_t animation, bool add_space = false);
|
||||
|
||||
void offset(int pixels = 0);
|
||||
void space(int width = DEFAULT_SPACING);
|
||||
void remove_trailing_space(int width = DEFAULT_SPACING);
|
||||
|
||||
void invert();
|
||||
|
||||
void font(int index);
|
||||
void font_close(bool force = false);
|
||||
|
||||
void font_close();
|
||||
void background(string color);
|
||||
void background_close(bool force = false);
|
||||
|
||||
void color(string color_);
|
||||
void color_alpha(string alpha_);
|
||||
void color_close(bool force = false);
|
||||
|
||||
void background_close();
|
||||
void color(string color);
|
||||
void color_alpha(string alpha);
|
||||
void color_close();
|
||||
void line_color(string color);
|
||||
void line_color_close(bool force = false);
|
||||
void line_color_close();
|
||||
void overline_color(string color);
|
||||
void overline_color_close(bool force = false);
|
||||
void overline_color_close();
|
||||
void underline_color(string color);
|
||||
void underline_color_close(bool force = false);
|
||||
|
||||
void underline_color_close();
|
||||
void overline(string color = "");
|
||||
void overline_close(bool force = false);
|
||||
|
||||
void overline_close();
|
||||
void underline(string color = "");
|
||||
void underline_close(bool force = false);
|
||||
|
||||
void underline_close();
|
||||
void cmd(mousebtn index, string action, bool condition = true);
|
||||
void cmd_close(bool force = false);
|
||||
void cmd_close();
|
||||
|
||||
protected:
|
||||
void tag_open(char tag, string value);
|
||||
void tag_close(char tag);
|
||||
string background_hex();
|
||||
string foreground_hex();
|
||||
|
||||
void tag_open(syntaxtag tag, string value);
|
||||
void tag_open(attribute attr);
|
||||
void tag_close(syntaxtag tag);
|
||||
void tag_close(attribute attr);
|
||||
|
||||
private:
|
||||
const bar_settings m_bar;
|
||||
|
||||
string m_output;
|
||||
bool m_lazy = true;
|
||||
|
||||
map<syntaxtag, int> m_counters{
|
||||
// clang-format off
|
||||
{syntaxtag::A, 0},
|
||||
{syntaxtag::B, 0},
|
||||
{syntaxtag::F, 0},
|
||||
{syntaxtag::T, 0},
|
||||
{syntaxtag::U, 0},
|
||||
{syntaxtag::Uo, 0},
|
||||
{syntaxtag::Uu, 0},
|
||||
{syntaxtag::O, 0},
|
||||
{syntaxtag::R, 0},
|
||||
// clang-format on
|
||||
map<syntaxtag, int> m_tags{
|
||||
// clang-format off
|
||||
{syntaxtag::A, 0},
|
||||
{syntaxtag::B, 0},
|
||||
{syntaxtag::F, 0},
|
||||
{syntaxtag::T, 0},
|
||||
{syntaxtag::u, 0},
|
||||
{syntaxtag::o, 0},
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
map<syntaxtag, string> m_colors{
|
||||
// clang-format off
|
||||
{syntaxtag::B, ""},
|
||||
{syntaxtag::F, ""},
|
||||
{syntaxtag::U, ""},
|
||||
{syntaxtag::Uu, ""},
|
||||
{syntaxtag::Uo, ""},
|
||||
// clang-format on
|
||||
// clang-format off
|
||||
{syntaxtag::B, ""},
|
||||
{syntaxtag::F, ""},
|
||||
{syntaxtag::u, ""},
|
||||
{syntaxtag::o, ""},
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
int m_fontindex = 1;
|
||||
uint8_t m_attributes{static_cast<uint8_t>(attribute::NONE)};
|
||||
uint8_t m_fontindex{1};
|
||||
|
||||
string m_background;
|
||||
string m_foreground;
|
||||
};
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue