aboutsummaryrefslogtreecommitdiff
path: root/src/layout.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-29 18:09:25 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-29 18:09:25 +0300
commit1a4e94e57e181379e2ed42d63a49fbc56ed1dba4 (patch)
tree0319544374f1149a405259070b90df9d62854789 /src/layout.rs
parenta937f7e85bbf8780c6030c57f48dab2168bca932 (diff)
refactor: route tui mutations through runtime authority
Diffstat (limited to 'src/layout.rs')
-rw-r--r--src/layout.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/layout.rs b/src/layout.rs
index cd611d10..8a16da9c 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -206,8 +206,8 @@ impl TileLayout {
}
/// Set the ratio of a split node at the given path.
- pub fn set_ratio_at(&mut self, path: &[bool], ratio: f32) {
- set_ratio_at(&mut self.root, path, ratio.clamp(0.1, 0.9));
+ pub fn set_ratio_at(&mut self, path: &[bool], ratio: f32) -> bool {
+ set_ratio_at(&mut self.root, path, ratio.clamp(0.1, 0.9))
}
/// Adjust the nearest split in the given direction for the focused pane.
@@ -577,7 +577,7 @@ fn remove_pane(node: Node, target: PaneId) -> Option<Node> {
}
}
-fn set_ratio_at(node: &mut Node, path: &[bool], new_ratio: f32) {
+fn set_ratio_at(node: &mut Node, path: &[bool], new_ratio: f32) -> bool {
if let Node::Split {
ratio,
first,
@@ -587,11 +587,14 @@ fn set_ratio_at(node: &mut Node, path: &[bool], new_ratio: f32) {
{
if path.is_empty() {
*ratio = new_ratio;
+ true
} else if path[0] {
- set_ratio_at(second, &path[1..], new_ratio);
+ set_ratio_at(second, &path[1..], new_ratio)
} else {
- set_ratio_at(first, &path[1..], new_ratio);
+ set_ratio_at(first, &path[1..], new_ratio)
}
+ } else {
+ false
}
}