fix(formatting): Make formats parse specs as-is

This removes the spacing tinkering when parsing format specs.
The following example uses the old behavoir:

    format-test = <label-foo>  <label-bar>
    format-breaks = <label-foo><label-bar>/<bar-test>

`format-test` would replace all occurences of ' ' with the
a space string with defined `spacing` as its width. `format-breaks` would
not validate as the tags where split with ' ' as delimiter.

All that nonsense has been removed and each tag is extracted as is.
The `spacing` parameter can still be used to apply N extra whitespaces
between the tags, but it is now 0 by default.
This commit is contained in:
Michael Carlberg
2017-01-11 01:42:55 +01:00
parent f4e8051e9e
commit 30f516dd7d
9 changed files with 90 additions and 69 deletions

View File

@ -12,7 +12,9 @@ namespace modules {
template class module<menu_module>;
menu_module::menu_module(const bar_settings& bar, string name_) : static_module<menu_module>(bar, move(name_)) {
string default_format{TAG_LABEL_TOGGLE + string{" "} + TAG_MENU};
string default_format;
default_format += TAG_LABEL_TOGGLE;
default_format += TAG_MENU;
m_formatter->add(DEFAULT_FORMAT, default_format, {TAG_LABEL_TOGGLE, TAG_MENU});
@ -63,12 +65,14 @@ namespace modules {
builder->node(m_labelclose);
builder->cmd_close();
} else if (tag == TAG_MENU && m_level > -1) {
auto spacing = m_formatter->get(get_format())->spacing;
for (auto&& item : m_levels[m_level]->items) {
if (item != m_levels[m_level]->items.front()) {
builder->space();
}
if (*m_labelseparator) {
builder->node(m_labelseparator, true);
if (item != m_levels[m_level]->items[0]) {
builder->space(spacing);
}
builder->node(m_labelseparator);
builder->space(spacing);
}
builder->cmd(mousebtn::LEFT, item->exec);
builder->node(item->label);