From 63525ec95628a0720af457f38f6e266a723db9ac Mon Sep 17 00:00:00 2001 From: TheRealLorenz Date: Sat, 25 Mar 2023 17:33:01 +0100 Subject: [PATCH] Rename function name --- include/util/{rewrite_title.hpp => rewrite_string.hpp} | 2 +- meson.build | 2 +- src/modules/hyprland/window.cpp | 4 ++-- src/modules/sway/window.cpp | 4 ++-- src/util/{rewrite_title.cpp => rewrite_string.cpp} | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) rename include/util/{rewrite_title.hpp => rewrite_string.hpp} (55%) rename src/util/{rewrite_title.cpp => rewrite_string.cpp} (75%) diff --git a/include/util/rewrite_title.hpp b/include/util/rewrite_string.hpp similarity index 55% rename from include/util/rewrite_title.hpp rename to include/util/rewrite_string.hpp index c477339e..2ab39ad8 100644 --- a/include/util/rewrite_title.hpp +++ b/include/util/rewrite_string.hpp @@ -4,5 +4,5 @@ #include namespace waybar::util { -std::string rewriteTitle(const std::string&, const Json::Value&); +std::string rewriteString(const std::string&, const Json::Value&); } diff --git a/meson.build b/meson.build index ad6541e5..58e1c672 100644 --- a/meson.build +++ b/meson.build @@ -172,7 +172,7 @@ src_files = files( 'src/group.cpp', 'src/util/ustring_clen.cpp', 'src/util/sanitize_str.cpp', - 'src/util/rewrite_title.cpp' + 'src/util/rewrite_string.cpp' ) if is_linux diff --git a/src/modules/hyprland/window.cpp b/src/modules/hyprland/window.cpp index 47daae9b..40b66201 100644 --- a/src/modules/hyprland/window.cpp +++ b/src/modules/hyprland/window.cpp @@ -8,7 +8,7 @@ #include "modules/hyprland/backend.hpp" #include "util/command.hpp" #include "util/json.hpp" -#include "util/rewrite_title.hpp" +#include "util/rewrite_string.hpp" namespace waybar::modules::hyprland { @@ -41,7 +41,7 @@ auto Window::update() -> void { if (!format_.empty()) { label_.show(); label_.set_markup(fmt::format(fmt::runtime(format_), - waybar::util::rewriteTitle(lastView, config_["rewrite"]))); + waybar::util::rewriteString(lastView, config_["rewrite"]))); } else { label_.hide(); } diff --git a/src/modules/sway/window.cpp b/src/modules/sway/window.cpp index 7d60d292..c3c19f53 100644 --- a/src/modules/sway/window.cpp +++ b/src/modules/sway/window.cpp @@ -12,7 +12,7 @@ #include #include -#include "util/rewrite_title.hpp" +#include "util/rewrite_string.hpp" namespace waybar::modules::sway { @@ -206,7 +206,7 @@ auto Window::update() -> void { label_.set_markup( fmt::format(fmt::runtime(format_), - fmt::arg("title", waybar::util::rewriteTitle(window_, config_["rewrite"])), + fmt::arg("title", waybar::util::rewriteString(window_, config_["rewrite"])), fmt::arg("app_id", app_id_), fmt::arg("shell", shell_))); if (tooltipEnabled()) { label_.set_tooltip_text(window_); diff --git a/src/util/rewrite_title.cpp b/src/util/rewrite_string.cpp similarity index 75% rename from src/util/rewrite_title.cpp rename to src/util/rewrite_string.cpp index fae59bb1..40c71e99 100644 --- a/src/util/rewrite_title.cpp +++ b/src/util/rewrite_string.cpp @@ -1,16 +1,16 @@ -#include "util/rewrite_title.hpp" +#include "util/rewrite_string.hpp" #include #include namespace waybar::util { -std::string rewriteTitle(const std::string& title, const Json::Value& rules) { +std::string rewriteString(const std::string& value, const Json::Value& rules) { if (!rules.isObject()) { - return title; + return value; } - std::string res = title; + std::string res = value; for (auto it = rules.begin(); it != rules.end(); ++it) { if (it.key().isString() && it->isString()) { @@ -18,7 +18,7 @@ std::string rewriteTitle(const std::string& title, const Json::Value& rules) { // malformated regexes will cause an exception. // in this case, log error and try the next rule. const std::regex rule{it.key().asString()}; - if (std::regex_match(title, rule)) { + if (std::regex_match(value, rule)) { res = std::regex_replace(res, rule, it->asString()); } } catch (const std::regex_error& e) {