mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
@@ -19,8 +19,6 @@
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/screen.h"
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/eval.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "api/ui.c.generated.h"
|
||||
@@ -59,7 +57,7 @@ void remote_ui_disconnect(uint64_t channel_id)
|
||||
pmap_del(uint64_t)(connected_uis, channel_id);
|
||||
xfree(ui->data);
|
||||
ui->data = NULL; // Flag UI as "stopped".
|
||||
ui_detach_impl(ui);
|
||||
ui_detach_impl(ui, channel_id);
|
||||
xfree(ui);
|
||||
}
|
||||
|
||||
@@ -170,13 +168,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
||||
ui->data = data;
|
||||
|
||||
pmap_put(uint64_t)(connected_uis, channel_id, ui);
|
||||
ui_attach_impl(ui);
|
||||
|
||||
dict_T *dict = get_vim_var_dict(VV_EVENT);
|
||||
tv_dict_add_nr(dict, S_LEN("chan"), (long)channel_id);
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
apply_autocmds(EVENT_UIATTACH, NULL, NULL, false, curbuf);
|
||||
tv_dict_clear(dict);
|
||||
ui_attach_impl(ui, channel_id);
|
||||
}
|
||||
|
||||
/// @deprecated
|
||||
@@ -204,12 +196,6 @@ void nvim_ui_detach(uint64_t channel_id, Error *err)
|
||||
return;
|
||||
}
|
||||
remote_ui_disconnect(channel_id);
|
||||
|
||||
dict_T *dict = get_vim_var_dict(VV_EVENT);
|
||||
tv_dict_add_nr(dict, S_LEN("chan"), (long)channel_id);
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
apply_autocmds(EVENT_UIDETACH, NULL, NULL, false, curbuf);
|
||||
tv_dict_clear(dict);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -7,11 +7,32 @@
|
||||
#include "nvim/main.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/aucmd.h"
|
||||
#include "nvim/eval.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "aucmd.c.generated.h"
|
||||
#endif
|
||||
|
||||
void do_autocmd_uiattach(uint64_t chanid, bool attached)
|
||||
{
|
||||
static bool recursive = false;
|
||||
|
||||
if (recursive) {
|
||||
return; // disallow recursion
|
||||
}
|
||||
recursive = true;
|
||||
|
||||
dict_T *dict = get_vim_var_dict(VV_EVENT);
|
||||
assert(chanid < VARNUMBER_MAX);
|
||||
tv_dict_add_nr(dict, S_LEN("chan"), (varnumber_T)chanid);
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
apply_autocmds(attached ? EVENT_UIATTACH : EVENT_UIDETACH,
|
||||
NULL, NULL, false, curbuf);
|
||||
tv_dict_clear(dict);
|
||||
|
||||
recursive = false;
|
||||
}
|
||||
|
||||
static void focusgained_event(void **argv)
|
||||
{
|
||||
bool *gainedp = argv[0];
|
||||
@@ -38,4 +59,3 @@ static void do_autocmd_focusgained(bool gained)
|
||||
NULL, NULL, false, curbuf);
|
||||
recursive = false;
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#ifndef NVIM_AUCMD_H
|
||||
#define NVIM_AUCMD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "aucmd.h.generated.h"
|
||||
#endif
|
||||
|
@@ -3111,8 +3111,6 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
|
||||
}
|
||||
if (is_vimrc == DOSO_VIMRC) {
|
||||
vimrc_found(fname_exp, (char_u *)"MYVIMRC");
|
||||
} else if (is_vimrc == DOSO_GVIMRC) {
|
||||
vimrc_found(fname_exp, (char_u *)"MYGVIMRC");
|
||||
}
|
||||
|
||||
#ifdef USE_CRNL
|
||||
|
@@ -7,19 +7,18 @@
|
||||
|
||||
typedef void (*DoInRuntimepathCB)(char_u *, void *);
|
||||
|
||||
/*
|
||||
* flags for check_changed()
|
||||
*/
|
||||
#define CCGD_AW 1 /* do autowrite if buffer was changed */
|
||||
#define CCGD_MULTWIN 2 /* check also when several wins for the buf */
|
||||
#define CCGD_FORCEIT 4 /* ! used */
|
||||
#define CCGD_ALLBUF 8 /* may write all buffers */
|
||||
#define CCGD_EXCMD 16 /* may suggest using ! */
|
||||
//
|
||||
// flags for check_changed()
|
||||
//
|
||||
#define CCGD_AW 1 // do autowrite if buffer was changed
|
||||
#define CCGD_MULTWIN 2 // check also when several wins for the buf
|
||||
#define CCGD_FORCEIT 4 // ! used
|
||||
#define CCGD_ALLBUF 8 // may write all buffers
|
||||
#define CCGD_EXCMD 16 // may suggest using !
|
||||
|
||||
/* last argument for do_source() */
|
||||
// last argument for do_source()
|
||||
#define DOSO_NONE 0
|
||||
#define DOSO_VIMRC 1 /* loading vimrc file */
|
||||
#define DOSO_GVIMRC 2 /* loading gvimrc file */
|
||||
#define DOSO_VIMRC 1 // loading vimrc file
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "ex_cmds2.h.generated.h"
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/log.h"
|
||||
#include "nvim/aucmd.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/cursor.h"
|
||||
@@ -268,7 +269,7 @@ void ui_busy_stop(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ui_attach_impl(UI *ui)
|
||||
void ui_attach_impl(UI *ui, uint64_t chanid)
|
||||
{
|
||||
if (ui_count == MAX_UI_COUNT) {
|
||||
abort();
|
||||
@@ -292,9 +293,14 @@ void ui_attach_impl(UI *ui)
|
||||
ui_send_all_hls(ui);
|
||||
}
|
||||
ui_refresh();
|
||||
|
||||
bool is_compositor = (ui == uis[0]);
|
||||
if (!is_compositor) {
|
||||
do_autocmd_uiattach(chanid, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_detach_impl(UI *ui)
|
||||
void ui_detach_impl(UI *ui, uint64_t chanid)
|
||||
{
|
||||
size_t shift_index = MAX_UI_COUNT;
|
||||
|
||||
@@ -326,6 +332,8 @@ void ui_detach_impl(UI *ui)
|
||||
if (!ui->ui_ext[kUIMultigrid] && !ui->ui_ext[kUIFloatDebug]) {
|
||||
ui_comp_detach(ui);
|
||||
}
|
||||
|
||||
do_autocmd_uiattach(chanid, false);
|
||||
}
|
||||
|
||||
void ui_set_ext_option(UI *ui, UIExtension ext, bool active)
|
||||
|
@@ -17,8 +17,6 @@
|
||||
#include "nvim/ui_bridge.h"
|
||||
#include "nvim/ugrid.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/eval.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "ui_bridge.c.generated.h"
|
||||
@@ -87,13 +85,7 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
|
||||
}
|
||||
uv_mutex_unlock(&rv->mutex);
|
||||
|
||||
ui_attach_impl(&rv->bridge);
|
||||
|
||||
dict_T *dict = get_vim_var_dict(VV_EVENT);
|
||||
tv_dict_add_nr(dict, S_LEN("chan"), 0);
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
apply_autocmds(EVENT_UIATTACH, NULL, NULL, false, curbuf);
|
||||
tv_dict_clear(dict);
|
||||
ui_attach_impl(&rv->bridge, 0);
|
||||
|
||||
return &rv->bridge;
|
||||
}
|
||||
@@ -115,13 +107,7 @@ static void ui_bridge_stop(UI *b)
|
||||
{
|
||||
// Detach bridge first, so that "stop" is the last event the TUI loop
|
||||
// receives from the main thread. #8041
|
||||
ui_detach_impl(b);
|
||||
|
||||
dict_T *dict = get_vim_var_dict(VV_EVENT);
|
||||
tv_dict_add_nr(dict, S_LEN("chan"), 0);
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
apply_autocmds(EVENT_UIDETACH, NULL, NULL, false, curbuf);
|
||||
tv_dict_clear(dict);
|
||||
ui_detach_impl(b, 0);
|
||||
|
||||
UIBridgeData *bridge = (UIBridgeData *)b;
|
||||
bool stopped = bridge->stopped = false;
|
||||
|
@@ -83,7 +83,7 @@ void ui_comp_init(void)
|
||||
kv_push(layers, &default_grid);
|
||||
curgrid = &default_grid;
|
||||
|
||||
ui_attach_impl(compositor);
|
||||
ui_attach_impl(compositor, 0);
|
||||
}
|
||||
|
||||
void ui_comp_syn_init(void)
|
||||
|
Reference in New Issue
Block a user