aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/desktop/Rule.cpp
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-12-21 23:07:23 +0000
committerVaxry <[email protected]>2024-12-21 23:07:34 +0000
commit31422ae25dee33dd000798b64a80bd7fd08d2ece (patch)
tree43c71511f09159b716435bf6abb4deaaadd0b49a /src/desktop/Rule.cpp
parent57921d7dbd1b87a9474f609cb9cd30e6174027cd (diff)
downloadHyprland-31422ae25dee33dd000798b64a80bd7fd08d2ece.tar.gz
Hyprland-31422ae25dee33dd000798b64a80bd7fd08d2ece.zip
windowrules: add negative: prefix for negating a regex
fixes #8799
Diffstat (limited to 'src/desktop/Rule.cpp')
-rw-r--r--src/desktop/Rule.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/desktop/Rule.cpp b/src/desktop/Rule.cpp
new file mode 100644
index 00000000..dd1848d4
--- /dev/null
+++ b/src/desktop/Rule.cpp
@@ -0,0 +1,16 @@
+#include "Rule.hpp"
+#include <re2/re2.h>
+
+CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) {
+ const bool NEGATIVE = regex_.starts_with("negative:");
+
+ negative = NEGATIVE;
+ regex = std::make_unique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
+}
+
+bool CRuleRegexContainer::passes(const std::string& str) const {
+ if (!regex)
+ return false;
+
+ return RE2::FullMatch(str, *regex) != negative;
+} \ No newline at end of file