feat: Add support for prefix and suffix to formats
This commit is contained in:
parent
fbca73a83b
commit
ffbedf4217
@ -59,6 +59,8 @@ namespace modules {
|
||||
struct module_format {
|
||||
string value;
|
||||
vector<string> tags;
|
||||
label_t prefix;
|
||||
label_t suffix;
|
||||
string fg;
|
||||
string bg;
|
||||
string ul;
|
||||
|
@ -159,7 +159,7 @@ namespace modules {
|
||||
int i = 0;
|
||||
bool tag_built = true;
|
||||
|
||||
for (auto tag : string_util::split(format->value, ' ')) {
|
||||
for (auto&& tag : string_util::split(format->value, ' ')) {
|
||||
bool is_blankspace = tag.empty();
|
||||
|
||||
if (tag[0] == '<' && tag[tag.length() - 1] == '>') {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "components/builder.hpp"
|
||||
#include "modules/meta/base.hpp"
|
||||
#include "drawtypes/label.hpp"
|
||||
|
||||
POLYBAR_NS
|
||||
|
||||
@ -31,7 +32,11 @@ namespace modules {
|
||||
builder->space(padding);
|
||||
}
|
||||
|
||||
builder->append(move(output));
|
||||
if (!output.empty()) {
|
||||
builder->node(prefix);
|
||||
builder->append(move(output));
|
||||
builder->node(suffix);
|
||||
}
|
||||
|
||||
if (padding > 0) {
|
||||
builder->space(padding);
|
||||
@ -72,6 +77,18 @@ namespace modules {
|
||||
format->offset = m_conf.get<int>(m_modname, name + "-offset", 0);
|
||||
format->tags.swap(tags);
|
||||
|
||||
try {
|
||||
format->prefix = load_label(m_conf, m_modname, name + "-prefix");
|
||||
} catch (const key_error& err) {
|
||||
// prefix not defined
|
||||
}
|
||||
|
||||
try {
|
||||
format->suffix = load_label(m_conf, m_modname, name + "-suffix");
|
||||
} catch (const key_error& err) {
|
||||
// suffix not defined
|
||||
}
|
||||
|
||||
for (auto&& tag : string_util::split(format->value, ' ')) {
|
||||
if (tag[0] != '<' || tag[tag.length() - 1] != '>') {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user