New Tag Parser ()

* refactor(color): Use enum class for color type

* Add testcases for tag parser

* Make tag parser a pull-style parser

Being able to parse single elements at a time gives us more fine-grained
error messages, we can also parse as much as possible and only stop
after an exception.

* fix(color): Parser did not check for invalid chars

* tag parser: First full implementation

* tag parser: Fix remaining failing tests

* tag parser: Replace old parser

* tag parser: Treat alignment as formatting tag

Makes the structure less complex and the alignment tags really are
formatting tags, they are structurally no different from the %{R} tag.

* tag parser: Cleanup type definitions

All type definitions for tags now live in tags/types.hpp, the parser.hpp
only contains the definitions necessary for actually calling the parser,
this shouldn't be included in many places (only places that actually do
parsing). But many places need the definitions for the tags themselves.

* Rename components/parser to tags/dispatch

* tag parser: Cleanup

* Add changelog
This commit is contained in:
Patrick Ziegler 2020-12-17 20:37:28 +01:00 committed by GitHub
parent c07cc09a5f
commit fd556525a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 1588 additions and 505 deletions
include/components

View file

@ -4,6 +4,7 @@
#include "common.hpp"
#include "components/types.hpp"
#include "tags/types.hpp"
POLYBAR_NS
using std::map;
@ -47,7 +48,7 @@ class builder {
void overline_close();
void underline(const rgba& color = rgba{});
void underline_close();
void control(controltag tag);
void control(tags::controltag tag);
void action(mousebtn index, string action);
void action(mousebtn btn, const modules::module_interface& module, string action, string data);
void action(mousebtn index, string action, const label_t& label);
@ -55,19 +56,18 @@ class builder {
void action_close();
protected:
void tag_open(syntaxtag tag, const string& value);
void tag_open(attribute attr);
void tag_close(syntaxtag tag);
void tag_close(attribute attr);
void tag_open(tags::syntaxtag tag, const string& value);
void tag_open(tags::attribute attr);
void tag_close(tags::syntaxtag tag);
void tag_close(tags::attribute attr);
private:
const bar_settings m_bar;
string m_output;
map<syntaxtag, int> m_tags{};
map<syntaxtag, string> m_colors{};
map<attribute, bool> m_attrs{};
map<tags::syntaxtag, int> m_tags{};
map<tags::syntaxtag, string> m_colors{};
map<tags::attribute, bool> m_attrs{};
int m_fontindex{0};
};