fix(controller): Module margin require surrounding text

This commit is contained in:
Michael Carlberg 2016-12-14 19:03:59 +01:00
parent cdec06ee5a
commit e11798253a
2 changed files with 10 additions and 13 deletions

View File

@ -135,7 +135,7 @@ void config::parse_file() {
void config::copy_inherited() { void config::copy_inherited() {
for (auto&& section : m_sections) { for (auto&& section : m_sections) {
for (auto&& param : section.second) { for (auto&& param : section.second) {
if (param.first.compare(KEY_INHERIT) == 0) { if (param.first.compare(0, strlen(KEY_INHERIT), KEY_INHERIT) == 0) {
// Get name of base section // Get name of base section
auto inherit = param.second; auto inherit = param.second;
if ((inherit = dereference<string>(section.first, param.first, inherit, inherit)).empty()) { if ((inherit = dereference<string>(section.first, param.first, inherit, inherit)).empty()) {
@ -154,10 +154,7 @@ void config::copy_inherited() {
// that hasn't been defined for the sub-section // that hasn't been defined for the sub-section
for (auto&& base_param : base_section->second) { for (auto&& base_param : base_section->second) {
valuemap_t::const_iterator iter; valuemap_t::const_iterator iter;
section.second.insert(make_pair(base_param.first, base_param.second));
if ((iter = section.second.find(base_param.first)) == section.second.end()) {
section.second.emplace_hint(iter, base_param.first, base_param.second);
}
} }
} }
} }

View File

@ -270,8 +270,8 @@ bool controller::on(const sig_ev::process_update& evt) {
string separator{bar.separator}; string separator{bar.separator};
string padding_left(bar.padding.left, ' '); string padding_left(bar.padding.left, ' ');
string padding_right(bar.padding.right, ' '); string padding_right(bar.padding.right, ' ');
auto margin_left = bar.module_margin.left; string margin_left(bar.module_margin.left, ' ');
auto margin_right = bar.module_margin.right; string margin_right(bar.module_margin.right, ' ');
for (const auto& block : m_eventloop->modules()) { for (const auto& block : m_eventloop->modules()) {
string block_contents; string block_contents;
@ -288,25 +288,25 @@ bool controller::on(const sig_ev::process_update& evt) {
} }
for (const auto& module : block.second) { for (const auto& module : block.second) {
auto module_contents = module->contents(); string module_contents{module->contents()};
if (module_contents.empty()) { if (module_contents.empty()) {
continue; continue;
} }
if (!block_contents.empty() && !(is_right && module == block.second.back())) { if (!block_contents.empty() && !margin_right.empty()) {
block_contents += string(margin_right, ' '); block_contents += margin_right;
} }
if (!block_contents.empty() && !separator.empty()) { if (!block_contents.empty() && !separator.empty()) {
block_contents += separator; block_contents += separator;
} }
if (!(is_left && module == block.second.front())) { if (!block_contents.empty() && !margin_left.empty() && !(is_left && module == block.second.front())) {
block_contents += string(margin_left, ' '); block_contents += margin_left;
} }
block_contents += module->contents(); block_contents += module_contents;
} }
if (block_contents.empty()) { if (block_contents.empty()) {