From badec8afdd2484b839d460bd95b31f63d027e731 Mon Sep 17 00:00:00 2001 From: equalsraf Date: Sun, 4 Aug 2024 10:45:04 +0100 Subject: [PATCH] Remove use of rpcnotify(0 from gui plugino ref 1112 --- src/gui/runtime/plugin/nvim_gui_shim.vim | 60 +++++++++++++----------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/gui/runtime/plugin/nvim_gui_shim.vim b/src/gui/runtime/plugin/nvim_gui_shim.vim index b047cdc6d..6c89ea29c 100644 --- a/src/gui/runtime/plugin/nvim_gui_shim.vim +++ b/src/gui/runtime/plugin/nvim_gui_shim.vim @@ -16,14 +16,20 @@ function! s:get_last_ui_chan() return uis[-1].chan endfunction +function! s:notify_all_uis(...) + for ui in nvim_list_uis() + call call(rpcnotify, ui.chan, a:000) + endfor +endfunction + " Close the GUI function! GuiClose() abort - call rpcnotify(0, 'Gui', 'Close', v:exiting) + call s:notify_all_uis('Gui', 'Close', v:exiting) endfunction " Open new window function! GuiNewWindow(args) abort - call rpcnotify(0, 'Gui', 'NewWindow', a:args) + call s:notify_all_uis('Gui', 'NewWindow', a:args) endfunction " Notify the GUI when exiting Neovim @@ -34,38 +40,38 @@ augroup END " A replacement for foreground() function! GuiForeground() abort - call rpcnotify(0, 'Gui', 'Foreground') + call s:notify_all_uis('Gui', 'Foreground') endfunction " Set maximized state for GUI window (1 is enabled, 0 disabled) function! GuiWindowMaximized(enabled) abort - call rpcnotify(0, 'Gui', 'WindowMaximized', a:enabled) + call s:notify_all_uis('Gui', 'WindowMaximized', a:enabled) endfunction " Set fullscreen state for GUI window (1 is enabled, 0 disabled) function! GuiWindowFullScreen(enabled) abort - call rpcnotify(0, 'Gui', 'WindowFullScreen', a:enabled) + call s:notify_all_uis('Gui', 'WindowFullScreen', a:enabled) endfunction " Set frameless state for GUI window (1 is enabled, 0 disabled) function! GuiWindowFrameless(enabled) abort - call rpcnotify(0, 'Gui', 'WindowFrameless', a:enabled) + call s:notify_all_uis('Gui', 'WindowFrameless', a:enabled) endfunction " Set GUI font function! GuiFont(fname, ...) abort let force = get(a:000, 0, 0) - call rpcnotify(0, 'Gui', 'Font', a:fname, force) + call s:notify_all_uis('Gui', 'Font', a:fname, force) endfunction " Set additional linespace function! GuiLinespace(height) abort - call rpcnotify(0, 'Gui', 'Linespace', a:height) + call s:notify_all_uis('Gui', 'Linespace', a:height) endfunction " Configure mouse hide behaviour (1 is enabled, 0 disabled) function! GuiMousehide(enabled) abort - call rpcnotify(0, 'Gui', 'Mousehide', a:enabled) + call s:notify_all_uis('Gui', 'Mousehide', a:enabled) endfunction " The GuiFont command. For compatibility there is also Guifont @@ -97,17 +103,17 @@ endfunction command! -nargs=? GuiLinespace call s:GuiLinespaceCommand("") function! s:GuiTabline(enable) abort - call rpcnotify(0, 'Gui', 'Option', 'Tabline', a:enable) + call s:notify_all_uis('Gui', 'Option', 'Tabline', a:enable) endfunction command! -nargs=1 GuiTabline call s:GuiTabline() function! s:GuiTablineBuffers(enable) abort - call rpcnotify(0, 'Gui', 'Option', 'TablineBuffers', a:enable) + call s:notify_all_uis('Gui', 'Option', 'TablineBuffers', a:enable) endfunction command! -nargs=1 GuiTablineBuffers call s:GuiTablineBuffers() function! s:GuiPopupmenu(enable) abort - call rpcnotify(0, 'Gui', 'Option', 'Popupmenu', a:enable) + call s:notify_all_uis('Gui', 'Option', 'Popupmenu', a:enable) endfunction command! -nargs=1 GuiPopupmenu call s:GuiPopupmenu() @@ -200,14 +206,14 @@ endfunction " Directory autocommands for Treeview augroup guiDirEvents autocmd! - autocmd DirChanged * call rpcnotify(0, 'Dir', getcwd()) - autocmd WinEnter * call rpcnotify(0, 'Dir', getcwd()) - autocmd VimEnter * call rpcnotify(0, 'Dir', getcwd()) + autocmd DirChanged * call s:notify_all_uis('Dir', getcwd()) + autocmd WinEnter * call s:notify_all_uis('Dir', getcwd()) + autocmd VimEnter * call s:notify_all_uis('Dir', getcwd()) augroup END " Notifies the TreeView widget of a Show or Hide event function! s:TreeViewShowHide(show) - call rpcnotify(0, 'Gui', 'TreeView', 'ShowHide', a:show) + call s:notify_all_uis('Gui', 'TreeView', 'ShowHide', a:show) endfunction command! GuiTreeviewShow call TreeViewShowHide(1) @@ -219,7 +225,7 @@ anoremenu