|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
|
|
use nvim_rs::Neovim;
|
|
|
|
use nvim_rs::Neovim;
|
|
|
|
use nvim_rs::compat::tokio::Compat;
|
|
|
|
use nvim_rs::compat::tokio::Compat;
|
|
|
|
use tokio::process::ChildStdin;
|
|
|
|
use tokio::process::ChildStdin;
|
|
|
@ -12,23 +14,23 @@ pub enum UiCommand {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl UiCommand {
|
|
|
|
impl UiCommand {
|
|
|
|
pub async fn execute(&self, nvim: &Neovim<Compat<ChildStdin>>) {
|
|
|
|
pub async fn execute(self, nvim: &Neovim<Compat<ChildStdin>>) {
|
|
|
|
match self {
|
|
|
|
match self {
|
|
|
|
UiCommand::Resize { width, height } =>
|
|
|
|
UiCommand::Resize { width, height } =>
|
|
|
|
nvim.ui_try_resize(*width.max(&10), *height.max(&3)).await
|
|
|
|
nvim.ui_try_resize(width.max(10), height.max(3)).await
|
|
|
|
.expect("Resize failed"),
|
|
|
|
.expect("Resize failed"),
|
|
|
|
UiCommand::Keyboard(input_command) => {
|
|
|
|
UiCommand::Keyboard(input_command) => {
|
|
|
|
nvim.input(&input_command).await
|
|
|
|
nvim.input(&input_command).await
|
|
|
|
.expect("Input failed");
|
|
|
|
.expect("Input failed");
|
|
|
|
},
|
|
|
|
},
|
|
|
|
UiCommand::MouseButton { action, position: (grid_x, grid_y) } =>
|
|
|
|
UiCommand::MouseButton { action, position: (grid_x, grid_y) } =>
|
|
|
|
nvim.input_mouse("left", action, "", 0, *grid_x, *grid_y).await
|
|
|
|
nvim.input_mouse("left", &action, "", 0, grid_x, grid_y).await
|
|
|
|
.expect("Mouse Input Failed"),
|
|
|
|
.expect("Mouse Input Failed"),
|
|
|
|
UiCommand::Scroll { direction, position: (grid_x, grid_y) } =>
|
|
|
|
UiCommand::Scroll { direction, position: (grid_x, grid_y) } =>
|
|
|
|
nvim.input_mouse("wheel", direction, "", 0, *grid_x, *grid_y).await
|
|
|
|
nvim.input_mouse("wheel", &direction, "", 0, grid_x, grid_y).await
|
|
|
|
.expect("Mouse Scroll Failed"),
|
|
|
|
.expect("Mouse Scroll Failed"),
|
|
|
|
UiCommand::Drag(grid_x, grid_y) =>
|
|
|
|
UiCommand::Drag(grid_x, grid_y) =>
|
|
|
|
nvim.input_mouse("left", "drag", "", 0, *grid_x, *grid_y).await
|
|
|
|
nvim.input_mouse("left", "drag", "", 0, grid_x, grid_y).await
|
|
|
|
.expect("Mouse Drag Failed")
|
|
|
|
.expect("Mouse Drag Failed")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|