Files
polybar/include/components/parser.hpp
patrick96 57d364a2fc Reset all tags at the end of a module
The %{PR} tag is introduced for this. It resets all colors as well as
the activation of the underline and overline and font.

This has become necessary because we don't track what raw tags a user
injects into the formatting string and otherwise their raw tags could
bleed through.

This doesn't touch action tags because even before raw action tags
weren't being tracked. Action tags also have the requirement that they
have to be used in pairs, so closing them prematurely could break things
(for example with click actions for the entire bar)
2019-08-06 21:36:20 +02:00

46 lines
1.1 KiB
C++

#pragma once
#include "common.hpp"
#include "errors.hpp"
POLYBAR_NS
class signal_emitter;
enum class attribute;
enum class controltag;
enum class mousebtn;
struct bar_settings;
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);
class parser {
public:
using make_type = unique_ptr<parser>;
static make_type make();
public:
explicit parser(signal_emitter& emitter);
void parse(const bar_settings& bar, string data);
protected:
void codeblock(string&& data, const bar_settings& bar);
size_t text(string&& data);
unsigned int parse_color(const string& s, unsigned int fallback = 0);
int parse_fontindex(const string& s);
attribute parse_attr(const char attr);
mousebtn parse_action_btn(const string& data);
string parse_action_cmd(string&& data);
controltag parse_control(const string& data);
private:
signal_emitter& m_sig;
vector<int> m_actions;
unique_ptr<parser> m_parser;
};
POLYBAR_NS_END