mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
UIEnter/UILeave: fire for embedder UI, builtin TUI
Before this, --embed UIs (without --headless) would not trigger UIEnter. For TUI, maybe UIEnter isn't useful, but: - It is less "surprising"/special. - Makes documentation simpler. - When TUI becomes a coprocess, it will happen anyway.
This commit is contained in:
parent
589f612adf
commit
492ac04f7e
@ -12,6 +12,7 @@
|
|||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/main.h"
|
#include "nvim/main.h"
|
||||||
|
#include "nvim/aucmd.h"
|
||||||
#include "nvim/buffer.h"
|
#include "nvim/buffer.h"
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
#include "nvim/diff.h"
|
#include "nvim/diff.h"
|
||||||
@ -351,7 +352,7 @@ int main(int argc, char **argv)
|
|||||||
bool use_remote_ui = (embedded_mode && !headless_mode);
|
bool use_remote_ui = (embedded_mode && !headless_mode);
|
||||||
bool use_builtin_ui = (!headless_mode && !embedded_mode && !silent_mode);
|
bool use_builtin_ui = (!headless_mode && !embedded_mode && !silent_mode);
|
||||||
if (use_remote_ui || use_builtin_ui) {
|
if (use_remote_ui || use_builtin_ui) {
|
||||||
TIME_MSG("waiting for UI to make request");
|
TIME_MSG("waiting for UI");
|
||||||
if (use_remote_ui) {
|
if (use_remote_ui) {
|
||||||
remote_ui_wait_for_attach();
|
remote_ui_wait_for_attach();
|
||||||
} else {
|
} else {
|
||||||
@ -537,6 +538,10 @@ int main(int argc, char **argv)
|
|||||||
set_vim_var_nr(VV_VIM_DID_ENTER, 1L);
|
set_vim_var_nr(VV_VIM_DID_ENTER, 1L);
|
||||||
apply_autocmds(EVENT_VIMENTER, NULL, NULL, false, curbuf);
|
apply_autocmds(EVENT_VIMENTER, NULL, NULL, false, curbuf);
|
||||||
TIME_MSG("VimEnter autocommands");
|
TIME_MSG("VimEnter autocommands");
|
||||||
|
if (use_remote_ui || use_builtin_ui) {
|
||||||
|
do_autocmd_uienter(use_remote_ui ? CHAN_STDIO : 0, true);
|
||||||
|
TIME_MSG("UIEnter autocommands");
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust default register name for "unnamed" in 'clipboard'. Can only be
|
// Adjust default register name for "unnamed" in 'clipboard'. Can only be
|
||||||
// done after the clipboard is available and all initial commands that may
|
// done after the clipboard is available and all initial commands that may
|
||||||
|
@ -37,7 +37,9 @@ describe('nvim_ui_attach()', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('autocmds UIEnter/UILeave', function()
|
it('autocmds UIEnter/UILeave', function()
|
||||||
clear{args={
|
clear{
|
||||||
|
args_rm={'--headless'},
|
||||||
|
args={
|
||||||
'--cmd', 'let g:evs = []',
|
'--cmd', 'let g:evs = []',
|
||||||
'--cmd', 'autocmd UIEnter * :call add(g:evs, "UIEnter") | let g:uienter_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 UILeave * :call add(g:evs, "UILeave") | let g:uileave_ev = deepcopy(v:event)',
|
||||||
|
@ -767,11 +767,36 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('TUI UIEnter/UILeave', function()
|
||||||
|
it('fires exactly once, after VimEnter', function()
|
||||||
|
clear()
|
||||||
|
local screen = thelpers.screen_setup(0,
|
||||||
|
'["'..nvim_prog..'", "-u", "NONE", "-i", "NONE"'
|
||||||
|
..[[, "--cmd", "set noswapfile noshowcmd noruler"]]
|
||||||
|
..[[, "--cmd", "let g:evs = []"]]
|
||||||
|
..[[, "--cmd", "autocmd UIEnter * :call add(g:evs, 'UIEnter')"]]
|
||||||
|
..[[, "--cmd", "autocmd UILeave * :call add(g:evs, 'UILeave')"]]
|
||||||
|
..[[, "--cmd", "autocmd VimEnter * :call add(g:evs, 'VimEnter')"]]
|
||||||
|
..']'
|
||||||
|
)
|
||||||
|
feed_data(":echo g:evs\n")
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{1: } |
|
||||||
|
{4:~ }|
|
||||||
|
{4:~ }|
|
||||||
|
{4:~ }|
|
||||||
|
{5:[No Name] }|
|
||||||
|
['VimEnter', 'UIEnter'] |
|
||||||
|
{3:-- TERMINAL --} |
|
||||||
|
]]}
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
describe('TUI FocusGained/FocusLost', function()
|
describe('TUI FocusGained/FocusLost', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
helpers.clear()
|
clear()
|
||||||
screen = thelpers.screen_setup(0, '["'..nvim_prog
|
screen = thelpers.screen_setup(0, '["'..nvim_prog
|
||||||
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
||||||
feed_data(":autocmd FocusGained * echo 'gained'\n")
|
feed_data(":autocmd FocusGained * echo 'gained'\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user