From 7b4bbbc53e0fe23b6ec606e7f17669b3918e5c5f Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Mon, 6 Mar 2017 23:51:45 +0000 Subject: [PATCH] runtime: Add GuiClose function --- src/gui/runtime/doc/nvim_gui_shim.txt | 5 +++++ src/gui/runtime/plugin/nvim_gui_shim.vim | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/runtime/doc/nvim_gui_shim.txt b/src/gui/runtime/doc/nvim_gui_shim.txt index daac2fd29..1d99baed7 100644 --- a/src/gui/runtime/doc/nvim_gui_shim.txt +++ b/src/gui/runtime/doc/nvim_gui_shim.txt @@ -121,6 +121,11 @@ GuiMousehide(enabled) enables mouse hiding while typing. If enabled is 1, as soon as the user types the mouse cursor is concealed. When the user moves the mouse, the cursor becomes visible. Replaces |'mousehide'|. + *GuiClose()* +GuiClose() notifies the GUI that it should close. The GUI may or may not +respect this request. The shim setups an autocommand to call this function +when the |'VimLeave'| event occurs. + ============================================================================== 4. Internals diff --git a/src/gui/runtime/plugin/nvim_gui_shim.vim b/src/gui/runtime/plugin/nvim_gui_shim.vim index 68c855432..2fa09455c 100644 --- a/src/gui/runtime/plugin/nvim_gui_shim.vim +++ b/src/gui/runtime/plugin/nvim_gui_shim.vim @@ -4,8 +4,13 @@ if !has('nvim') || exists('g:GuiLoaded') endif let g:GuiLoaded = 1 +" Close the GUI +function! GuiClose() abort + call rpcnotify(0, 'Gui', 'Close') +endfunction + " Notify the GUI when exiting Neovim -autocmd VimLeave * call rpcnotify(0, 'Gui', 'Close')" +autocmd VimLeave * call GuiClose() " A replacement for foreground() function! GuiForeground() abort