Skip to content

Commit 0264e69

Browse files
committed
core: allow ;-separated values in hl format
fixes #67
1 parent 70fb494 commit 0264e69

1 file changed

Lines changed: 42 additions & 34 deletions

File tree

libhyprcursor/meta.cpp

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -71,49 +71,53 @@ static Hyprlang::CParseResult parseDefineSize(const char* C, const char* V) {
7171
Hyprlang::CParseResult result;
7272
const std::string VALUE = V;
7373

74-
if (!VALUE.contains(",")) {
75-
result.setError("Invalid define_size");
76-
return result;
77-
}
78-
79-
auto LHS = removeBeginEndSpacesTabs(VALUE.substr(0, VALUE.find_first_of(",")));
80-
auto RHS = removeBeginEndSpacesTabs(VALUE.substr(VALUE.find_first_of(",") + 1));
81-
auto DELAY = 0;
82-
83-
CMeta::SDefinedSize size;
84-
85-
if (RHS.contains(",")) {
86-
const auto LL = removeBeginEndSpacesTabs(RHS.substr(0, RHS.find(",")));
87-
const auto RR = removeBeginEndSpacesTabs(RHS.substr(RHS.find(",") + 1));
74+
CVarList sizes(VALUE, 0, ';');
8875

89-
try {
90-
size.delayMs = std::stoull(RR);
91-
} catch (std::exception& e) {
92-
result.setError(e.what());
76+
for (const auto& sizeStr : sizes) {
77+
if (!sizeStr.contains(",")) {
78+
result.setError("Invalid define_size");
9379
return result;
9480
}
9581

96-
RHS = LL;
97-
}
82+
auto LHS = removeBeginEndSpacesTabs(sizeStr.substr(0, sizeStr.find_first_of(",")));
83+
auto RHS = removeBeginEndSpacesTabs(sizeStr.substr(sizeStr.find_first_of(",") + 1));
84+
auto DELAY = 0;
9885

99-
if (!std::regex_match(RHS, std::regex("^[A-Za-z0-9_\\-\\.]+$"))) {
100-
result.setError("Invalid cursor file name, characters must be within [A-Za-z0-9_\\-\\.] (if this seems like a mistake, check for invisible characters)");
101-
return result;
102-
}
86+
CMeta::SDefinedSize size;
87+
88+
if (RHS.contains(",")) {
89+
const auto LL = removeBeginEndSpacesTabs(RHS.substr(0, RHS.find(",")));
90+
const auto RR = removeBeginEndSpacesTabs(RHS.substr(RHS.find(",") + 1));
10391

104-
size.file = RHS;
92+
try {
93+
size.delayMs = std::stoull(RR);
94+
} catch (std::exception& e) {
95+
result.setError(e.what());
96+
return result;
97+
}
10598

106-
if (!size.file.ends_with(".svg")) {
107-
try {
108-
size.size = std::stoull(LHS);
109-
} catch (std::exception& e) {
110-
result.setError(e.what());
99+
RHS = LL;
100+
}
101+
102+
if (!std::regex_match(RHS, std::regex("^[A-Za-z0-9_\\-\\.]+$"))) {
103+
result.setError("Invalid cursor file name, characters must be within [A-Za-z0-9_\\-\\.] (if this seems like a mistake, check for invisible characters)");
111104
return result;
112105
}
113-
} else
114-
size.size = 0;
115106

116-
currentMeta->parsedData.definedSizes.push_back(size);
107+
size.file = RHS;
108+
109+
if (!size.file.ends_with(".svg")) {
110+
try {
111+
size.size = std::stoull(LHS);
112+
} catch (std::exception& e) {
113+
result.setError(e.what());
114+
return result;
115+
}
116+
} else
117+
size.size = 0;
118+
119+
currentMeta->parsedData.definedSizes.push_back(size);
120+
}
117121

118122
return result;
119123
}
@@ -122,7 +126,11 @@ static Hyprlang::CParseResult parseOverride(const char* C, const char* V) {
122126
Hyprlang::CParseResult result;
123127
const std::string VALUE = V;
124128

125-
currentMeta->parsedData.overrides.push_back(VALUE);
129+
CVarList overrides(VALUE, 0, ';');
130+
131+
for (const auto& o : overrides) {
132+
currentMeta->parsedData.overrides.push_back(VALUE);
133+
}
126134

127135
return result;
128136
}

0 commit comments

Comments
 (0)