mirror of
https://github.com/hyprwm/hyprlang.git
synced 2024-11-16 18:25:57 +01:00
config: make special own its subcategories if not set
This commit is contained in:
parent
380453d389
commit
ab007915f7
1 changed files with 7 additions and 2 deletions
|
@ -108,6 +108,11 @@ void CConfig::addSpecialCategory(const char* name, SSpecialCategoryOptions optio
|
||||||
if (!PCAT->key.empty())
|
if (!PCAT->key.empty())
|
||||||
addSpecialConfigValue(name, options.key, CConfigValue("0"));
|
addSpecialConfigValue(name, options.key, CConfigValue("0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort longest to shortest
|
||||||
|
std::sort(impl->specialCategories.begin(), impl->specialCategories.end(), [](const auto& a, const auto& b) -> int { return a->name.length() > b->name.length(); });
|
||||||
|
std::sort(impl->specialCategoryDescriptors.begin(), impl->specialCategoryDescriptors.end(),
|
||||||
|
[](const auto& a, const auto& b) -> int { return a->name.length() > b->name.length(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfig::removeSpecialCategory(const char* name) {
|
void CConfig::removeSpecialCategory(const char* name) {
|
||||||
|
@ -241,7 +246,7 @@ CParseResult CConfig::configSetValueSafe(const std::string& command, const std::
|
||||||
// it might be in a special category
|
// it might be in a special category
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto& sc : impl->specialCategories) {
|
for (auto& sc : impl->specialCategories) {
|
||||||
if (!valueName.starts_with(sc->name) || valueName.substr(sc->name.length() + 1).contains(":"))
|
if (!valueName.starts_with(sc->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!sc->isStatic && std::string{std::any_cast<const char*>(sc->values[sc->key].getValue())} != impl->currentSpecialKey)
|
if (!sc->isStatic && std::string{std::any_cast<const char*>(sc->values[sc->key].getValue())} != impl->currentSpecialKey)
|
||||||
|
@ -260,7 +265,7 @@ CParseResult CConfig::configSetValueSafe(const std::string& command, const std::
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// could be a dynamic category that doesnt exist yet
|
// could be a dynamic category that doesnt exist yet
|
||||||
for (auto& sc : impl->specialCategoryDescriptors) {
|
for (auto& sc : impl->specialCategoryDescriptors) {
|
||||||
if (sc->key.empty() || !valueName.starts_with(sc->name) || valueName.substr(sc->name.length() + 1).contains(":"))
|
if (sc->key.empty() || !valueName.starts_with(sc->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// bingo
|
// bingo
|
||||||
|
|
Loading…
Reference in a new issue