2016-06-15 03:32:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
2016-11-25 12:55:15 +00:00
|
|
|
#include "errors.hpp"
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-12-05 19:41:00 +00:00
|
|
|
class signal_emitter;
|
2016-11-24 18:24:47 +00:00
|
|
|
class logger;
|
2016-11-21 14:07:00 +00:00
|
|
|
struct bar_settings;
|
|
|
|
enum class attribute : uint8_t;
|
|
|
|
enum class mousebtn : uint8_t;
|
|
|
|
|
2016-11-25 03:10:26 +00: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 03:32:35 +00:00
|
|
|
|
|
|
|
class parser {
|
|
|
|
public:
|
2016-12-05 19:41:00 +00:00
|
|
|
explicit parser(signal_emitter& emitter, const logger& logger, const bar_settings& bar);
|
2016-11-02 19:22:45 +00:00
|
|
|
void operator()(string data);
|
|
|
|
void codeblock(string data);
|
|
|
|
size_t text(string data);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
protected:
|
2016-11-21 14:07:00 +00:00
|
|
|
uint32_t parse_color(string s, uint32_t fallback = 0);
|
|
|
|
int8_t parse_fontindex(string s);
|
2016-11-25 12:55:15 +00:00
|
|
|
attribute parse_attr(const char attr);
|
2016-11-02 19:22:45 +00:00
|
|
|
mousebtn parse_action_btn(string data);
|
2016-11-25 12:55:15 +00:00
|
|
|
string parse_action_cmd(const string& data);
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-05 19:41:00 +00:00
|
|
|
signal_emitter& m_sig;
|
2016-11-24 18:24:47 +00:00
|
|
|
const logger& m_log;
|
2016-06-15 03:32:35 +00:00
|
|
|
const bar_settings& m_bar;
|
|
|
|
vector<int> m_actions;
|
|
|
|
};
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|