summaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorRoland Kovacs2022-05-20 01:25:04 +0000
committerGitHub2022-05-20 01:25:04 +0000
commit8958bf0a926a6e6afc63f0c59f3fa6761f5da709 (patch)
treeb48042f1f03cefb99bdf14d970ff937a60bc211e /helix-view/src
parent62fd1f699988bdf7bba4a9ada511b5303b01d328 (diff)
Implement view transpose (#2461)
Change the layout of existing split view from horizontal to vertical and vica-versa. It only effects the focused view and its siblings, i.e. not recursive. Command is mapped to 't' or 'C-t' under the Window menus.
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/editor.rs4
-rw-r--r--helix-view/src/tree.rs12
2 files changed, 16 insertions, 0 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index f4a48ba6..1ad21059 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -885,6 +885,10 @@ impl Editor {
self.tree.focus_direction(tree::Direction::Down);
}
+ pub fn transpose_view(&mut self) {
+ self.tree.transpose();
+ }
+
pub fn should_close(&self) -> bool {
self.tree.is_empty()
}
diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs
index b068f4c7..522a79d7 100644
--- a/helix-view/src/tree.rs
+++ b/helix-view/src/tree.rs
@@ -526,6 +526,18 @@ impl Tree {
}
}
+ pub fn transpose(&mut self) {
+ let focus = self.focus;
+ let parent = self.nodes[focus].parent;
+ if let Content::Container(container) = &mut self.nodes[parent].content {
+ container.layout = match container.layout {
+ Layout::Vertical => Layout::Horizontal,
+ Layout::Horizontal => Layout::Vertical,
+ };
+ self.recalculate();
+ }
+ }
+
pub fn area(&self) -> Rect {
self.area
}