2016-11-02 19:22:45 +00:00
|
|
|
#include "modules/text.hpp"
|
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/base.inl"
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-11-02 19:22:45 +00:00
|
|
|
|
|
|
|
namespace modules {
|
2016-11-20 22:04:31 +00:00
|
|
|
template class module<text_module>;
|
|
|
|
|
2016-12-21 07:00:09 +00:00
|
|
|
text_module::text_module(const bar_settings& bar, string name_) : static_module<text_module>(bar, move(name_)) {
|
2016-11-02 19:22:45 +00:00
|
|
|
m_formatter->add("content", "", {});
|
|
|
|
|
2016-11-25 12:55:15 +00:00
|
|
|
if (m_formatter->get("content")->value.empty()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
throw module_error(name() + ".content is empty or undefined");
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
2016-11-02 19:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string text_module::get_format() const {
|
|
|
|
return "content";
|
|
|
|
}
|
|
|
|
|
|
|
|
string text_module::get_output() {
|
2016-12-05 04:32:10 +00:00
|
|
|
// Get the module output early so that
|
|
|
|
// the format prefix/suffix also gets wrapper
|
|
|
|
// with the cmd handlers
|
|
|
|
string output{module::get_output()};
|
|
|
|
|
2016-12-30 22:32:05 +00:00
|
|
|
auto click_left = m_conf.get(name(), "click-left", ""s);
|
|
|
|
auto click_middle = m_conf.get(name(), "click-middle", ""s);
|
|
|
|
auto click_right = m_conf.get(name(), "click-right", ""s);
|
|
|
|
auto scroll_up = m_conf.get(name(), "scroll-up", ""s);
|
|
|
|
auto scroll_down = m_conf.get(name(), "scroll-down", ""s);
|
2016-11-02 19:22:45 +00:00
|
|
|
|
2016-11-25 12:55:15 +00:00
|
|
|
if (!click_left.empty()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
m_builder->cmd(mousebtn::LEFT, click_left);
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
|
|
|
if (!click_middle.empty()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
m_builder->cmd(mousebtn::MIDDLE, click_middle);
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
|
|
|
if (!click_right.empty()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
m_builder->cmd(mousebtn::RIGHT, click_right);
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
|
|
|
if (!scroll_up.empty()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
m_builder->cmd(mousebtn::SCROLL_UP, scroll_up);
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
|
|
|
if (!scroll_down.empty()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
m_builder->cmd(mousebtn::SCROLL_DOWN, scroll_down);
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
2016-11-02 19:22:45 +00:00
|
|
|
|
2016-12-05 04:32:10 +00:00
|
|
|
m_builder->append(output);
|
2016-11-02 19:22:45 +00:00
|
|
|
|
|
|
|
return m_builder->flush();
|
|
|
|
}
|
2019-08-06 17:35:07 +00:00
|
|
|
} // namespace modules
|
2016-11-02 19:22:45 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|