From 817be96be535a8aecc24a72f51fe2d6743ed4a24 Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Mon, 22 Dec 2014 02:05:22 -0300 Subject: Add TabNew event TabNew triggers when entering a new tab page, but not when entering an already created one. --- src/nvim/ex_docmd.c | 2 ++ src/nvim/fileio.c | 1 + src/nvim/fileio.h | 1 + 3 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7ff69a3d41..9d2285acb5 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5715,6 +5715,8 @@ void ex_splitview(exarg_T *eap) if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab : eap->addr_count == 0 ? 0 : (int)eap->line2 + 1) != FAIL) { + apply_autocmds(EVENT_TABNEW, eap->arg, eap->arg, FALSE, curbuf); + entering_new_tab = true; do_exedit(eap, old_curwin); /* set the alternate buffer for the window we came from */ diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index dd6e5ace3f..c8944fffe4 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5247,6 +5247,7 @@ static struct event_name { {"Syntax", EVENT_SYNTAX}, {"TabEnter", EVENT_TABENTER}, {"TabLeave", EVENT_TABLEAVE}, + {"TabNew", EVENT_TABNEW}, {"TermChanged", EVENT_TERMCHANGED}, {"TermResponse", EVENT_TERMRESPONSE}, {"TextChanged", EVENT_TEXTCHANGED}, diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 29bd1307f6..134759577c 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -95,6 +95,7 @@ typedef enum auto_event { EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */ EVENT_TABLEAVE, /* before leaving a tab page */ EVENT_TABENTER, /* after entering a tab page */ + EVENT_TABNEW, /* when creating a new tab */ EVENT_SHELLCMDPOST, /* after ":!cmd" */ EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */ EVENT_TEXTCHANGED, /* text was modified */ -- cgit From 66d94869a0f01902d93597eae4244f9a64db82fc Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Tue, 23 Dec 2014 11:56:10 -0300 Subject: Add TabNewEntered TabNewEntered is triggered after vim has entered a buffer in new tab. --- src/nvim/ex_docmd.c | 2 +- src/nvim/fileio.c | 1 + src/nvim/fileio.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9d2285acb5..189881be34 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5716,8 +5716,8 @@ void ex_splitview(exarg_T *eap) : eap->addr_count == 0 ? 0 : (int)eap->line2 + 1) != FAIL) { apply_autocmds(EVENT_TABNEW, eap->arg, eap->arg, FALSE, curbuf); - entering_new_tab = true; do_exedit(eap, old_curwin); + apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, FALSE, curbuf); /* set the alternate buffer for the window we came from */ if (curwin != old_curwin diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index c8944fffe4..6aeb36b719 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5248,6 +5248,7 @@ static struct event_name { {"TabEnter", EVENT_TABENTER}, {"TabLeave", EVENT_TABLEAVE}, {"TabNew", EVENT_TABNEW}, + {"TabNewEntered", EVENT_TABNEWENTERED}, {"TermChanged", EVENT_TERMCHANGED}, {"TermResponse", EVENT_TERMRESPONSE}, {"TextChanged", EVENT_TEXTCHANGED}, diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 134759577c..48d96760db 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -96,6 +96,7 @@ typedef enum auto_event { EVENT_TABLEAVE, /* before leaving a tab page */ EVENT_TABENTER, /* after entering a tab page */ EVENT_TABNEW, /* when creating a new tab */ + EVENT_TABNEWENTERED, /* after entering a new tab */ EVENT_SHELLCMDPOST, /* after ":!cmd" */ EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */ EVENT_TEXTCHANGED, /* text was modified */ -- cgit From 3ffc5d81c34cfdd535573a50790690c88e4324bb Mon Sep 17 00:00:00 2001 From: Felipe Morales Date: Mon, 5 Jan 2015 01:03:22 -0300 Subject: Add TabClosed event TabClosed is triggered when a tab page closes. --- src/nvim/ex_docmd.c | 3 +++ src/nvim/fileio.c | 4 +++- src/nvim/fileio.h | 1 + src/nvim/window.c | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 189881be34..bf9b5c16d7 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5328,10 +5328,12 @@ void tabpage_close_other(tabpage_T *tp, int forceit) int done = 0; win_T *wp; int h = tabline_height(); + char_u prev_idx[NUMBUFLEN]; /* Limit to 1000 windows, autocommands may add a window while we close * one. OK, so I'm paranoid... */ while (++done < 1000) { + sprintf((char *)prev_idx, "%i", tabpage_index(tp)); wp = tp->tp_firstwin; ex_win_close(forceit, wp, tp); @@ -5340,6 +5342,7 @@ void tabpage_close_other(tabpage_T *tp, int forceit) if (!valid_tabpage(tp) || tp->tp_firstwin == wp) break; } + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, FALSE, curbuf); redraw_tabline = TRUE; if (h != tabline_height()) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 6aeb36b719..762514a237 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5245,6 +5245,7 @@ static struct event_name { {"StdinReadPre", EVENT_STDINREADPRE}, {"SwapExists", EVENT_SWAPEXISTS}, {"Syntax", EVENT_SYNTAX}, + {"TabClosed", EVENT_TABCLOSED}, {"TabEnter", EVENT_TABENTER}, {"TabLeave", EVENT_TABLEAVE}, {"TabNew", EVENT_TABNEW}, @@ -6634,7 +6635,8 @@ apply_autocmds_group ( || event == EVENT_QUICKFIXCMDPRE || event == EVENT_COLORSCHEME || event == EVENT_QUICKFIXCMDPOST - || event == EVENT_JOBACTIVITY) + || event == EVENT_JOBACTIVITY + || event == EVENT_TABCLOSED) fname = vim_strsave(fname); else fname = FullName_save(fname, FALSE); diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 48d96760db..7a9e2adae1 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -93,6 +93,7 @@ typedef enum auto_event { EVENT_SPELLFILEMISSING, /* spell file missing */ EVENT_CURSORMOVED, /* cursor was moved */ EVENT_CURSORMOVEDI, /* cursor was moved in Insert mode */ + EVENT_TABCLOSED, /* a tab has closed */ EVENT_TABLEAVE, /* before leaving a tab page */ EVENT_TABENTER, /* after entering a tab page */ EVENT_TABNEW, /* when creating a new tab */ diff --git a/src/nvim/window.c b/src/nvim/window.c index 52a1853f4b..adc6e9f1c2 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1791,6 +1791,9 @@ static int close_last_window_tabpage(win_T *win, int free_buf, tabpage_T *prev_c } /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do * that now. */ + char_u prev_idx[NUMBUFLEN]; + sprintf((char *)prev_idx, "%i", tabpage_index(prev_curtab)); + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, FALSE, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); if (old_curbuf != curbuf) -- cgit