-
-
Notifications
You must be signed in to change notification settings - Fork 717
Make text module a label #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make text module a label #1342
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1342 +/- ##
=========================================
+ Coverage 5.94% 5.94% +<.01%
=========================================
Files 161 161
Lines 8929 8928 -1
=========================================
Hits 531 531
+ Misses 8398 8397 -1
Continue to review full report at Codecov.
|
I have a couple of questions about this:
|
Well, I ended up implementing
Anything else will be reported as an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. This does make the text module more consistent with the others.
There seems to be some legacy code in the current text module, I have added a few comments about it.
The rest looks good and it shouldn't break any existing configs (unless someone has already defined the format
key in their text module).
src/modules/text.cpp
Outdated
|
||
string text_module::get_format() const { | ||
return "content"; | ||
format->value = string_util::replace_all(format->value, " ", BUILDER_SPACE_TOKEN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have wondered about this before. I think we can remove it because the builder also does this.
m_formatter->add("content", "", {}); | ||
|
||
if (m_formatter->get("content")->value.empty()) { | ||
throw module_error(name() + ".content is empty or undefined"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like very old code. No other module actually does that anymore. I don't think this needs to be adapted and can be removed. What all the other modules do, is to load the format, as you did, and if the label tag occurs in the format string, load the label. For example the script modules does it like this:
modules/script.cpp:
-------------------
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL});
if (m_formatter->has(TAG_LABEL)) {
m_label = load_optional_label(m_conf, name(), "label", "%output%");
}
This avoids throwing unnecessary errors because one should be able to also define a format without including any tags (even if it's not that useful).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your last example
if (m_formatter->has(TAG_LABEL))
I'm unsure about removing the DEFAULT_FORMAT
argument, as in:
if (m_formatter->has(TAG_CONTENT, DEFAULT_FORMAT))
Because the formatter could contain more than one format and the only API I found to check if a tag is inside a format is to request the formatter for that tag in one of its formats. But maybe the dafault format is considered when no other is explicitly passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From looking at the code (base.cpp:143
), if you pass only one argument to module_formatter::has
, then it searches through all the defined formats. So in this case it shouldn't matter, because the text module only defines a single format format
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've already updated and rebased everything according to your comments.
I just realised that this breaks compatibility for all configs that use |
Yeah, I commented a bit about that in the issue, so I was expecting this to
enter the next major version, if any. It's ok, since I posted I discovered
many workarounds like prefix/suffix labels and font tags.
…On Sun, Jul 29, 2018, 10:30 AM Patrick Ziegler ***@***.***> wrote:
I just realised that this breaks compatibility for all configs that use
content-prefix, -suffix, -spacing, or -margin because right now content
is a format and afterwards it would be a label, which doesn't have all
those properties. We will keep this PR open and will merge it for the 4.0.0
release. This may be a while though.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1342 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACtq-Z7HFtufcyRQ5DLoOQ0qJDtUUWjqks5uLbkCgaJpZM4VaLg8>
.
|
Closes polybar#1331 Closes polybar#1342 Closes polybar#2673
Closes polybar#1331 Closes polybar#1342 Fixes polybar#2673
Closes polybar#1331 Closes polybar#1342 Fixes polybar#2673
Fixes #1331
Reviewer Note: This PR introduces breaking changes to the text module. It should be merged in the merge window where breaking changes can be introduced for the next major release (generally directly before the next major release).