rename: UIAttach/UIDetach => UIEnter/UILeave

"enter"/"leave" is more conventional for Vim events, and
"attach"/"detach" distinction does not gain much.
This commit is contained in:
Justin M. Keyes 2019-09-12 16:08:22 -07:00
parent 44d45e29ea
commit 589f612adf
8 changed files with 26 additions and 26 deletions

View File

@ -280,8 +280,8 @@ Name triggered by ~
Startup and exit
|VimEnter| after doing all the startup stuff
|UIAttach| after a UI attaches
|UIDetach| after a UI detaches
|UIEnter| after a UI attaches
|UILeave| after a UI detaches
|TermResponse| after the terminal response to t_RV is received
|QuitPre| when using `:quit`, before deciding whether to exit
|ExitPre| when using a command that may make Vim exit
@ -805,14 +805,14 @@ FuncUndefined When a user function is used but it isn't
NOTE: When writing Vim scripts a better
alternative is to use an autoloaded function.
See |autoload-functions|.
*UIAttach*
UIAttach After a UI connects via |nvim_ui_attach()|,
*UIEnter*
UIEnter After a UI connects via |nvim_ui_attach()|,
after VimEnter. Can be used for GUI-specific
configuration.
Sets these |v:event| keys:
chan
*UIDetach*
UIDetach After a UI detaches from Nvim.
*UILeave*
UILeave After a UI disconnects from Nvim.
Sets these |v:event| keys:
chan
*InsertChange*

View File

@ -28,7 +28,7 @@ Environment Variables ~
Events ~
*EncodingChanged* Never fired; 'encoding' is always "utf-8".
*FileEncoding* Never fired; equivalent to |EncodingChanged|.
*GUIEnter* Never fired; use |UIAttach| instead.
*GUIEnter* Never fired; use |UIEnter| instead.
*GUIFailed* Never fired.
Keycodes ~

View File

@ -12,11 +12,11 @@ Nvim Graphical User Interface *gui* *GUI*
Starting the GUI *gui-start* *E229* *E233*
*ginit.vim* *gui-init* *gvimrc* *$MYGVIMRC*
For GUI-specific configuration Nvim provides the |UIAttach| event. This
For GUI-specific configuration Nvim provides the |UIEnter| event. This
happens after other |initialization|s, like reading your vimrc file.
Example: this sets "g:gui" to the value of the UI's "rgb" field: >
:autocmd UIAttach * let g:gui = filter(nvim_list_uis(),{k,v-> v.chan==v:event.chan})[0].rgb
:autocmd UIEnter * let g:gui = filter(nvim_list_uis(),{k,v-> v.chan==v:event.chan})[0].rgb
<
*:winp* *:winpos* *E188*

View File

@ -154,8 +154,8 @@ Events:
|TermClose|
|TermOpen|
|TextYankPost|
|UIAttach|
|UIDetach|
|UIEnter|
|UILeave|
|VimResume|
|VimSuspend|

View File

@ -13,7 +13,7 @@
# include "aucmd.c.generated.h"
#endif
void do_autocmd_uiattach(uint64_t chanid, bool attached)
void do_autocmd_uienter(uint64_t chanid, bool attached)
{
static bool recursive = false;
@ -26,7 +26,7 @@ void do_autocmd_uiattach(uint64_t chanid, bool attached)
assert(chanid < VARNUMBER_MAX);
tv_dict_add_nr(dict, S_LEN("chan"), (varnumber_T)chanid);
tv_dict_set_keys_readonly(dict);
apply_autocmds(attached ? EVENT_UIATTACH : EVENT_UIDETACH,
apply_autocmds(attached ? EVENT_UIENTER : EVENT_UILEAVE,
NULL, NULL, false, curbuf);
tv_dict_clear(dict);

View File

@ -96,8 +96,8 @@ return {
'TextChangedI', -- text was modified in Insert mode(no popup)
'TextChangedP', -- text was modified in Insert mode(popup)
'TextYankPost', -- after a yank or delete was done (y, d, c)
'UIAttach', -- after a UI attached
'UIDetach', -- after a UI detaches
'UIEnter', -- after UI attaches
'UILeave', -- after UI detaches
'User', -- user defined autocommand
'VimEnter', -- after starting Vim
'VimLeave', -- before exiting Vim
@ -125,7 +125,7 @@ return {
TabNewEntered=true,
TermClose=true,
TermOpen=true,
UIAttach=true,
UIDetach=true,
UIEnter=true,
UILeave=true,
},
}

View File

@ -296,7 +296,7 @@ void ui_attach_impl(UI *ui, uint64_t chanid)
bool is_compositor = (ui == uis[0]);
if (!is_compositor) {
do_autocmd_uiattach(chanid, true);
do_autocmd_uienter(chanid, true);
}
}
@ -333,7 +333,7 @@ void ui_detach_impl(UI *ui, uint64_t chanid)
ui_comp_detach(ui);
}
do_autocmd_uiattach(chanid, false);
do_autocmd_uienter(chanid, false);
}
void ui_set_ext_option(UI *ui, UIExtension ext, bool active)

View File

@ -36,21 +36,21 @@ describe('nvim_ui_attach()', function()
end)
end)
it('autocmds UIAttach/UIDetach', function()
it('autocmds UIEnter/UILeave', function()
clear{args={
'--cmd', 'let g:evs = []',
'--cmd', 'autocmd UIAttach * :call add(g:evs, "UIAttach") | let g:ui_attach_ev = deepcopy(v:event)',
'--cmd', 'autocmd UIDetach * :call add(g:evs, "UIDetach") | let g:ui_detach_ev = deepcopy(v:event)',
'--cmd', 'autocmd UIEnter * :call add(g:evs, "UIEnter") | let g:uienter_ev = deepcopy(v:event)',
'--cmd', 'autocmd UILeave * :call add(g:evs, "UILeave") | let g:uileave_ev = deepcopy(v:event)',
'--cmd', 'autocmd VimEnter * :call add(g:evs, "VimEnter")',
}}
local screen = Screen.new()
screen:attach()
eq({chan=1}, eval('g:ui_attach_ev'))
eq({chan=1}, eval('g:uienter_ev'))
screen:detach()
eq({chan=1}, eval('g:ui_detach_ev'))
eq({chan=1}, eval('g:uileave_ev'))
eq({
'VimEnter',
'UIAttach',
'UIDetach',
'UIEnter',
'UILeave',
}, eval('g:evs'))
end)