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