From b80bad8e6d0361458e215aeccf2d70dbe006c050 Mon Sep 17 00:00:00 2001 From: exoticus <56480961+exoticus@users.noreply.github.com> Date: Tue, 21 Apr 2020 00:00:07 +0200 Subject: [PATCH] can now drop files to open them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in order to open a file if there’s changes in current buffer, a user should have `set hidden` in his/her vimrc --- src/bridge/ui_commands.rs | 4 ++++ src/window.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/bridge/ui_commands.rs b/src/bridge/ui_commands.rs index 70ef61c..8dca19a 100644 --- a/src/bridge/ui_commands.rs +++ b/src/bridge/ui_commands.rs @@ -21,6 +21,7 @@ pub enum UiCommand { position: (u32, u32), }, Drag(u32, u32), + FileDrop(String), FocusLost, FocusGained, Quit, @@ -74,6 +75,9 @@ impl UiCommand { .expect("Focus Gained Failed"), UiCommand::Quit => { nvim.command("qa!").await.ok(); // Ignoring result as it won't succeed since the app closed. + }, + UiCommand::FileDrop(path) => { + nvim.command(format!("e {}", path).as_str()).await.ok(); } } } diff --git a/src/window.rs b/src/window.rs index 742c1fd..cc360d1 100644 --- a/src/window.rs +++ b/src/window.rs @@ -454,6 +454,9 @@ pub fn ui_loop() { for event in event_pump.poll_iter() { match event { Event::Quit { .. } => window.handle_quit(), + Event::DropFile { filename, ..} => { + BRIDGE.queue_command(UiCommand::FileDrop(filename)); + } Event::KeyDown { keycode: received_keycode, ..