2016-06-14 23:32:35 -04:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-25 14:26:48 -04:00
|
|
|
#include <stack>
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "common.hpp"
|
2016-11-25 07:55:15 -05:00
|
|
|
#include "errors.hpp"
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-12-05 14:41:00 -05:00
|
|
|
class signal_emitter;
|
2017-01-19 05:11:28 -05:00
|
|
|
enum class attribute;
|
|
|
|
enum class mousebtn;
|
2016-12-19 23:05:43 -05:00
|
|
|
struct bar_settings;
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2016-11-24 22:10:26 -05:00
|
|
|
DEFINE_ERROR(parser_error);
|
|
|
|
DEFINE_CHILD_ERROR(unrecognized_token, parser_error);
|
|
|
|
DEFINE_CHILD_ERROR(unrecognized_attribute, parser_error);
|
|
|
|
DEFINE_CHILD_ERROR(unclosed_actionblocks, parser_error);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
class parser {
|
|
|
|
public:
|
2016-12-19 23:05:43 -05:00
|
|
|
using make_type = unique_ptr<parser>;
|
|
|
|
static make_type make();
|
2016-12-15 11:14:56 -05:00
|
|
|
|
2016-12-19 23:05:43 -05:00
|
|
|
public:
|
|
|
|
explicit parser(signal_emitter& emitter);
|
|
|
|
void parse(const bar_settings& bar, string data);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
protected:
|
2016-12-19 23:05:43 -05:00
|
|
|
void codeblock(string&& data, const bar_settings& bar);
|
2016-12-13 23:17:18 -05:00
|
|
|
size_t text(string&& data);
|
|
|
|
|
2017-04-26 13:25:02 -04:00
|
|
|
unsigned int parse_color(std::stack<unsigned int>& color_stack, string& value, unsigned int fallback);
|
|
|
|
unsigned int parse_color_string(const string& s, unsigned int fallback = 0);
|
|
|
|
int parse_fontindex(const string& value);
|
2016-11-25 07:55:15 -05:00
|
|
|
attribute parse_attr(const char attr);
|
2016-12-13 23:17:18 -05:00
|
|
|
mousebtn parse_action_btn(const string& data);
|
|
|
|
string parse_action_cmd(string&& data);
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
private:
|
2016-12-05 14:41:00 -05:00
|
|
|
signal_emitter& m_sig;
|
2016-06-14 23:32:35 -04:00
|
|
|
vector<int> m_actions;
|
2016-12-19 23:05:43 -05:00
|
|
|
unique_ptr<parser> m_parser;
|
2017-04-25 14:26:48 -04:00
|
|
|
|
|
|
|
std::stack<unsigned int> m_fg;
|
|
|
|
std::stack<unsigned int> m_bg;
|
|
|
|
std::stack<unsigned int> m_ul;
|
|
|
|
std::stack<unsigned int> m_ol;
|
2016-06-14 23:32:35 -04:00
|
|
|
};
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|