mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
tui: rework deferred-termcodes implementation
Try another approach to defer the termcodes. Seems less janky, but still
not perfect.
ref #7664
ref #7649
ref #7664
ref 27f9b1c7b0
This commit is contained in:
@@ -563,6 +563,9 @@ int main(int argc, char **argv)
|
||||
(void)eval_has_provider("clipboard");
|
||||
}
|
||||
|
||||
if (!headless_mode) {
|
||||
ui_builtin_after_startup();
|
||||
}
|
||||
TIME_MSG("before starting main loop");
|
||||
ILOG("starting main loop");
|
||||
|
||||
|
@@ -126,6 +126,7 @@ UI *tui_start(void)
|
||||
{
|
||||
UI *ui = xcalloc(1, sizeof(UI));
|
||||
ui->stop = tui_stop;
|
||||
ui->after_startup = tui_after_startup;
|
||||
ui->rgb = p_tgc;
|
||||
ui->resize = tui_resize;
|
||||
ui->clear = tui_clear;
|
||||
@@ -174,13 +175,7 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index,
|
||||
static void terminfo_after_startup_event(void **argv)
|
||||
{
|
||||
UI *ui = argv[0];
|
||||
bool defer = argv[1] != NULL; // clever(?) boolean without malloc() dance.
|
||||
TUIData *data = ui->data;
|
||||
if (defer) { // We're on the main-loop. Now forward to the TUI loop.
|
||||
loop_schedule(data->loop,
|
||||
event_create(terminfo_after_startup_event, 2, ui, NULL));
|
||||
return;
|
||||
}
|
||||
// Enable bracketed paste
|
||||
unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste);
|
||||
// Enable focus reporting
|
||||
@@ -278,9 +273,13 @@ static void terminfo_start(UI *ui)
|
||||
uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0);
|
||||
uv_pipe_open(&data->output_handle.pipe, data->out_fd);
|
||||
}
|
||||
}
|
||||
|
||||
loop_schedule(&main_loop,
|
||||
event_create(terminfo_after_startup_event, 2, ui, ui));
|
||||
static void tui_after_startup(UI *ui)
|
||||
{
|
||||
TUIData *data = ui->data;
|
||||
loop_schedule(data->loop,
|
||||
event_create(terminfo_after_startup_event, 1, ui));
|
||||
}
|
||||
|
||||
static void terminfo_stop(UI *ui)
|
||||
|
@@ -138,6 +138,14 @@ void ui_builtin_start(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Immediately after VimEnter event.
|
||||
void ui_builtin_after_startup(void)
|
||||
{
|
||||
#ifdef FEAT_TUI
|
||||
UI_CALL(after_startup);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ui_builtin_stop(void)
|
||||
{
|
||||
UI_CALL(stop);
|
||||
|
@@ -31,13 +31,12 @@ struct ui_t {
|
||||
bool ui_ext[UI_WIDGETS]; ///< Externalized widgets
|
||||
int width, height;
|
||||
void *data;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "ui_events.generated.h"
|
||||
#endif
|
||||
|
||||
void (*event)(UI *ui, char *name, Array args, bool *args_consumed);
|
||||
void (*stop)(UI *ui);
|
||||
void (*after_startup)(UI *ui);
|
||||
};
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
|
@@ -42,6 +42,7 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
|
||||
rv->ui = ui;
|
||||
rv->bridge.rgb = ui->rgb;
|
||||
rv->bridge.stop = ui_bridge_stop;
|
||||
rv->bridge.after_startup = ui_bridge_after_startup;
|
||||
rv->bridge.resize = ui_bridge_resize;
|
||||
rv->bridge.clear = ui_bridge_clear;
|
||||
rv->bridge.eol_clear = ui_bridge_eol_clear;
|
||||
@@ -106,6 +107,16 @@ static void ui_thread_run(void *data)
|
||||
bridge->ui_main(bridge, bridge->ui);
|
||||
}
|
||||
|
||||
static void ui_bridge_after_startup(UI *b)
|
||||
{
|
||||
UI_BRIDGE_CALL(b, after_startup, 1, b);
|
||||
}
|
||||
static void ui_bridge_after_startup_event(void **argv)
|
||||
{
|
||||
UI *ui = UI(argv[0]);
|
||||
ui->after_startup(ui);
|
||||
}
|
||||
|
||||
static void ui_bridge_stop(UI *b)
|
||||
{
|
||||
UIBridgeData *bridge = (UIBridgeData *)b;
|
||||
|
Reference in New Issue
Block a user