mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ui: Add 'rgb' parameter to ui_attach
When set to false, nvim will send cterm color numbers with `highlight_set`.
This commit is contained in:
parent
631099d02a
commit
29bc6dfabd
@ -61,8 +61,9 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
|
|||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size != 2 || args.items[0].type != kObjectTypeInteger
|
if (args.size != 3 || args.items[0].type != kObjectTypeInteger
|
||||||
|| args.items[1].type != kObjectTypeInteger
|
|| args.items[1].type != kObjectTypeInteger
|
||||||
|
|| args.items[2].type != kObjectTypeBoolean
|
||||||
|| args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) {
|
|| args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) {
|
||||||
api_set_error(error, Validation,
|
api_set_error(error, Validation,
|
||||||
_("Arguments must be a pair of positive integers "
|
_("Arguments must be a pair of positive integers "
|
||||||
@ -75,6 +76,7 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
|
|||||||
UI *ui = xcalloc(1, sizeof(UI));
|
UI *ui = xcalloc(1, sizeof(UI));
|
||||||
ui->width = (int)args.items[0].data.integer;
|
ui->width = (int)args.items[0].data.integer;
|
||||||
ui->height = (int)args.items[1].data.integer;
|
ui->height = (int)args.items[1].data.integer;
|
||||||
|
ui->rgb = args.items[2].data.boolean;
|
||||||
ui->data = data;
|
ui->data = data;
|
||||||
ui->resize = remote_ui_resize;
|
ui->resize = remote_ui_resize;
|
||||||
ui->clear = remote_ui_clear;
|
ui->clear = remote_ui_clear;
|
||||||
|
@ -6439,8 +6439,7 @@ do_highlight (
|
|||||||
HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
|
HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
|
||||||
}
|
}
|
||||||
color &= 7; /* truncate to 8 colors */
|
color &= 7; /* truncate to 8 colors */
|
||||||
} else if (t_colors == 16 || t_colors == 88
|
} else if (t_colors == 16 || t_colors == 88 || t_colors == 256) {
|
||||||
|| t_colors == 256) {
|
|
||||||
/*
|
/*
|
||||||
* Guess: if the termcap entry ends in 'm', it is
|
* Guess: if the termcap entry ends in 'm', it is
|
||||||
* probably an xterm-like terminal. Use the changed
|
* probably an xterm-like terminal. Use the changed
|
||||||
|
@ -60,9 +60,6 @@ static struct {
|
|||||||
int top, bot, left, right;
|
int top, bot, left, right;
|
||||||
} sr;
|
} sr;
|
||||||
static int current_highlight_mask = 0;
|
static int current_highlight_mask = 0;
|
||||||
static HlAttrs current_attrs = {
|
|
||||||
false, false, false, false, false, -1, -1
|
|
||||||
};
|
|
||||||
static bool cursor_enabled = true;
|
static bool cursor_enabled = true;
|
||||||
static int height, width;
|
static int height, width;
|
||||||
|
|
||||||
@ -187,13 +184,8 @@ void ui_resize(int new_width, int new_height)
|
|||||||
width = new_width;
|
width = new_width;
|
||||||
height = new_height;
|
height = new_height;
|
||||||
|
|
||||||
if (normal_fg != -1) {
|
UI_CALL(update_fg, (ui->rgb ? normal_fg : cterm_normal_fg_color - 1));
|
||||||
UI_CALL(update_fg, normal_fg);
|
UI_CALL(update_bg, (ui->rgb ? normal_bg : cterm_normal_bg_color - 1));
|
||||||
}
|
|
||||||
|
|
||||||
if (normal_bg != -1) {
|
|
||||||
UI_CALL(update_bg, normal_bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
sr.top = 0;
|
sr.top = 0;
|
||||||
sr.bot = height - 1;
|
sr.bot = height - 1;
|
||||||
@ -314,8 +306,7 @@ static void highlight_start(int mask)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_highlight_args(current_highlight_mask, ¤t_attrs);
|
set_highlight_args(current_highlight_mask);
|
||||||
UI_CALL(highlight_set, current_attrs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void highlight_stop(int mask)
|
static void highlight_stop(int mask)
|
||||||
@ -328,12 +319,12 @@ static void highlight_stop(int mask)
|
|||||||
current_highlight_mask &= ~mask;
|
current_highlight_mask &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_highlight_args(current_highlight_mask, ¤t_attrs);
|
set_highlight_args(current_highlight_mask);
|
||||||
UI_CALL(highlight_set, current_attrs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_highlight_args(int mask, HlAttrs *attrs)
|
static void set_highlight_args(int mask)
|
||||||
{
|
{
|
||||||
|
HlAttrs rgb_attrs = { false, false, false, false, false, -1, -1 };
|
||||||
attrentry_T *aep = NULL;
|
attrentry_T *aep = NULL;
|
||||||
|
|
||||||
if (mask > HL_ALL) {
|
if (mask > HL_ALL) {
|
||||||
@ -341,13 +332,32 @@ static void set_highlight_args(int mask, HlAttrs *attrs)
|
|||||||
mask = aep ? aep->ae_attr : 0;
|
mask = aep ? aep->ae_attr : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs->bold = mask & HL_BOLD;
|
rgb_attrs.bold = mask & HL_BOLD;
|
||||||
attrs->underline = mask & HL_UNDERLINE;
|
rgb_attrs.underline = mask & HL_UNDERLINE;
|
||||||
attrs->undercurl = mask & HL_UNDERCURL;
|
rgb_attrs.undercurl = mask & HL_UNDERCURL;
|
||||||
attrs->italic = mask & HL_ITALIC;
|
rgb_attrs.italic = mask & HL_ITALIC;
|
||||||
attrs->reverse = mask & (HL_INVERSE | HL_STANDOUT);
|
rgb_attrs.reverse = mask & (HL_INVERSE | HL_STANDOUT);
|
||||||
attrs->foreground = aep && aep->fg_color >= 0 ? aep->fg_color : normal_fg;
|
HlAttrs cterm_attrs = rgb_attrs;
|
||||||
attrs->background = aep && aep->bg_color >= 0 ? aep->bg_color : normal_bg;
|
|
||||||
|
if (aep) {
|
||||||
|
if (aep->fg_color != normal_fg) {
|
||||||
|
rgb_attrs.foreground = aep->fg_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aep->bg_color != normal_bg) {
|
||||||
|
rgb_attrs.background = aep->bg_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cterm_normal_fg_color != aep->ae_u.cterm.fg_color) {
|
||||||
|
cterm_attrs.foreground = aep->ae_u.cterm.fg_color - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cterm_normal_bg_color != aep->ae_u.cterm.bg_color) {
|
||||||
|
cterm_attrs.background = aep->ae_u.cterm.bg_color - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UI_CALL(highlight_set, (ui->rgb ? rgb_attrs : cterm_attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_abstract_ui_codes(uint8_t *ptr, int len)
|
static void parse_abstract_ui_codes(uint8_t *ptr, int len)
|
||||||
|
@ -13,6 +13,7 @@ typedef struct {
|
|||||||
typedef struct ui_t UI;
|
typedef struct ui_t UI;
|
||||||
|
|
||||||
struct ui_t {
|
struct ui_t {
|
||||||
|
bool rgb;
|
||||||
int width, height;
|
int width, height;
|
||||||
void *data;
|
void *data;
|
||||||
void (*resize)(UI *ui, int rows, int columns);
|
void (*resize)(UI *ui, int rows, int columns);
|
||||||
|
@ -115,7 +115,7 @@ function Screen:set_default_attr_ids(attr_ids)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Screen:attach()
|
function Screen:attach()
|
||||||
request('ui_attach', self._width, self._height)
|
request('ui_attach', self._width, self._height, true)
|
||||||
self._suspended = false
|
self._suspended = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user