refactor: Drop tokenized labels

Handle placeholder tokens inside each label
instead of cloning into a new instance each time
This commit is contained in:
Michael Carlberg 2016-10-19 01:26:17 +02:00
parent 37e367eb79
commit 68f72d69cc
19 changed files with 185 additions and 209 deletions
include/modules

View file

@ -167,9 +167,10 @@ namespace modules {
auto icon = m_icons->get(workspace->name, DEFAULT_WS_ICON);
auto label = m_statelabels.find(flag)->second->clone();
label->reset_tokens();
label->replace_token("%output%", workspace->output);
label->replace_token("%name%", wsname);
label->replace_token("%icon%", icon->m_text);
label->replace_token("%icon%", icon->get());
label->replace_token("%index%", to_string(workspace->num));
m_workspaces.emplace_back(
make_unique<i3_workspace>(workspace->num, flag, std::move(label)));
@ -184,7 +185,7 @@ namespace modules {
// }}}
}
bool build(builder* builder, string tag) {
bool build(builder* builder, string tag) const {
// Output workspace info {{{
if (tag != TAG_LABEL_STATE)