mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ui: Add update_fg/update_bg methods
It is necessary to notify the UI when the default background/foreground colors change in order to render correctly.
This commit is contained in:
parent
209b5ed6ba
commit
4f5f246a95
@ -67,6 +67,8 @@ Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args,
|
||||
ui->put = remote_ui_put;
|
||||
ui->bell = remote_ui_bell;
|
||||
ui->visual_bell = remote_ui_visual_bell;
|
||||
ui->update_fg = remote_ui_update_fg;
|
||||
ui->update_bg = remote_ui_update_bg;
|
||||
ui->flush = remote_ui_flush;
|
||||
ui->suspend = remote_ui_suspend;
|
||||
pmap_put(uint64_t)(connected_uis, channel_id, ui);
|
||||
@ -266,6 +268,20 @@ static void remote_ui_visual_bell(UI *ui)
|
||||
push_call(ui, "visual_bell", args);
|
||||
}
|
||||
|
||||
static void remote_ui_update_fg(UI *ui, int fg)
|
||||
{
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
ADD(args, INTEGER_OBJ(fg));
|
||||
push_call(ui, "update_fg", args);
|
||||
}
|
||||
|
||||
static void remote_ui_update_bg(UI *ui, int bg)
|
||||
{
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
ADD(args, INTEGER_OBJ(bg));
|
||||
push_call(ui, "update_bg", args);
|
||||
}
|
||||
|
||||
static void remote_ui_flush(UI *ui)
|
||||
{
|
||||
UIData *data = ui->data;
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/syntax_defs.h"
|
||||
#include "nvim/term.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/os/time.h"
|
||||
|
||||
@ -6528,6 +6529,7 @@ do_highlight (
|
||||
|
||||
if (is_normal_group) {
|
||||
normal_fg = HL_TABLE()[idx].sg_rgb_fg;
|
||||
ui_fg_updated();
|
||||
}
|
||||
} else if (STRCMP(key, "GUIBG") == 0) {
|
||||
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
|
||||
@ -6546,6 +6548,7 @@ do_highlight (
|
||||
|
||||
if (is_normal_group) {
|
||||
normal_bg = HL_TABLE()[idx].sg_rgb_bg;
|
||||
ui_bg_updated();
|
||||
}
|
||||
} else if (STRCMP(key, "GUISP") == 0) {
|
||||
// Ignored
|
||||
|
@ -113,6 +113,18 @@ void ui_write(uint8_t *s, int len)
|
||||
free(tofree);
|
||||
}
|
||||
|
||||
void ui_fg_updated(void)
|
||||
{
|
||||
UI_CALL(update_fg, normal_fg);
|
||||
UI_CALL(flush);
|
||||
}
|
||||
|
||||
void ui_bg_updated(void)
|
||||
{
|
||||
UI_CALL(update_bg, normal_bg);
|
||||
UI_CALL(flush);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the machine has job control, use it to suspend the program,
|
||||
* otherwise fake it by starting a new shell.
|
||||
@ -167,6 +179,8 @@ void ui_cursor_shape(void)
|
||||
|
||||
void ui_resize(int width, int height)
|
||||
{
|
||||
ui_fg_updated();
|
||||
ui_bg_updated();
|
||||
sr.top = 0;
|
||||
sr.bot = height - 1;
|
||||
sr.left = 0;
|
||||
|
@ -32,6 +32,8 @@ struct ui_t {
|
||||
void (*bell)(UI *ui);
|
||||
void (*visual_bell)(UI *ui);
|
||||
void (*flush)(UI *ui);
|
||||
void (*update_fg)(UI *ui, int fg);
|
||||
void (*update_bg)(UI *ui, int bg);
|
||||
void (*suspend)(UI *ui);
|
||||
};
|
||||
|
||||
|
@ -278,6 +278,14 @@ function Screen:_handle_visual_bell()
|
||||
self._visual_bell = true
|
||||
end
|
||||
|
||||
function Screen:_handle_update_fg(fg)
|
||||
self._fg = fg
|
||||
end
|
||||
|
||||
function Screen:_handle_update_bg(bg)
|
||||
self._bg = bg
|
||||
end
|
||||
|
||||
function Screen:_handle_suspend()
|
||||
self._suspended = true
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user