From 4f5f246a958e66e04a5d62b3bf0d8986afb51c09 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 12 Dec 2014 16:25:11 -0300 Subject: 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. --- src/nvim/syntax.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f35da39bb3..8f686ca59f 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -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 -- cgit From 748920d505e2997c79e08d87d09c564eaea23a2f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 12 Dec 2014 16:29:25 -0300 Subject: ui: Test for abstract_ui whenever a minimal t_colors value is required t_colors should not be checked when abstract_ui is active, because nvim UI is not limited to a terminal. --- src/nvim/syntax.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 8f686ca59f..68589522c4 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5984,7 +5984,7 @@ init_highlight ( * With 8 colors brown is equal to yellow, need to use black for Search fg * to avoid Statement highlighted text disappears. * Clear the attributes, needed when changing the t_Co value. */ - if (t_colors > 8) + if (abstract_ui || t_colors > 8) do_highlight( (char_u *)(*p_bg == 'l' ? "Visual cterm=NONE ctermbg=LightGrey" @@ -6449,7 +6449,7 @@ do_highlight ( HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; } color &= 7; /* truncate to 8 colors */ - } else if (t_colors == 16 || t_colors == 88 + } else if (abstract_ui || t_colors == 16 || t_colors == 88 || t_colors == 256) { /* * Guess: if the termcap entry ends in 'm', it is @@ -6497,7 +6497,7 @@ do_highlight ( if (color >= 0) { if (termcap_active) term_bg_color(color); - if (t_colors < 16) + if (!abstract_ui && t_colors < 16) i = (color == 0 || color == 4); else i = (color < 7 || color == 8); @@ -6873,7 +6873,7 @@ int hl_combine_attr(int char_attr, int prim_attr) if (char_attr <= HL_ALL && prim_attr <= HL_ALL) return char_attr | prim_attr; - if (t_colors > 1) { + if (abstract_ui || t_colors > 1) { if (char_attr > HL_ALL) char_aep = syn_cterm_attr2entry(char_attr); if (char_aep != NULL) @@ -6937,7 +6937,7 @@ int syn_attr2attr(int attr) { attrentry_T *aep; - if (t_colors > 1) + if (abstract_ui || t_colors > 1) aep = syn_cterm_attr2entry(attr); else aep = syn_term_attr2entry(attr); @@ -7364,7 +7364,7 @@ int syn_id2attr(int hl_id) hl_id = syn_get_final_id(hl_id); sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ - if (t_colors > 1) + if (abstract_ui || t_colors > 1) attr = sgp->sg_cterm_attr; else attr = sgp->sg_term_attr; -- cgit From 213c3c3e53459a77c77166cda85ba619e7eb2eb1 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 13 Dec 2014 12:58:06 -0300 Subject: ui: Fix ui resizing and change some method names --- src/nvim/syntax.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 68589522c4..c2fb34cde0 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6529,7 +6529,6 @@ 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)) { @@ -6548,7 +6547,6 @@ do_highlight ( if (is_normal_group) { normal_bg = HL_TABLE()[idx].sg_rgb_bg; - ui_bg_updated(); } } else if (STRCMP(key, "GUISP") == 0) { // Ignored @@ -6645,6 +6643,10 @@ do_highlight ( if (is_normal_group) { HL_TABLE()[idx].sg_term_attr = 0; HL_TABLE()[idx].sg_cterm_attr = 0; + if (abstract_ui) { + // If the normal group has changed, it is simpler to refresh every UI + ui_refresh(); + } } else set_hl_attr(idx); HL_TABLE()[idx].sg_scriptID = current_SID; -- cgit From c1252a5615d9e69cac50570e8de70e5036a67908 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 2 Jan 2015 21:03:25 -0300 Subject: syntax: Take rgb fg/bg when allocating cterm attr number --- src/nvim/syntax.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index c2fb34cde0..884a563fea 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7209,9 +7209,10 @@ set_hl_attr ( * For the color term mode: If there are other than "normal" * highlighting attributes, need to allocate an attr number. */ - if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0) + if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0 + && sgp->sg_rgb_fg == -1 && sgp->sg_rgb_bg == -1) { sgp->sg_cterm_attr = sgp->sg_cterm; - else { + } else { at_en.ae_attr = abstract_ui ? sgp->sg_gui : sgp->sg_cterm; at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; -- cgit From 74c247f75baec5778296adf164831c5ffea0fb88 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 8 Jan 2015 11:23:45 -0300 Subject: ui: Add 'rgb' parameter to ui_attach When set to false, nvim will send cterm color numbers with `highlight_set`. --- src/nvim/syntax.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 884a563fea..805f808449 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6432,7 +6432,9 @@ do_highlight ( /* Use the _16 table to check if its a valid color name. */ color = color_numbers_16[i]; if (color >= 0) { - if (t_colors == 8) { + if (abstract_ui) { + color = color_numbers_256[i]; + } else if (t_colors == 8) { /* t_Co is 8: use the 8 colors table */ #if defined(__QNXNTO__) color = color_numbers_8_qansi[i]; @@ -6449,8 +6451,7 @@ do_highlight ( HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; } color &= 7; /* truncate to 8 colors */ - } else if (abstract_ui || t_colors == 16 || t_colors == 88 - || t_colors == 256) { + } else if (t_colors == 16 || t_colors == 88 || t_colors == 256) { /* * Guess: if the termcap entry ends in 'm', it is * probably an xterm-like terminal. Use the changed -- cgit From 62c1daffe028185030d0d8e95dc2c6532457b4fa Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 12 Jan 2015 10:28:32 -0300 Subject: syntax: Refresh UI when the color scheme changes --- src/nvim/syntax.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 805f808449..e5f7662a32 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6037,6 +6037,7 @@ int load_colors(char_u *name) apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); recursive = FALSE; + ui_refresh(); return retval; } -- cgit