mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 7.4.2075
Problem: No autocommand event to initialize a window or tab page. Solution: Add WinNew and TabNew events. (partly by Felipe Morales)
This commit is contained in:
parent
0a0f641b98
commit
c917da4b3e
@ -293,6 +293,8 @@ Name triggered by ~
|
|||||||
|CursorMoved| the cursor was moved in Normal mode
|
|CursorMoved| the cursor was moved in Normal mode
|
||||||
|CursorMovedI| the cursor was moved in Insert mode
|
|CursorMovedI| the cursor was moved in Insert mode
|
||||||
|
|
||||||
|
|WinNew| after creating a new window
|
||||||
|
|TabNew| after creating a new window
|
||||||
|WinEnter| after entering another window
|
|WinEnter| after entering another window
|
||||||
|WinLeave| before leaving a window
|
|WinLeave| before leaving a window
|
||||||
|TabEnter| after entering another tab page
|
|TabEnter| after entering another tab page
|
||||||
@ -309,6 +311,9 @@ Name triggered by ~
|
|||||||
|TextChanged| after a change was made to the text in Normal mode
|
|TextChanged| after a change was made to the text in Normal mode
|
||||||
|TextChangedI| after a change was made to the text in Insert mode
|
|TextChangedI| after a change was made to the text in Insert mode
|
||||||
|
|
||||||
|
|TextChanged| after a change was made to the text in Normal mode
|
||||||
|
|TextChangedI| after a change was made to the text in Insert mode
|
||||||
|
|
||||||
|ColorScheme| after loading a color scheme
|
|ColorScheme| after loading a color scheme
|
||||||
|
|
||||||
|RemoteReply| a reply from a server Vim was received
|
|RemoteReply| a reply from a server Vim was received
|
||||||
@ -882,6 +887,10 @@ TabEnter Just after entering a tab page. |tab-page|
|
|||||||
TabLeave Just before leaving a tab page. |tab-page|
|
TabLeave Just before leaving a tab page. |tab-page|
|
||||||
A WinLeave event will have been triggered
|
A WinLeave event will have been triggered
|
||||||
first.
|
first.
|
||||||
|
*TabNew*
|
||||||
|
TabNew When a tab page was created. |tab-page|
|
||||||
|
A WinEnter event will have been triggered
|
||||||
|
first, TabEnter follows.
|
||||||
*TermChanged*
|
*TermChanged*
|
||||||
TermChanged After the value of 'term' has changed. Useful
|
TermChanged After the value of 'term' has changed. Useful
|
||||||
for re-loading the syntax file to update the
|
for re-loading the syntax file to update the
|
||||||
|
@ -7706,6 +7706,7 @@ static struct event_name
|
|||||||
{"StdinReadPre", EVENT_STDINREADPRE},
|
{"StdinReadPre", EVENT_STDINREADPRE},
|
||||||
{"SwapExists", EVENT_SWAPEXISTS},
|
{"SwapExists", EVENT_SWAPEXISTS},
|
||||||
{"Syntax", EVENT_SYNTAX},
|
{"Syntax", EVENT_SYNTAX},
|
||||||
|
{"TabNew", EVENT_TABNEW},
|
||||||
{"TabEnter", EVENT_TABENTER},
|
{"TabEnter", EVENT_TABENTER},
|
||||||
{"TabLeave", EVENT_TABLEAVE},
|
{"TabLeave", EVENT_TABLEAVE},
|
||||||
{"TermChanged", EVENT_TERMCHANGED},
|
{"TermChanged", EVENT_TERMCHANGED},
|
||||||
@ -7716,6 +7717,7 @@ static struct event_name
|
|||||||
{"VimEnter", EVENT_VIMENTER},
|
{"VimEnter", EVENT_VIMENTER},
|
||||||
{"VimLeave", EVENT_VIMLEAVE},
|
{"VimLeave", EVENT_VIMLEAVE},
|
||||||
{"VimLeavePre", EVENT_VIMLEAVEPRE},
|
{"VimLeavePre", EVENT_VIMLEAVEPRE},
|
||||||
|
{"WinNew", EVENT_WINNEW},
|
||||||
{"WinEnter", EVENT_WINENTER},
|
{"WinEnter", EVENT_WINENTER},
|
||||||
{"WinLeave", EVENT_WINLEAVE},
|
{"WinLeave", EVENT_WINLEAVE},
|
||||||
{"VimResized", EVENT_VIMRESIZED},
|
{"VimResized", EVENT_VIMRESIZED},
|
||||||
|
@ -78,3 +78,33 @@ function Test_autocmd_bufunload_with_tabnext()
|
|||||||
tablast
|
tablast
|
||||||
quit
|
quit
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_win_tab_autocmd()
|
||||||
|
let g:record = []
|
||||||
|
|
||||||
|
augroup testing
|
||||||
|
au WinNew * call add(g:record, 'WinNew')
|
||||||
|
au WinEnter * call add(g:record, 'WinEnter')
|
||||||
|
au WinLeave * call add(g:record, 'WinLeave')
|
||||||
|
au TabNew * call add(g:record, 'TabNew')
|
||||||
|
au TabEnter * call add(g:record, 'TabEnter')
|
||||||
|
au TabLeave * call add(g:record, 'TabLeave')
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
split
|
||||||
|
tabnew
|
||||||
|
close
|
||||||
|
close
|
||||||
|
|
||||||
|
call assert_equal([
|
||||||
|
\ 'WinLeave', 'WinNew', 'WinEnter',
|
||||||
|
\ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter',
|
||||||
|
\ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter',
|
||||||
|
\ 'WinLeave', 'WinEnter'
|
||||||
|
\ ], g:record)
|
||||||
|
|
||||||
|
augroup testing
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
unlet g:record
|
||||||
|
endfunc
|
||||||
|
@ -758,6 +758,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2075,
|
||||||
/**/
|
/**/
|
||||||
2074,
|
2074,
|
||||||
/**/
|
/**/
|
||||||
|
@ -1315,6 +1315,7 @@ enum auto_event
|
|||||||
EVENT_VIMRESIZED, /* after Vim window was resized */
|
EVENT_VIMRESIZED, /* after Vim window was resized */
|
||||||
EVENT_WINENTER, /* after entering a window */
|
EVENT_WINENTER, /* after entering a window */
|
||||||
EVENT_WINLEAVE, /* before leaving a window */
|
EVENT_WINLEAVE, /* before leaving a window */
|
||||||
|
EVENT_WINNEW, /* when entering a new window */
|
||||||
EVENT_ENCODINGCHANGED, /* after changing the 'encoding' option */
|
EVENT_ENCODINGCHANGED, /* after changing the 'encoding' option */
|
||||||
EVENT_INSERTCHARPRE, /* before inserting a char */
|
EVENT_INSERTCHARPRE, /* before inserting a char */
|
||||||
EVENT_CURSORHOLD, /* cursor in same position for a while */
|
EVENT_CURSORHOLD, /* cursor in same position for a while */
|
||||||
@ -1327,8 +1328,9 @@ enum auto_event
|
|||||||
EVENT_SPELLFILEMISSING, /* spell file missing */
|
EVENT_SPELLFILEMISSING, /* spell file missing */
|
||||||
EVENT_CURSORMOVED, /* cursor was moved */
|
EVENT_CURSORMOVED, /* cursor was moved */
|
||||||
EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */
|
EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */
|
||||||
EVENT_TABLEAVE, /* before leaving a tab page */
|
|
||||||
EVENT_TABENTER, /* after entering a tab page */
|
EVENT_TABENTER, /* after entering a tab page */
|
||||||
|
EVENT_TABLEAVE, /* before leaving a tab page */
|
||||||
|
EVENT_TABNEW, /* when entering a new tab page */
|
||||||
EVENT_SHELLCMDPOST, /* after ":!cmd" */
|
EVENT_SHELLCMDPOST, /* after ":!cmd" */
|
||||||
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
|
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
|
||||||
EVENT_TEXTCHANGED, /* text was modified */
|
EVENT_TEXTCHANGED, /* text was modified */
|
||||||
|
15
src/window.c
15
src/window.c
@ -45,7 +45,7 @@ static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds);
|
|||||||
static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds);
|
static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds);
|
||||||
static void frame_fix_height(win_T *wp);
|
static void frame_fix_height(win_T *wp);
|
||||||
static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
|
static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
|
||||||
static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_enter_autocmds, int trigger_leave_autocmds);
|
static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_new_autocmds, int trigger_enter_autocmds, int trigger_leave_autocmds);
|
||||||
static void win_free(win_T *wp, tabpage_T *tp);
|
static void win_free(win_T *wp, tabpage_T *tp);
|
||||||
static void frame_append(frame_T *after, frame_T *frp);
|
static void frame_append(frame_T *after, frame_T *frp);
|
||||||
static void frame_insert(frame_T *before, frame_T *frp);
|
static void frame_insert(frame_T *before, frame_T *frp);
|
||||||
@ -1259,7 +1259,7 @@ win_split_ins(
|
|||||||
/*
|
/*
|
||||||
* make the new window the current window
|
* make the new window the current window
|
||||||
*/
|
*/
|
||||||
win_enter(wp, FALSE);
|
win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE);
|
||||||
if (flags & WSP_VERT)
|
if (flags & WSP_VERT)
|
||||||
p_wiw = i;
|
p_wiw = i;
|
||||||
else
|
else
|
||||||
@ -2416,7 +2416,7 @@ win_close(win_T *win, int free_buf)
|
|||||||
win_comp_pos();
|
win_comp_pos();
|
||||||
if (close_curwin)
|
if (close_curwin)
|
||||||
{
|
{
|
||||||
win_enter_ext(wp, FALSE, TRUE, TRUE, TRUE);
|
win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE);
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
if (other_buffer)
|
if (other_buffer)
|
||||||
/* careful: after this wp and win may be invalid! */
|
/* careful: after this wp and win may be invalid! */
|
||||||
@ -3629,7 +3629,9 @@ win_new_tabpage(int after)
|
|||||||
|
|
||||||
redraw_all_later(CLEAR);
|
redraw_all_later(CLEAR);
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
|
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
|
||||||
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
|
||||||
|
apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf);
|
||||||
apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
@ -3808,7 +3810,7 @@ enter_tabpage(
|
|||||||
/* We would like doing the TabEnter event first, but we don't have a
|
/* We would like doing the TabEnter event first, but we don't have a
|
||||||
* valid current window yet, which may break some commands.
|
* valid current window yet, which may break some commands.
|
||||||
* This triggers autocommands, thus may make "tp" invalid. */
|
* This triggers autocommands, thus may make "tp" invalid. */
|
||||||
win_enter_ext(tp->tp_curwin, FALSE, TRUE,
|
win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE,
|
||||||
trigger_enter_autocmds, trigger_leave_autocmds);
|
trigger_enter_autocmds, trigger_leave_autocmds);
|
||||||
prevwin = next_prevwin;
|
prevwin = next_prevwin;
|
||||||
|
|
||||||
@ -4242,7 +4244,7 @@ end:
|
|||||||
void
|
void
|
||||||
win_enter(win_T *wp, int undo_sync)
|
win_enter(win_T *wp, int undo_sync)
|
||||||
{
|
{
|
||||||
win_enter_ext(wp, undo_sync, FALSE, TRUE, TRUE);
|
win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4255,6 +4257,7 @@ win_enter_ext(
|
|||||||
win_T *wp,
|
win_T *wp,
|
||||||
int undo_sync,
|
int undo_sync,
|
||||||
int curwin_invalid,
|
int curwin_invalid,
|
||||||
|
int trigger_new_autocmds UNUSED,
|
||||||
int trigger_enter_autocmds UNUSED,
|
int trigger_enter_autocmds UNUSED,
|
||||||
int trigger_leave_autocmds UNUSED)
|
int trigger_leave_autocmds UNUSED)
|
||||||
{
|
{
|
||||||
@ -4340,6 +4343,8 @@ win_enter_ext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
|
if (trigger_new_autocmds)
|
||||||
|
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
|
||||||
if (trigger_enter_autocmds)
|
if (trigger_enter_autocmds)
|
||||||
{
|
{
|
||||||
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user