algo/dwindle: add back splitratio (#13498)
This commit is contained in:
parent
5cb1281035
commit
9f98f7440b
3 changed files with 87 additions and 0 deletions
|
|
@ -714,6 +714,25 @@ std::expected<void, std::string> CDwindleAlgorithm::layoutMsg(const std::string_
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (ARGS[0] == "splitratio") {
|
||||
auto ratio = ARGS[1];
|
||||
bool exact = ARGS[2].starts_with("exact");
|
||||
|
||||
if (ratio.empty())
|
||||
return std::unexpected("splitratio requires an arg");
|
||||
|
||||
auto delta = getPlusMinusKeywordResult(std::string{ratio}, 0.F);
|
||||
|
||||
if (!CURRENT_NODE || !CURRENT_NODE->pParent)
|
||||
return std::unexpected("cannot alter split ratio on no / single node");
|
||||
|
||||
if (!delta)
|
||||
return std::unexpected(std::format("failed to parse \"{}\" as a delta", ratio));
|
||||
|
||||
const float newRatio = exact ? *delta : CURRENT_NODE->pParent->splitRatio + *delta;
|
||||
CURRENT_NODE->pParent->splitRatio = std::clamp(newRatio, 0.1F, 1.9F);
|
||||
|
||||
CURRENT_NODE->pParent->recalcSizePosRecursive();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue