aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-05-23 15:49:33 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-05-23 16:06:58 -0300
commit20848c4064fc82c160d68770b2e64f5115f0bf60 (patch)
treecd290f398ca476b28f9eae7079ef9fe4a44f49f9 /src
parented99198ff1a3c2b6aad88b03e838a1337f83c4dc (diff)
downloadrneovim-20848c4064fc82c160d68770b2e64f5115f0bf60.tar.gz
rneovim-20848c4064fc82c160d68770b2e64f5115f0bf60.tar.bz2
rneovim-20848c4064fc82c160d68770b2e64f5115f0bf60.zip
API: Refactor: Register/unregister created/destroyed windows
- Add the 'handle' field to `win_T` - Add declare/implement functions for registering/unregistering/retrieving windows - Register/unregister windows when they are created/destroyed.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/private/handle.c2
-rw-r--r--src/nvim/api/private/handle.h1
-rw-r--r--src/nvim/buffer_defs.h1
-rw-r--r--src/nvim/window.c4
4 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/api/private/handle.c b/src/nvim/api/private/handle.c
index 97f5cd88b5..3dfe05d59f 100644
--- a/src/nvim/api/private/handle.c
+++ b/src/nvim/api/private/handle.c
@@ -29,8 +29,10 @@
static uint64_t next_handle = 1;
HANDLE_IMPL(buf_T, buffer)
+HANDLE_IMPL(win_T, window)
void handle_init()
{
HANDLE_INIT(buffer);
+ HANDLE_INIT(window);
}
diff --git a/src/nvim/api/private/handle.h b/src/nvim/api/private/handle.h
index 846b20dff2..29c80e10d4 100644
--- a/src/nvim/api/private/handle.h
+++ b/src/nvim/api/private/handle.h
@@ -10,6 +10,7 @@
void handle_unregister_##name(type *name);
HANDLE_DECLS(buf_T, buffer)
+HANDLE_DECLS(win_T, window)
void handle_init(void);
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 6634ba72a6..68f70d7bf3 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -840,6 +840,7 @@ struct matchitem {
* All row numbers are relative to the start of the window, except w_winrow.
*/
struct window_S {
+ uint64_t handle;
buf_T *w_buffer; /* buffer we are a window into (used
often, keep it the first item!) */
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 851e9cead7..a0a325f950 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -6,6 +6,7 @@
* See README.txt for an overview of the Vim source code.
*/
+#include "nvim/api/private/handle.h"
#include "nvim/vim.h"
#include "nvim/window.h"
#include "nvim/buffer.h"
@@ -3568,6 +3569,7 @@ static win_T *win_alloc(win_T *after, int hidden)
* allocate window structure and linesizes arrays
*/
win_T *new_wp = xcalloc(1, sizeof(win_T));
+ handle_register_window(new_wp);
win_alloc_lines(new_wp);
/* init w: variables */
@@ -3583,6 +3585,7 @@ static win_T *win_alloc(win_T *after, int hidden)
*/
if (!hidden)
win_append(after, new_wp);
+
new_wp->w_wincol = 0;
new_wp->w_width = Columns;
@@ -3618,6 +3621,7 @@ win_free (
buf_T *buf;
wininfo_T *wip;
+ handle_unregister_window(wp);
clearFolding(wp);
/* reduce the reference count to the argument list. */