mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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.
This commit is contained in:
parent
ed99198ff1
commit
20848c4064
@ -29,8 +29,10 @@
|
|||||||
static uint64_t next_handle = 1;
|
static uint64_t next_handle = 1;
|
||||||
|
|
||||||
HANDLE_IMPL(buf_T, buffer)
|
HANDLE_IMPL(buf_T, buffer)
|
||||||
|
HANDLE_IMPL(win_T, window)
|
||||||
|
|
||||||
void handle_init()
|
void handle_init()
|
||||||
{
|
{
|
||||||
HANDLE_INIT(buffer);
|
HANDLE_INIT(buffer);
|
||||||
|
HANDLE_INIT(window);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
void handle_unregister_##name(type *name);
|
void handle_unregister_##name(type *name);
|
||||||
|
|
||||||
HANDLE_DECLS(buf_T, buffer)
|
HANDLE_DECLS(buf_T, buffer)
|
||||||
|
HANDLE_DECLS(win_T, window)
|
||||||
|
|
||||||
void handle_init(void);
|
void handle_init(void);
|
||||||
|
|
||||||
|
@ -840,6 +840,7 @@ struct matchitem {
|
|||||||
* All row numbers are relative to the start of the window, except w_winrow.
|
* All row numbers are relative to the start of the window, except w_winrow.
|
||||||
*/
|
*/
|
||||||
struct window_S {
|
struct window_S {
|
||||||
|
uint64_t handle;
|
||||||
buf_T *w_buffer; /* buffer we are a window into (used
|
buf_T *w_buffer; /* buffer we are a window into (used
|
||||||
often, keep it the first item!) */
|
often, keep it the first item!) */
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
* See README.txt for an overview of the Vim source code.
|
* See README.txt for an overview of the Vim source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "nvim/api/private/handle.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
#include "nvim/buffer.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
|
* allocate window structure and linesizes arrays
|
||||||
*/
|
*/
|
||||||
win_T *new_wp = xcalloc(1, sizeof(win_T));
|
win_T *new_wp = xcalloc(1, sizeof(win_T));
|
||||||
|
handle_register_window(new_wp);
|
||||||
win_alloc_lines(new_wp);
|
win_alloc_lines(new_wp);
|
||||||
|
|
||||||
/* init w: variables */
|
/* init w: variables */
|
||||||
@ -3583,6 +3585,7 @@ static win_T *win_alloc(win_T *after, int hidden)
|
|||||||
*/
|
*/
|
||||||
if (!hidden)
|
if (!hidden)
|
||||||
win_append(after, new_wp);
|
win_append(after, new_wp);
|
||||||
|
|
||||||
new_wp->w_wincol = 0;
|
new_wp->w_wincol = 0;
|
||||||
new_wp->w_width = Columns;
|
new_wp->w_width = Columns;
|
||||||
|
|
||||||
@ -3618,6 +3621,7 @@ win_free (
|
|||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
wininfo_T *wip;
|
wininfo_T *wip;
|
||||||
|
|
||||||
|
handle_unregister_window(wp);
|
||||||
clearFolding(wp);
|
clearFolding(wp);
|
||||||
|
|
||||||
/* reduce the reference count to the argument list. */
|
/* reduce the reference count to the argument list. */
|
||||||
|
Loading…
Reference in New Issue
Block a user