From fc33cae70cab2c5acaeac77e8a5c2594c7292bbd Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 22:33:43 +0200 Subject: [PATCH] change bind flag parsing --- src/config/ConfigManager.cpp | 19 +++++++++++++++---- src/config/ConfigManager.hpp | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 9d474fcc..fa9a1334 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -506,9 +506,21 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri configSetValueSafe("animations:" + ANIMNAME + "_style", curitem); } -void CConfigManager::handleBind(const std::string& command, const std::string& value, bool locked) { +void CConfigManager::handleBind(const std::string& command, const std::string& value) { // example: - // bind=SUPER,G,exec,dmenu_run + // bind[fl]=SUPER,G,exec,dmenu_run + + // flags + bool locked = false; + const auto ARGS = command.substr(4); + for (auto& arg : ARGS) { + if (arg == 'l') { + locked = true; + } else { + parseError = "bind: invalid flag"; + return; + } + } auto valueCopy = value; @@ -710,8 +722,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: } } else if (COMMAND == "monitor") handleMonitor(COMMAND, VALUE); - else if (COMMAND == "bind") handleBind(COMMAND, VALUE); - else if (COMMAND == "bindl") handleBind(COMMAND, VALUE, true); + else if (COMMAND.find("bind") == 0) handleBind(COMMAND, VALUE); else if (COMMAND == "unbind") handleUnbind(COMMAND, VALUE); else if (COMMAND == "workspace") handleDefaultWorkspace(COMMAND, VALUE); else if (COMMAND == "windowrule") handleWindowRule(COMMAND, VALUE); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 1d281c40..7f51f7e7 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -121,7 +121,7 @@ private: void handleDeviceConfig(const std::string&, const std::string&); void handleRawExec(const std::string&, const std::string&); void handleMonitor(const std::string&, const std::string&); - void handleBind(const std::string&, const std::string&, bool locked = false); + void handleBind(const std::string&, const std::string&); void handleUnbind(const std::string&, const std::string&); void handleWindowRule(const std::string&, const std::string&); void handleDefaultWorkspace(const std::string&, const std::string&);