mirror of https://github.com/helix-editor/helix
Editor: remove duplication for view focus/swap commands
parent
dd2b9e55a2
commit
7b8e4ac95a
|
@ -33,6 +33,7 @@ use helix_view::{
|
||||||
info::Info,
|
info::Info,
|
||||||
input::KeyEvent,
|
input::KeyEvent,
|
||||||
keyboard::KeyCode,
|
keyboard::KeyCode,
|
||||||
|
tree,
|
||||||
view::View,
|
view::View,
|
||||||
Document, DocumentId, Editor, ViewId,
|
Document, DocumentId, Editor, ViewId,
|
||||||
};
|
};
|
||||||
|
@ -4080,35 +4081,35 @@ fn rotate_view(cx: &mut Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn jump_view_right(cx: &mut Context) {
|
fn jump_view_right(cx: &mut Context) {
|
||||||
cx.editor.focus_right()
|
cx.editor.focus_direction(tree::Direction::Right)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn jump_view_left(cx: &mut Context) {
|
fn jump_view_left(cx: &mut Context) {
|
||||||
cx.editor.focus_left()
|
cx.editor.focus_direction(tree::Direction::Left)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn jump_view_up(cx: &mut Context) {
|
fn jump_view_up(cx: &mut Context) {
|
||||||
cx.editor.focus_up()
|
cx.editor.focus_direction(tree::Direction::Up)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn jump_view_down(cx: &mut Context) {
|
fn jump_view_down(cx: &mut Context) {
|
||||||
cx.editor.focus_down()
|
cx.editor.focus_direction(tree::Direction::Down)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn swap_view_right(cx: &mut Context) {
|
fn swap_view_right(cx: &mut Context) {
|
||||||
cx.editor.swap_right()
|
cx.editor.swap_split_in_direction(tree::Direction::Right)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn swap_view_left(cx: &mut Context) {
|
fn swap_view_left(cx: &mut Context) {
|
||||||
cx.editor.swap_left()
|
cx.editor.swap_split_in_direction(tree::Direction::Left)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn swap_view_up(cx: &mut Context) {
|
fn swap_view_up(cx: &mut Context) {
|
||||||
cx.editor.swap_up()
|
cx.editor.swap_split_in_direction(tree::Direction::Up)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn swap_view_down(cx: &mut Context) {
|
fn swap_view_down(cx: &mut Context) {
|
||||||
cx.editor.swap_down()
|
cx.editor.swap_split_in_direction(tree::Direction::Down)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transpose_view(cx: &mut Context) {
|
fn transpose_view(cx: &mut Context) {
|
||||||
|
|
|
@ -1095,36 +1095,12 @@ impl Editor {
|
||||||
self.tree.focus_next();
|
self.tree.focus_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus_right(&mut self) {
|
pub fn focus_direction(&mut self, direction: tree::Direction) {
|
||||||
self.tree.focus_direction(tree::Direction::Right);
|
self.tree.focus_direction(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus_left(&mut self) {
|
pub fn swap_split_in_direction(&mut self, direction: tree::Direction) {
|
||||||
self.tree.focus_direction(tree::Direction::Left);
|
self.tree.swap_split_in_direction(direction);
|
||||||
}
|
|
||||||
|
|
||||||
pub fn focus_up(&mut self) {
|
|
||||||
self.tree.focus_direction(tree::Direction::Up);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn focus_down(&mut self) {
|
|
||||||
self.tree.focus_direction(tree::Direction::Down);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn swap_right(&mut self) {
|
|
||||||
self.tree.swap_split_in_direction(tree::Direction::Right);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn swap_left(&mut self) {
|
|
||||||
self.tree.swap_split_in_direction(tree::Direction::Left);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn swap_up(&mut self) {
|
|
||||||
self.tree.swap_split_in_direction(tree::Direction::Up);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn swap_down(&mut self) {
|
|
||||||
self.tree.swap_split_in_direction(tree::Direction::Down);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transpose_view(&mut self) {
|
pub fn transpose_view(&mut self) {
|
||||||
|
|
Loading…
Reference in New Issue