mirror of
https://github.com/hyprwm/hyprlang.git
synced 2024-11-16 18:25:57 +01:00
api: add some qol stuff needed by hyprland
This commit is contained in:
parent
ab007915f7
commit
f5056f78d5
3 changed files with 28 additions and 2 deletions
|
@ -181,10 +181,15 @@ namespace Hyprlang {
|
||||||
CConfigValue(const STRING value);
|
CConfigValue(const STRING value);
|
||||||
CConfigValue(const VEC2 value);
|
CConfigValue(const VEC2 value);
|
||||||
CConfigValue(CUSTOMTYPE&& value);
|
CConfigValue(CUSTOMTYPE&& value);
|
||||||
CConfigValue(const CConfigValue&) = delete;
|
|
||||||
CConfigValue(CConfigValue&&) = delete;
|
CConfigValue(CConfigValue&&) = delete;
|
||||||
CConfigValue(const CConfigValue&&) = delete;
|
CConfigValue(const CConfigValue&&) = delete;
|
||||||
CConfigValue(CConfigValue&) = delete;
|
CConfigValue(CConfigValue&) = delete;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\since 0.3.0
|
||||||
|
*/
|
||||||
|
CConfigValue(const CConfigValue&);
|
||||||
|
|
||||||
~CConfigValue();
|
~CConfigValue();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -292,10 +297,17 @@ namespace Hyprlang {
|
||||||
void removeSpecialCategory(const char* name);
|
void removeSpecialCategory(const char* name);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\since 0.3.0
|
||||||
|
|
||||||
Add a config value to a special category.
|
Add a config value to a special category.
|
||||||
*/
|
*/
|
||||||
void addSpecialConfigValue(const char* cat, const char* name, const CConfigValue value);
|
void addSpecialConfigValue(const char* cat, const char* name, const CConfigValue value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Remove a config value from a special category.
|
||||||
|
*/
|
||||||
|
void removeSpecialConfigValue(const char* cat, const char* name);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Parse the config. Refresh the values.
|
Parse the config. Refresh the values.
|
||||||
*/
|
*/
|
||||||
|
@ -323,7 +335,7 @@ namespace Hyprlang {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Get a special category's config value ptr. These are only static for static (key-less)
|
Get a special category's config value ptr. These are only static for static (key-less)
|
||||||
categories, unless a new variable is added via addSpecialConfigValue.
|
categories, unless a new variable is added via addSpecialConfigValue or removed via removeSpecialConfigValue.
|
||||||
key can be nullptr for static categories. Cannot be nullptr for id-based categories.
|
key can be nullptr for static categories. Cannot be nullptr for id-based categories.
|
||||||
nullptr on fail.
|
nullptr on fail.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,6 +54,11 @@ CConfigValue::CConfigValue(CConfigCustomValueType&& value) {
|
||||||
m_eType = CONFIGDATATYPE_CUSTOM;
|
m_eType = CONFIGDATATYPE_CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CConfigValue::CConfigValue(const CConfigValue& other) {
|
||||||
|
m_eType = other.m_eType;
|
||||||
|
setFrom(other.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
CConfigValue::CConfigValue() {
|
CConfigValue::CConfigValue() {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,15 @@ void CConfig::addSpecialConfigValue(const char* cat, const char* name, const CCo
|
||||||
reinterpret_cast<CConfigCustomValueType*>(value.m_pData)->dtor});
|
reinterpret_cast<CConfigCustomValueType*>(value.m_pData)->dtor});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CConfig::removeSpecialConfigValue(const char* cat, const char* name) {
|
||||||
|
const auto IT = std::find_if(impl->specialCategoryDescriptors.begin(), impl->specialCategoryDescriptors.end(), [&](const auto& other) { return other->name == cat; });
|
||||||
|
|
||||||
|
if (IT == impl->specialCategoryDescriptors.end())
|
||||||
|
throw "No such category";
|
||||||
|
|
||||||
|
std::erase_if(IT->get()->defaultValues, [name](const auto& other) { return other.first == name; });
|
||||||
|
}
|
||||||
|
|
||||||
void CConfig::addSpecialCategory(const char* name, SSpecialCategoryOptions options) {
|
void CConfig::addSpecialCategory(const char* name, SSpecialCategoryOptions options) {
|
||||||
const auto PDESC = impl->specialCategoryDescriptors.emplace_back(std::make_unique<SSpecialCategoryDescriptor>()).get();
|
const auto PDESC = impl->specialCategoryDescriptors.emplace_back(std::make_unique<SSpecialCategoryDescriptor>()).get();
|
||||||
PDESC->name = name;
|
PDESC->name = name;
|
||||||
|
|
Loading…
Reference in a new issue