summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-19 22:31:36 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-19 22:31:36 +0200
commitc917da4b3e8801a255dbefea8e4ed19c1c716dd8 (patch)
tree4c4ca7b3b658f666aa781e2f9e51e9dafc57f6d6 /src/window.c
parent0a0f641b9841189ba4180758109d04d0a26e50e3 (diff)
downloadvim-git-c917da4b3e8801a255dbefea8e4ed19c1c716dd8.tar.gz
patch 7.4.2075v7.4.2075
Problem: No autocommand event to initialize a window or tab page. Solution: Add WinNew and TabNew events. (partly by Felipe Morales)
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/window.c b/src/window.c
index b9e75d6df..bf650f84b 100644
--- a/src/window.c
+++ b/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 frame_fix_height(win_T *wp);
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 frame_append(frame_T *after, 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
*/
- win_enter(wp, FALSE);
+ win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE);
if (flags & WSP_VERT)
p_wiw = i;
else
@@ -2416,7 +2416,7 @@ win_close(win_T *win, int free_buf)
win_comp_pos();
if (close_curwin)
{
- win_enter_ext(wp, FALSE, TRUE, TRUE, TRUE);
+ win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE);
#ifdef FEAT_AUTOCMD
if (other_buffer)
/* careful: after this wp and win may be invalid! */
@@ -3629,7 +3629,9 @@ win_new_tabpage(int after)
redraw_all_later(CLEAR);
#ifdef FEAT_AUTOCMD
+ apply_autocmds(EVENT_WINNEW, 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);
#endif
return OK;
@@ -3808,7 +3810,7 @@ enter_tabpage(
/* We would like doing the TabEnter event first, but we don't have a
* valid current window yet, which may break some commands.
* 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);
prevwin = next_prevwin;
@@ -4242,7 +4244,7 @@ end:
void
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,
int undo_sync,
int curwin_invalid,
+ int trigger_new_autocmds UNUSED,
int trigger_enter_autocmds UNUSED,
int trigger_leave_autocmds UNUSED)
{
@@ -4340,6 +4343,8 @@ win_enter_ext(
}
#ifdef FEAT_AUTOCMD
+ if (trigger_new_autocmds)
+ apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
if (trigger_enter_autocmds)
{
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);