2016-06-15 03:32:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "components/types.hpp"
|
|
|
|
#include "config.hpp"
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
#define DEFAULT_SPACING -1
|
|
|
|
|
|
|
|
#ifndef BUILDER_SPACE_TOKEN
|
|
|
|
#define BUILDER_SPACE_TOKEN "%__"
|
|
|
|
#endif
|
|
|
|
|
2016-11-19 14:49:03 +00:00
|
|
|
// fwd decl
|
|
|
|
namespace drawtypes {
|
|
|
|
class label;
|
|
|
|
using label_t = shared_ptr<label>;
|
|
|
|
using icon = label;
|
|
|
|
using icon_t = label_t;
|
|
|
|
}
|
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
using namespace drawtypes;
|
|
|
|
|
|
|
|
class builder {
|
|
|
|
public:
|
2016-11-24 18:24:47 +00:00
|
|
|
explicit builder(const bar_settings bar) : m_bar(bar) {}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
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);
|
2016-11-25 12:55:15 +00:00
|
|
|
void node(const label_t& label, bool add_space = false);
|
2016-11-30 21:17:52 +00:00
|
|
|
void node_repeat(string str, size_t n, bool add_space = false);
|
|
|
|
void node_repeat(const label_t& label, size_t n, bool add_space = false);
|
2016-11-02 19:22:45 +00:00
|
|
|
void offset(int pixels = 0);
|
|
|
|
void space(int width = DEFAULT_SPACING);
|
|
|
|
void remove_trailing_space(int width = DEFAULT_SPACING);
|
|
|
|
void font(int index);
|
2016-11-24 18:24:47 +00:00
|
|
|
void font_close();
|
2016-11-02 19:22:45 +00:00
|
|
|
void background(string color);
|
2016-11-24 18:24:47 +00:00
|
|
|
void background_close();
|
|
|
|
void color(string color);
|
|
|
|
void color_alpha(string alpha);
|
|
|
|
void color_close();
|
2016-11-25 12:55:15 +00:00
|
|
|
void line_color(const string& color);
|
2016-11-24 18:24:47 +00:00
|
|
|
void line_color_close();
|
2016-11-21 15:14:40 +00:00
|
|
|
void overline_color(string color);
|
2016-11-24 18:24:47 +00:00
|
|
|
void overline_color_close();
|
2016-11-21 15:14:40 +00:00
|
|
|
void underline_color(string color);
|
2016-11-24 18:24:47 +00:00
|
|
|
void underline_color_close();
|
2016-11-25 12:55:15 +00:00
|
|
|
void overline(const string& color = "");
|
2016-11-24 18:24:47 +00:00
|
|
|
void overline_close();
|
2016-11-25 12:55:15 +00:00
|
|
|
void underline(const string& color = "");
|
2016-11-24 18:24:47 +00:00
|
|
|
void underline_close();
|
2016-11-02 19:22:45 +00:00
|
|
|
void cmd(mousebtn index, string action, bool condition = true);
|
2016-11-24 18:24:47 +00:00
|
|
|
void cmd_close();
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
protected:
|
2016-11-24 18:24:47 +00:00
|
|
|
string background_hex();
|
|
|
|
string foreground_hex();
|
|
|
|
|
2016-11-25 12:55:15 +00:00
|
|
|
void tag_open(syntaxtag tag, const string& value);
|
2016-11-24 18:24:47 +00:00
|
|
|
void tag_open(attribute attr);
|
|
|
|
void tag_close(syntaxtag tag);
|
|
|
|
void tag_close(attribute attr);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const bar_settings m_bar;
|
|
|
|
string m_output;
|
2016-11-24 18:24:47 +00:00
|
|
|
|
|
|
|
map<syntaxtag, int> m_tags{
|
2016-11-25 07:42:31 +00:00
|
|
|
// clang-format off
|
|
|
|
{syntaxtag::A, 0},
|
|
|
|
{syntaxtag::B, 0},
|
|
|
|
{syntaxtag::F, 0},
|
|
|
|
{syntaxtag::T, 0},
|
|
|
|
{syntaxtag::u, 0},
|
|
|
|
{syntaxtag::o, 0},
|
|
|
|
// clang-format on
|
2016-06-15 03:32:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
map<syntaxtag, string> m_colors{
|
2016-11-25 07:42:31 +00:00
|
|
|
// clang-format off
|
|
|
|
{syntaxtag::B, ""},
|
|
|
|
{syntaxtag::F, ""},
|
|
|
|
{syntaxtag::u, ""},
|
|
|
|
{syntaxtag::o, ""},
|
|
|
|
// clang-format on
|
2016-06-15 03:32:35 +00:00
|
|
|
};
|
|
|
|
|
2016-11-24 18:24:47 +00:00
|
|
|
uint8_t m_attributes{static_cast<uint8_t>(attribute::NONE)};
|
|
|
|
uint8_t m_fontindex{1};
|
|
|
|
|
|
|
|
string m_background;
|
|
|
|
string m_foreground;
|
2016-06-15 03:32:35 +00:00
|
|
|
};
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|