Added the splitratio dispatcher
This commit is contained in:
parent
418e2d96ae
commit
87b8491294
7 changed files with 95 additions and 26 deletions
|
|
@ -73,4 +73,42 @@ std::string removeBeginEndSpacesTabs(std::string str) {
|
|||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
float getPlusMinusKeywordResult(std::string source, float relative) {
|
||||
float result = INT_MAX;
|
||||
|
||||
if (source.find_first_of("+") == 0) {
|
||||
try {
|
||||
if (source.find('.') != std::string::npos)
|
||||
result = relative + std::stof(source.substr(1));
|
||||
else
|
||||
result = relative + std::stoi(source.substr(1));
|
||||
} catch (...) {
|
||||
Debug::log(ERR, "Invalid arg \"%s\" in getPlusMinusKeywordResult!", source.c_str());
|
||||
return INT_MAX;
|
||||
}
|
||||
} else if (source.find_first_of("-") == 0) {
|
||||
try {
|
||||
if (source.find('.') != std::string::npos)
|
||||
result = relative - std::stof(source.substr(1));
|
||||
else
|
||||
result = relative - std::stoi(source.substr(1));
|
||||
} catch (...) {
|
||||
Debug::log(ERR, "Invalid arg \"%s\" in getPlusMinusKeywordResult!", source.c_str());
|
||||
return INT_MAX;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if (source.find('.') != std::string::npos)
|
||||
result = stof(source);
|
||||
else
|
||||
result = stoi(source);
|
||||
} catch (...) {
|
||||
Debug::log(ERR, "Invalid arg \"%s\" in getPlusMinusKeywordResult!", source.c_str());
|
||||
return INT_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -6,4 +6,6 @@ void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString
|
|||
void wlr_signal_emit_safe(struct wl_signal *signal, void *data);
|
||||
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
|
||||
void scaleBox(wlr_box*, float);
|
||||
std::string removeBeginEndSpacesTabs(std::string);
|
||||
std::string removeBeginEndSpacesTabs(std::string);
|
||||
|
||||
float getPlusMinusKeywordResult(std::string in, float relative);
|
||||
Loading…
Add table
Add a link
Reference in a new issue