1 #pragma once 2 3 #include <map> 4 5 #include "common.hpp" 6 #include "components/types.hpp" 7 POLYBAR_NS 8 9 using std::map; 10 11 // fwd decl 12 using namespace drawtypes; 13 namespace modules { 14 struct module_interface; 15 } 16 17 class builder { 18 public: 19 explicit builder(const bar_settings& bar); 20 21 void reset(); 22 string flush(); 23 void append(string text); 24 void node(string str); 25 void node(string str, int font_index); 26 void node(const label_t& label); 27 void node_repeat(const string& str, size_t n); 28 void node_repeat(const label_t& label, size_t n); 29 void offset(int pixels); 30 void space(size_t width); 31 void space(); 32 void remove_trailing_space(size_t len); 33 void remove_trailing_space(); 34 void font(int index); 35 void font_close(); 36 void background(rgba color); 37 void background_close(); 38 void color(rgba color); 39 void color_close(); 40 void line_color(const rgba& color); 41 void line_color_close(); 42 void overline_color(rgba color); 43 void overline_color_close(); 44 void underline_color(rgba color); 45 void underline_color_close(); 46 void overline(const rgba& color = rgba{}); 47 void overline_close(); 48 void underline(const rgba& color = rgba{}); 49 void underline_close(); 50 void control(controltag tag); 51 void action(mousebtn index, string action); 52 void action(mousebtn btn, const modules::module_interface& module, string action, string data); 53 void action(mousebtn index, string action, const label_t& label); 54 void action(mousebtn btn, const modules::module_interface& module, string action, string data, const label_t& label); 55 void action_close(); 56 57 protected: 58 59 void tag_open(syntaxtag tag, const string& value); 60 void tag_open(attribute attr); 61 void tag_close(syntaxtag tag); 62 void tag_close(attribute attr); 63 64 private: 65 const bar_settings m_bar; 66 string m_output; 67 68 map<syntaxtag, int> m_tags{}; 69 map<syntaxtag, string> m_colors{}; 70 map<attribute, bool> m_attrs{}; 71 72 int m_fontindex{0}; 73 }; 74 75 POLYBAR_NS_END 76