Mercurial > vim
comparison src/syntax.c @ 8969:c83e2c1e7f2b v7.4.1770
commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 21 21:10:14 2016 +0200
patch 7.4.1770
Problem: Cannot use true color in the terminal.
Solution: Add the 'guicolors' option. (Nikolai Pavlov)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 21 Apr 2016 21:15:07 +0200 |
parents | 50d9fb580ffe |
children | 9c097bfad637 |
comparison
equal
deleted
inserted
replaced
8968:4794235d1bb0 | 8969:c83e2c1e7f2b |
---|---|
31 int sg_cterm; /* "cterm=" highlighting attr */ | 31 int sg_cterm; /* "cterm=" highlighting attr */ |
32 int sg_cterm_bold; /* bold attr was set for light color */ | 32 int sg_cterm_bold; /* bold attr was set for light color */ |
33 int sg_cterm_fg; /* terminal fg color number + 1 */ | 33 int sg_cterm_fg; /* terminal fg color number + 1 */ |
34 int sg_cterm_bg; /* terminal bg color number + 1 */ | 34 int sg_cterm_bg; /* terminal bg color number + 1 */ |
35 int sg_cterm_attr; /* Screen attr for color term mode */ | 35 int sg_cterm_attr; /* Screen attr for color term mode */ |
36 #ifdef FEAT_GUI | |
37 /* for when using the GUI */ | 36 /* for when using the GUI */ |
37 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) | |
38 guicolor_T sg_gui_fg; /* GUI foreground color handle */ | 38 guicolor_T sg_gui_fg; /* GUI foreground color handle */ |
39 guicolor_T sg_gui_bg; /* GUI background color handle */ | 39 guicolor_T sg_gui_bg; /* GUI background color handle */ |
40 #endif | |
41 #ifdef FEAT_GUI | |
40 guicolor_T sg_gui_sp; /* GUI special color handle */ | 42 guicolor_T sg_gui_sp; /* GUI special color handle */ |
41 GuiFont sg_font; /* GUI font handle */ | 43 GuiFont sg_font; /* GUI font handle */ |
42 #ifdef FEAT_XFONTSET | 44 #ifdef FEAT_XFONTSET |
43 GuiFontset sg_fontset; /* GUI fontset handle */ | 45 GuiFontset sg_fontset; /* GUI fontset handle */ |
44 #endif | 46 #endif |
95 static int syn_add_group(char_u *name); | 97 static int syn_add_group(char_u *name); |
96 static int syn_list_header(int did_header, int outlen, int id); | 98 static int syn_list_header(int did_header, int outlen, int id); |
97 static int hl_has_settings(int idx, int check_link); | 99 static int hl_has_settings(int idx, int check_link); |
98 static void highlight_clear(int idx); | 100 static void highlight_clear(int idx); |
99 | 101 |
102 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) | |
103 static void gui_do_one_color(int idx, int do_menu, int do_tooltip); | |
104 static guicolor_T color_name2handle(char_u *name); | |
105 #endif | |
100 #ifdef FEAT_GUI | 106 #ifdef FEAT_GUI |
101 static void gui_do_one_color(int idx, int do_menu, int do_tooltip); | |
102 static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip); | 107 static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip); |
103 static guicolor_T color_name2handle(char_u *name); | |
104 static GuiFont font_name2handle(char_u *name); | 108 static GuiFont font_name2handle(char_u *name); |
105 # ifdef FEAT_XFONTSET | 109 # ifdef FEAT_XFONTSET |
106 static GuiFontset fontset_name2handle(char_u *name, int fixed_width); | 110 static GuiFontset fontset_name2handle(char_u *name, int fixed_width); |
107 # endif | 111 # endif |
108 static void hl_do_font(int idx, char_u *arg, int do_normal, int do_menu, int do_tooltip, int free_font); | 112 static void hl_do_font(int idx, char_u *arg, int do_normal, int do_menu, int do_tooltip, int free_font); |
7331 * Clear all default highlight groups and load the defaults. | 7335 * Clear all default highlight groups and load the defaults. |
7332 */ | 7336 */ |
7333 for (idx = 0; idx < highlight_ga.ga_len; ++idx) | 7337 for (idx = 0; idx < highlight_ga.ga_len; ++idx) |
7334 highlight_clear(idx); | 7338 highlight_clear(idx); |
7335 init_highlight(TRUE, TRUE); | 7339 init_highlight(TRUE, TRUE); |
7336 #ifdef FEAT_GUI | 7340 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
7337 if (gui.in_use) | 7341 if (USE_24BIT) |
7338 highlight_gui_started(); | 7342 highlight_gui_started(); |
7339 #endif | 7343 #endif |
7340 highlight_changed(); | 7344 highlight_changed(); |
7341 redraw_later_clear(); | 7345 redraw_later_clear(); |
7342 return; | 7346 return; |
7786 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) | 7790 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) |
7787 { | 7791 { |
7788 if (!init) | 7792 if (!init) |
7789 HL_TABLE()[idx].sg_set |= SG_GUI; | 7793 HL_TABLE()[idx].sg_set |= SG_GUI; |
7790 | 7794 |
7791 # ifdef FEAT_GUI | 7795 # if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
7792 /* In GUI guifg colors are only used when recognized */ | 7796 /* In GUI guifg colors are only used when recognized */ |
7793 i = color_name2handle(arg); | 7797 i = color_name2handle(arg); |
7794 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) | 7798 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 |
7799 # ifdef FEAT_GUI | |
7800 || !(USE_24BIT) | |
7801 # else | |
7802 || !p_guicolors | |
7803 # endif | |
7804 ) | |
7795 { | 7805 { |
7796 HL_TABLE()[idx].sg_gui_fg = i; | 7806 HL_TABLE()[idx].sg_gui_fg = i; |
7797 # endif | 7807 # endif |
7798 vim_free(HL_TABLE()[idx].sg_gui_fg_name); | 7808 vim_free(HL_TABLE()[idx].sg_gui_fg_name); |
7799 if (STRCMP(arg, "NONE")) | 7809 if (STRCMP(arg, "NONE")) |
7800 HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg); | 7810 HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg); |
7801 else | 7811 else |
7802 HL_TABLE()[idx].sg_gui_fg_name = NULL; | 7812 HL_TABLE()[idx].sg_gui_fg_name = NULL; |
7803 # ifdef FEAT_GUI | 7813 # if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
7804 # ifdef FEAT_GUI_X11 | 7814 # ifdef FEAT_GUI_X11 |
7805 if (is_menu_group) | 7815 if (is_menu_group) |
7806 gui.menu_fg_pixel = i; | 7816 gui.menu_fg_pixel = i; |
7807 if (is_scrollbar_group) | 7817 if (is_scrollbar_group) |
7808 gui.scroll_fg_pixel = i; | 7818 gui.scroll_fg_pixel = i; |
7823 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) | 7833 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) |
7824 { | 7834 { |
7825 if (!init) | 7835 if (!init) |
7826 HL_TABLE()[idx].sg_set |= SG_GUI; | 7836 HL_TABLE()[idx].sg_set |= SG_GUI; |
7827 | 7837 |
7828 # ifdef FEAT_GUI | 7838 # if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
7829 /* In GUI guifg colors are only used when recognized */ | 7839 /* In GUI guifg colors are only used when recognized */ |
7830 i = color_name2handle(arg); | 7840 i = color_name2handle(arg); |
7831 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) | 7841 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT) |
7832 { | 7842 { |
7833 HL_TABLE()[idx].sg_gui_bg = i; | 7843 HL_TABLE()[idx].sg_gui_bg = i; |
7834 # endif | 7844 # endif |
7835 vim_free(HL_TABLE()[idx].sg_gui_bg_name); | 7845 vim_free(HL_TABLE()[idx].sg_gui_bg_name); |
7836 if (STRCMP(arg, "NONE") != 0) | 7846 if (STRCMP(arg, "NONE") != 0) |
7837 HL_TABLE()[idx].sg_gui_bg_name = vim_strsave(arg); | 7847 HL_TABLE()[idx].sg_gui_bg_name = vim_strsave(arg); |
7838 else | 7848 else |
7839 HL_TABLE()[idx].sg_gui_bg_name = NULL; | 7849 HL_TABLE()[idx].sg_gui_bg_name = NULL; |
7840 # ifdef FEAT_GUI | 7850 # if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
7841 # ifdef FEAT_GUI_X11 | 7851 # ifdef FEAT_GUI_X11 |
7842 if (is_menu_group) | 7852 if (is_menu_group) |
7843 gui.menu_bg_pixel = i; | 7853 gui.menu_bg_pixel = i; |
7844 if (is_scrollbar_group) | 7854 if (is_scrollbar_group) |
7845 gui.scroll_bg_pixel = i; | 7855 gui.scroll_bg_pixel = i; |
7995 HL_TABLE()[idx].sg_gui_attr = 0; | 8005 HL_TABLE()[idx].sg_gui_attr = 0; |
7996 /* | 8006 /* |
7997 * Need to update all groups, because they might be using "bg" | 8007 * Need to update all groups, because they might be using "bg" |
7998 * and/or "fg", which have been changed now. | 8008 * and/or "fg", which have been changed now. |
7999 */ | 8009 */ |
8000 if (gui.in_use) | 8010 #endif |
8011 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) | |
8012 if (USE_24BIT) | |
8001 highlight_gui_started(); | 8013 highlight_gui_started(); |
8002 #endif | 8014 #endif |
8003 } | 8015 } |
8004 #ifdef FEAT_GUI_X11 | 8016 #ifdef FEAT_GUI_X11 |
8005 # ifdef FEAT_MENU | 8017 # ifdef FEAT_MENU |
8066 mch_set_normal_colors(); | 8078 mch_set_normal_colors(); |
8067 #else | 8079 #else |
8068 cterm_normal_fg_color = 0; | 8080 cterm_normal_fg_color = 0; |
8069 cterm_normal_fg_bold = 0; | 8081 cterm_normal_fg_bold = 0; |
8070 cterm_normal_bg_color = 0; | 8082 cterm_normal_bg_color = 0; |
8083 # ifdef FEAT_TERMTRUECOLOR | |
8084 cterm_normal_fg_gui_color = INVALCOLOR; | |
8085 cterm_normal_bg_gui_color = INVALCOLOR; | |
8086 # endif | |
8071 #endif | 8087 #endif |
8072 } | 8088 } |
8073 | 8089 |
8074 /* | 8090 /* |
8075 * Return TRUE if highlight group "idx" has any settings. | 8091 * Return TRUE if highlight group "idx" has any settings. |
8116 vim_free(HL_TABLE()[idx].sg_gui_bg_name); | 8132 vim_free(HL_TABLE()[idx].sg_gui_bg_name); |
8117 HL_TABLE()[idx].sg_gui_bg_name = NULL; | 8133 HL_TABLE()[idx].sg_gui_bg_name = NULL; |
8118 vim_free(HL_TABLE()[idx].sg_gui_sp_name); | 8134 vim_free(HL_TABLE()[idx].sg_gui_sp_name); |
8119 HL_TABLE()[idx].sg_gui_sp_name = NULL; | 8135 HL_TABLE()[idx].sg_gui_sp_name = NULL; |
8120 #endif | 8136 #endif |
8121 #ifdef FEAT_GUI | 8137 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
8122 HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; | 8138 HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; |
8123 HL_TABLE()[idx].sg_gui_bg = INVALCOLOR; | 8139 HL_TABLE()[idx].sg_gui_bg = INVALCOLOR; |
8140 #endif | |
8141 #ifdef FEAT_GUI | |
8124 HL_TABLE()[idx].sg_gui_sp = INVALCOLOR; | 8142 HL_TABLE()[idx].sg_gui_sp = INVALCOLOR; |
8125 gui_mch_free_font(HL_TABLE()[idx].sg_font); | 8143 gui_mch_free_font(HL_TABLE()[idx].sg_font); |
8126 HL_TABLE()[idx].sg_font = NOFONT; | 8144 HL_TABLE()[idx].sg_font = NOFONT; |
8127 # ifdef FEAT_XFONTSET | 8145 # ifdef FEAT_XFONTSET |
8128 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); | 8146 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); |
8138 if (HL_TABLE()[idx].sg_link == 0) | 8156 if (HL_TABLE()[idx].sg_link == 0) |
8139 HL_TABLE()[idx].sg_scriptID = 0; | 8157 HL_TABLE()[idx].sg_scriptID = 0; |
8140 #endif | 8158 #endif |
8141 } | 8159 } |
8142 | 8160 |
8143 #if defined(FEAT_GUI) || defined(PROTO) | 8161 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) || defined(PROTO) |
8144 /* | 8162 /* |
8145 * Set the normal foreground and background colors according to the "Normal" | 8163 * Set the normal foreground and background colors according to the "Normal" |
8146 * highlighting group. For X11 also set "Menu", "Scrollbar", and | 8164 * highlighting group. For X11 also set "Menu", "Scrollbar", and |
8147 * "Tooltip" colors. | 8165 * "Tooltip" colors. |
8148 */ | 8166 */ |
8149 void | 8167 void |
8150 set_normal_colors(void) | 8168 set_normal_colors(void) |
8151 { | 8169 { |
8152 if (set_group_colors((char_u *)"Normal", | 8170 #ifdef FEAT_GUI |
8153 &gui.norm_pixel, &gui.back_pixel, | 8171 # ifdef FEAT_TERMTRUECOLOR |
8154 FALSE, TRUE, FALSE)) | 8172 if (gui.in_use) |
8155 { | |
8156 gui_mch_new_colors(); | |
8157 must_redraw = CLEAR; | |
8158 } | |
8159 #ifdef FEAT_GUI_X11 | |
8160 if (set_group_colors((char_u *)"Menu", | |
8161 &gui.menu_fg_pixel, &gui.menu_bg_pixel, | |
8162 TRUE, FALSE, FALSE)) | |
8163 { | |
8164 # ifdef FEAT_MENU | |
8165 gui_mch_new_menu_colors(); | |
8166 # endif | 8173 # endif |
8167 must_redraw = CLEAR; | 8174 { |
8168 } | 8175 if (set_group_colors((char_u *)"Normal", |
8169 # ifdef FEAT_BEVAL | 8176 &gui.norm_pixel, &gui.back_pixel, |
8170 if (set_group_colors((char_u *)"Tooltip", | 8177 FALSE, TRUE, FALSE)) |
8171 &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel, | 8178 { |
8172 FALSE, FALSE, TRUE)) | 8179 gui_mch_new_colors(); |
8173 { | 8180 must_redraw = CLEAR; |
8174 # ifdef FEAT_TOOLBAR | 8181 } |
8175 gui_mch_new_tooltip_colors(); | 8182 # ifdef FEAT_GUI_X11 |
8183 if (set_group_colors((char_u *)"Menu", | |
8184 &gui.menu_fg_pixel, &gui.menu_bg_pixel, | |
8185 TRUE, FALSE, FALSE)) | |
8186 { | |
8187 # ifdef FEAT_MENU | |
8188 gui_mch_new_menu_colors(); | |
8189 # endif | |
8190 must_redraw = CLEAR; | |
8191 } | |
8192 # ifdef FEAT_BEVAL | |
8193 if (set_group_colors((char_u *)"Tooltip", | |
8194 &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel, | |
8195 FALSE, FALSE, TRUE)) | |
8196 { | |
8197 # ifdef FEAT_TOOLBAR | |
8198 gui_mch_new_tooltip_colors(); | |
8199 # endif | |
8200 must_redraw = CLEAR; | |
8201 } | |
8202 # endif | |
8203 if (set_group_colors((char_u *)"Scrollbar", | |
8204 &gui.scroll_fg_pixel, &gui.scroll_bg_pixel, | |
8205 FALSE, FALSE, FALSE)) | |
8206 { | |
8207 gui_new_scrollbar_colors(); | |
8208 must_redraw = CLEAR; | |
8209 } | |
8176 # endif | 8210 # endif |
8177 must_redraw = CLEAR; | 8211 } |
8178 } | 8212 #endif |
8179 #endif | 8213 #ifdef FEAT_TERMTRUECOLOR |
8180 if (set_group_colors((char_u *)"Scrollbar", | 8214 # ifdef FEAT_GUI |
8181 &gui.scroll_fg_pixel, &gui.scroll_bg_pixel, | 8215 else |
8182 FALSE, FALSE, FALSE)) | 8216 # endif |
8183 { | 8217 { |
8184 gui_new_scrollbar_colors(); | 8218 int idx; |
8185 must_redraw = CLEAR; | 8219 |
8186 } | 8220 idx = syn_name2id((char_u *)"Normal") - 1; |
8187 #endif | 8221 if (idx >= 0) |
8188 } | 8222 { |
8189 | 8223 gui_do_one_color(idx, FALSE, FALSE); |
8224 | |
8225 if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR) | |
8226 { | |
8227 cterm_normal_fg_gui_color = HL_TABLE()[idx].sg_gui_fg; | |
8228 must_redraw = CLEAR; | |
8229 } | |
8230 if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR) | |
8231 { | |
8232 cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg; | |
8233 must_redraw = CLEAR; | |
8234 } | |
8235 } | |
8236 } | |
8237 #endif | |
8238 } | |
8239 #endif | |
8240 | |
8241 #if defined(FEAT_GUI) || defined(PROTO) | |
8190 /* | 8242 /* |
8191 * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". | 8243 * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". |
8192 */ | 8244 */ |
8193 static int | 8245 static int |
8194 set_group_colors( | 8246 set_group_colors( |
8294 { | 8346 { |
8295 vim_free(HL_TABLE()[id - 1].sg_gui_fg_name); | 8347 vim_free(HL_TABLE()[id - 1].sg_gui_fg_name); |
8296 HL_TABLE()[id - 1].sg_gui_fg_name = name; | 8348 HL_TABLE()[id - 1].sg_gui_fg_name = name; |
8297 } | 8349 } |
8298 } | 8350 } |
8299 } | |
8300 | |
8301 /* | |
8302 * Return the handle for a color name. | |
8303 * Returns INVALCOLOR when failed. | |
8304 */ | |
8305 static guicolor_T | |
8306 color_name2handle(char_u *name) | |
8307 { | |
8308 if (STRCMP(name, "NONE") == 0) | |
8309 return INVALCOLOR; | |
8310 | |
8311 if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) | |
8312 return gui.norm_pixel; | |
8313 if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) | |
8314 return gui.back_pixel; | |
8315 | |
8316 return gui_get_color(name); | |
8317 } | 8351 } |
8318 | 8352 |
8319 /* | 8353 /* |
8320 * Return the handle for a font name. | 8354 * Return the handle for a font name. |
8321 * Returns NOFONT when failed. | 8355 * Returns NOFONT when failed. |
8436 } | 8470 } |
8437 } | 8471 } |
8438 } | 8472 } |
8439 | 8473 |
8440 #endif /* FEAT_GUI */ | 8474 #endif /* FEAT_GUI */ |
8475 | |
8476 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) || defined(PROTO) | |
8477 /* | |
8478 * Return the handle for a color name. | |
8479 * Returns INVALCOLOR when failed. | |
8480 */ | |
8481 static guicolor_T | |
8482 color_name2handle(char_u *name) | |
8483 { | |
8484 if (STRCMP(name, "NONE") == 0) | |
8485 return INVALCOLOR; | |
8486 | |
8487 if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) | |
8488 { | |
8489 #if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) | |
8490 if (gui.in_use) | |
8491 #endif | |
8492 #ifdef FEAT_GUI | |
8493 return gui.norm_pixel; | |
8494 #endif | |
8495 #if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) | |
8496 else | |
8497 #endif | |
8498 #ifdef FEAT_TERMTRUECOLOR | |
8499 return cterm_normal_fg_gui_color; | |
8500 #endif | |
8501 } | |
8502 if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) | |
8503 { | |
8504 #if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) | |
8505 if (gui.in_use) | |
8506 #endif | |
8507 #ifdef FEAT_GUI | |
8508 return gui.back_pixel; | |
8509 #endif | |
8510 #if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) | |
8511 else | |
8512 #endif | |
8513 #ifdef FEAT_TERMTRUECOLOR | |
8514 return cterm_normal_bg_gui_color; | |
8515 #endif | |
8516 } | |
8517 | |
8518 return GUI_GET_COLOR(name); | |
8519 } | |
8520 #endif | |
8441 | 8521 |
8442 /* | 8522 /* |
8443 * Table with the specifications for an attribute number. | 8523 * Table with the specifications for an attribute number. |
8444 * Note that this table is used by ALL buffers. This is required because the | 8524 * Note that this table is used by ALL buffers. This is required because the |
8445 * GUI can redraw at any time for any buffer. | 8525 * GUI can redraw at any time for any buffer. |
8512 taep->ae_u.term.stop) == 0)) | 8592 taep->ae_u.term.stop) == 0)) |
8513 || (table == &cterm_attr_table | 8593 || (table == &cterm_attr_table |
8514 && aep->ae_u.cterm.fg_color | 8594 && aep->ae_u.cterm.fg_color |
8515 == taep->ae_u.cterm.fg_color | 8595 == taep->ae_u.cterm.fg_color |
8516 && aep->ae_u.cterm.bg_color | 8596 && aep->ae_u.cterm.bg_color |
8517 == taep->ae_u.cterm.bg_color) | 8597 == taep->ae_u.cterm.bg_color |
8518 )) | 8598 #ifdef FEAT_TERMTRUECOLOR |
8599 && aep->ae_u.cterm.fg_rgb | |
8600 == taep->ae_u.cterm.fg_rgb | |
8601 && aep->ae_u.cterm.bg_rgb | |
8602 == taep->ae_u.cterm.bg_rgb | |
8603 #endif | |
8604 | |
8605 ))) | |
8519 | 8606 |
8520 return i + ATTR_OFF; | 8607 return i + ATTR_OFF; |
8521 } | 8608 } |
8522 | 8609 |
8523 if (table->ga_len + ATTR_OFF > MAX_TYPENR) | 8610 if (table->ga_len + ATTR_OFF > MAX_TYPENR) |
8578 } | 8665 } |
8579 else if (table == &cterm_attr_table) | 8666 else if (table == &cterm_attr_table) |
8580 { | 8667 { |
8581 taep->ae_u.cterm.fg_color = aep->ae_u.cterm.fg_color; | 8668 taep->ae_u.cterm.fg_color = aep->ae_u.cterm.fg_color; |
8582 taep->ae_u.cterm.bg_color = aep->ae_u.cterm.bg_color; | 8669 taep->ae_u.cterm.bg_color = aep->ae_u.cterm.bg_color; |
8670 #ifdef FEAT_TERMTRUECOLOR | |
8671 taep->ae_u.cterm.fg_rgb = aep->ae_u.cterm.fg_rgb; | |
8672 taep->ae_u.cterm.bg_rgb = aep->ae_u.cterm.bg_rgb; | |
8673 #endif | |
8583 } | 8674 } |
8584 ++table->ga_len; | 8675 ++table->ga_len; |
8585 return (table->ga_len - 1 + ATTR_OFF); | 8676 return (table->ga_len - 1 + ATTR_OFF); |
8586 } | 8677 } |
8587 | 8678 |
8669 } | 8760 } |
8670 return get_attr_entry(&gui_attr_table, &new_en); | 8761 return get_attr_entry(&gui_attr_table, &new_en); |
8671 } | 8762 } |
8672 #endif | 8763 #endif |
8673 | 8764 |
8674 if (t_colors > 1) | 8765 if (IS_CTERM) |
8675 { | 8766 { |
8676 if (char_attr > HL_ALL) | 8767 if (char_attr > HL_ALL) |
8677 char_aep = syn_cterm_attr2entry(char_attr); | 8768 char_aep = syn_cterm_attr2entry(char_attr); |
8678 if (char_aep != NULL) | 8769 if (char_aep != NULL) |
8679 new_en = *char_aep; | 8770 new_en = *char_aep; |
8694 new_en.ae_attr |= spell_aep->ae_attr; | 8785 new_en.ae_attr |= spell_aep->ae_attr; |
8695 if (spell_aep->ae_u.cterm.fg_color > 0) | 8786 if (spell_aep->ae_u.cterm.fg_color > 0) |
8696 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color; | 8787 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color; |
8697 if (spell_aep->ae_u.cterm.bg_color > 0) | 8788 if (spell_aep->ae_u.cterm.bg_color > 0) |
8698 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; | 8789 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; |
8790 #ifdef FEAT_TERMTRUECOLOR | |
8791 if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR) | |
8792 new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb; | |
8793 if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR) | |
8794 new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb; | |
8795 #endif | |
8699 } | 8796 } |
8700 } | 8797 } |
8701 return get_attr_entry(&cterm_attr_table, &new_en); | 8798 return get_attr_entry(&cterm_attr_table, &new_en); |
8702 } | 8799 } |
8703 | 8800 |
8755 #ifdef FEAT_GUI | 8852 #ifdef FEAT_GUI |
8756 if (gui.in_use) | 8853 if (gui.in_use) |
8757 aep = syn_gui_attr2entry(attr); | 8854 aep = syn_gui_attr2entry(attr); |
8758 else | 8855 else |
8759 #endif | 8856 #endif |
8760 if (t_colors > 1) | 8857 if (IS_CTERM) |
8761 aep = syn_cterm_attr2entry(attr); | 8858 aep = syn_cterm_attr2entry(attr); |
8762 else | 8859 else |
8763 aep = syn_term_attr2entry(attr); | 8860 aep = syn_term_attr2entry(attr); |
8764 | 8861 |
8765 if (aep == NULL) /* highlighting not set */ | 8862 if (aep == NULL) /* highlighting not set */ |
8766 return 0; | 8863 return 0; |
8767 return aep->ae_attr; | 8864 return aep->ae_attr; |
8768 } | 8865 } |
8957 sp = TRUE; | 9054 sp = TRUE; |
8958 else if (!(TOLOWER_ASC(what[0]) == 'b' && TOLOWER_ASC(what[1]) == 'g')) | 9055 else if (!(TOLOWER_ASC(what[0]) == 'b' && TOLOWER_ASC(what[1]) == 'g')) |
8959 return NULL; | 9056 return NULL; |
8960 if (modec == 'g') | 9057 if (modec == 'g') |
8961 { | 9058 { |
8962 # ifdef FEAT_GUI | 9059 # if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
9060 # ifdef FEAT_GUI | |
8963 /* return font name */ | 9061 /* return font name */ |
8964 if (font) | 9062 if (font) |
8965 return HL_TABLE()[id - 1].sg_font_name; | 9063 return HL_TABLE()[id - 1].sg_font_name; |
9064 # endif | |
8966 | 9065 |
8967 /* return #RRGGBB form (only possible when GUI is running) */ | 9066 /* return #RRGGBB form (only possible when GUI is running) */ |
8968 if (gui.in_use && what[2] == '#') | 9067 if ((USE_24BIT) && what[2] == '#') |
8969 { | 9068 { |
8970 guicolor_T color; | 9069 guicolor_T color; |
8971 long_u rgb; | 9070 long_u rgb; |
8972 static char_u buf[10]; | 9071 static char_u buf[10]; |
8973 | 9072 |
8974 if (fg) | 9073 if (fg) |
8975 color = HL_TABLE()[id - 1].sg_gui_fg; | 9074 color = HL_TABLE()[id - 1].sg_gui_fg; |
8976 else if (sp) | 9075 else if (sp) |
9076 # ifdef FEAT_GUI | |
8977 color = HL_TABLE()[id - 1].sg_gui_sp; | 9077 color = HL_TABLE()[id - 1].sg_gui_sp; |
9078 # else | |
9079 color = INVALCOLOR; | |
9080 # endif | |
8978 else | 9081 else |
8979 color = HL_TABLE()[id - 1].sg_gui_bg; | 9082 color = HL_TABLE()[id - 1].sg_gui_bg; |
8980 if (color == INVALCOLOR) | 9083 if (color == INVALCOLOR) |
8981 return NULL; | 9084 return NULL; |
8982 rgb = gui_mch_get_rgb(color); | 9085 rgb = GUI_MCH_GET_RGB(color); |
8983 sprintf((char *)buf, "#%02x%02x%02x", | 9086 sprintf((char *)buf, "#%02x%02x%02x", |
8984 (unsigned)(rgb >> 16), | 9087 (unsigned)(rgb >> 16), |
8985 (unsigned)(rgb >> 8) & 255, | 9088 (unsigned)(rgb >> 8) & 255, |
8986 (unsigned)rgb & 255); | 9089 (unsigned)rgb & 255); |
8987 return buf; | 9090 return buf; |
8988 } | 9091 } |
8989 #endif | 9092 # endif |
8990 if (fg) | 9093 if (fg) |
8991 return (HL_TABLE()[id - 1].sg_gui_fg_name); | 9094 return (HL_TABLE()[id - 1].sg_gui_fg_name); |
8992 if (sp) | 9095 if (sp) |
8993 return (HL_TABLE()[id - 1].sg_gui_sp_name); | 9096 return (HL_TABLE()[id - 1].sg_gui_sp_name); |
8994 return (HL_TABLE()[id - 1].sg_gui_bg_name); | 9097 return (HL_TABLE()[id - 1].sg_gui_bg_name); |
9009 /* term doesn't have color */ | 9112 /* term doesn't have color */ |
9010 return NULL; | 9113 return NULL; |
9011 } | 9114 } |
9012 #endif | 9115 #endif |
9013 | 9116 |
9014 #if (defined(FEAT_SYN_HL) && defined(FEAT_GUI) && defined(FEAT_PRINTER)) \ | 9117 #if (defined(FEAT_SYN_HL) \ |
9015 || defined(PROTO) | 9118 && (defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR)) \ |
9119 && defined(FEAT_PRINTER)) || defined(PROTO) | |
9016 /* | 9120 /* |
9017 * Return color name of highlight group "id" as RGB value. | 9121 * Return color name of highlight group "id" as RGB value. |
9018 */ | 9122 */ |
9019 long_u | 9123 long_u |
9020 highlight_gui_color_rgb( | 9124 highlight_gui_color_rgb( |
9032 color = HL_TABLE()[id - 1].sg_gui_bg; | 9136 color = HL_TABLE()[id - 1].sg_gui_bg; |
9033 | 9137 |
9034 if (color == INVALCOLOR) | 9138 if (color == INVALCOLOR) |
9035 return 0L; | 9139 return 0L; |
9036 | 9140 |
9037 return gui_mch_get_rgb(color); | 9141 return GUI_MCH_GET_RGB(color); |
9038 } | 9142 } |
9039 #endif | 9143 #endif |
9040 | 9144 |
9041 /* | 9145 /* |
9042 * Output the syntax list header. | 9146 * Output the syntax list header. |
9148 | 9252 |
9149 /* | 9253 /* |
9150 * For the color term mode: If there are other than "normal" | 9254 * For the color term mode: If there are other than "normal" |
9151 * highlighting attributes, need to allocate an attr number. | 9255 * highlighting attributes, need to allocate an attr number. |
9152 */ | 9256 */ |
9153 if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0) | 9257 if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0 |
9258 # ifdef FEAT_TERMTRUECOLOR | |
9259 && sgp->sg_gui_fg == INVALCOLOR | |
9260 && sgp->sg_gui_bg == INVALCOLOR | |
9261 # endif | |
9262 ) | |
9154 sgp->sg_cterm_attr = sgp->sg_cterm; | 9263 sgp->sg_cterm_attr = sgp->sg_cterm; |
9155 else | 9264 else |
9156 { | 9265 { |
9157 at_en.ae_attr = sgp->sg_cterm; | 9266 at_en.ae_attr = sgp->sg_cterm; |
9158 at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; | 9267 at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; |
9159 at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; | 9268 at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; |
9269 # ifdef FEAT_TERMTRUECOLOR | |
9270 at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB(sgp->sg_gui_fg); | |
9271 at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB(sgp->sg_gui_bg); | |
9272 # endif | |
9160 sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en); | 9273 sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en); |
9161 } | 9274 } |
9162 } | 9275 } |
9163 | 9276 |
9164 /* | 9277 /* |
9305 } | 9418 } |
9306 | 9419 |
9307 vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group)); | 9420 vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group)); |
9308 HL_TABLE()[highlight_ga.ga_len].sg_name = name; | 9421 HL_TABLE()[highlight_ga.ga_len].sg_name = name; |
9309 HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); | 9422 HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); |
9310 #ifdef FEAT_GUI | 9423 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
9311 HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; | 9424 HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; |
9312 HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; | 9425 HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; |
9426 # ifdef FEAT_GUI | |
9313 HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR; | 9427 HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR; |
9428 # endif | |
9314 #endif | 9429 #endif |
9315 ++highlight_ga.ga_len; | 9430 ++highlight_ga.ga_len; |
9316 | 9431 |
9317 return highlight_ga.ga_len; /* ID is index plus one */ | 9432 return highlight_ga.ga_len; /* ID is index plus one */ |
9318 } | 9433 } |
9347 */ | 9462 */ |
9348 if (gui.in_use) | 9463 if (gui.in_use) |
9349 attr = sgp->sg_gui_attr; | 9464 attr = sgp->sg_gui_attr; |
9350 else | 9465 else |
9351 #endif | 9466 #endif |
9352 if (t_colors > 1) | 9467 if (IS_CTERM) |
9353 attr = sgp->sg_cterm_attr; | 9468 attr = sgp->sg_cterm_attr; |
9354 else | 9469 else |
9355 attr = sgp->sg_term_attr; | 9470 attr = sgp->sg_term_attr; |
9356 | 9471 |
9357 return attr; | 9472 return attr; |
9401 } | 9516 } |
9402 | 9517 |
9403 return hl_id; | 9518 return hl_id; |
9404 } | 9519 } |
9405 | 9520 |
9406 #ifdef FEAT_GUI | 9521 #if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
9407 /* | 9522 /* |
9408 * Call this function just after the GUI has started. | 9523 * Call this function just after the GUI has started. |
9409 * It finds the font and color handles for the highlighting groups. | 9524 * It finds the font and color handles for the highlighting groups. |
9410 */ | 9525 */ |
9411 void | 9526 void |
9412 highlight_gui_started(void) | 9527 highlight_gui_started(void) |
9413 { | 9528 { |
9414 int idx; | 9529 int idx; |
9415 | 9530 |
9416 /* First get the colors from the "Normal" and "Menu" group, if set */ | 9531 /* First get the colors from the "Normal" and "Menu" group, if set */ |
9417 set_normal_colors(); | 9532 # if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) |
9533 # ifdef FEAT_TERMTRUECOLOR | |
9534 if (USE_24BIT) | |
9535 # endif | |
9536 set_normal_colors(); | |
9537 # endif | |
9418 | 9538 |
9419 for (idx = 0; idx < highlight_ga.ga_len; ++idx) | 9539 for (idx = 0; idx < highlight_ga.ga_len; ++idx) |
9420 gui_do_one_color(idx, FALSE, FALSE); | 9540 gui_do_one_color(idx, FALSE, FALSE); |
9421 | 9541 |
9422 highlight_changed(); | 9542 highlight_changed(); |
9428 int do_menu, /* TRUE: might set the menu font */ | 9548 int do_menu, /* TRUE: might set the menu font */ |
9429 int do_tooltip) /* TRUE: might set the tooltip font */ | 9549 int do_tooltip) /* TRUE: might set the tooltip font */ |
9430 { | 9550 { |
9431 int didit = FALSE; | 9551 int didit = FALSE; |
9432 | 9552 |
9433 if (HL_TABLE()[idx].sg_font_name != NULL) | 9553 # ifdef FEAT_GUI |
9434 { | 9554 # ifdef FEAT_TERMTRUECOLOR |
9435 hl_do_font(idx, HL_TABLE()[idx].sg_font_name, FALSE, do_menu, | 9555 if (gui.in_use) |
9556 # endif | |
9557 if (HL_TABLE()[idx].sg_font_name != NULL) | |
9558 { | |
9559 hl_do_font(idx, HL_TABLE()[idx].sg_font_name, FALSE, do_menu, | |
9436 do_tooltip, TRUE); | 9560 do_tooltip, TRUE); |
9437 didit = TRUE; | 9561 didit = TRUE; |
9438 } | 9562 } |
9563 # endif | |
9439 if (HL_TABLE()[idx].sg_gui_fg_name != NULL) | 9564 if (HL_TABLE()[idx].sg_gui_fg_name != NULL) |
9440 { | 9565 { |
9441 HL_TABLE()[idx].sg_gui_fg = | 9566 HL_TABLE()[idx].sg_gui_fg = |
9442 color_name2handle(HL_TABLE()[idx].sg_gui_fg_name); | 9567 color_name2handle(HL_TABLE()[idx].sg_gui_fg_name); |
9443 didit = TRUE; | 9568 didit = TRUE; |
9446 { | 9571 { |
9447 HL_TABLE()[idx].sg_gui_bg = | 9572 HL_TABLE()[idx].sg_gui_bg = |
9448 color_name2handle(HL_TABLE()[idx].sg_gui_bg_name); | 9573 color_name2handle(HL_TABLE()[idx].sg_gui_bg_name); |
9449 didit = TRUE; | 9574 didit = TRUE; |
9450 } | 9575 } |
9576 # ifdef FEAT_GUI | |
9451 if (HL_TABLE()[idx].sg_gui_sp_name != NULL) | 9577 if (HL_TABLE()[idx].sg_gui_sp_name != NULL) |
9452 { | 9578 { |
9453 HL_TABLE()[idx].sg_gui_sp = | 9579 HL_TABLE()[idx].sg_gui_sp = |
9454 color_name2handle(HL_TABLE()[idx].sg_gui_sp_name); | 9580 color_name2handle(HL_TABLE()[idx].sg_gui_sp_name); |
9455 didit = TRUE; | 9581 didit = TRUE; |
9456 } | 9582 } |
9583 # endif | |
9457 if (didit) /* need to get a new attr number */ | 9584 if (didit) /* need to get a new attr number */ |
9458 set_hl_attr(idx); | 9585 set_hl_attr(idx); |
9459 } | 9586 } |
9460 | |
9461 #endif | 9587 #endif |
9462 | 9588 |
9463 /* | 9589 /* |
9464 * Translate the 'highlight' option into attributes in highlight_attr[] and | 9590 * Translate the 'highlight' option into attributes in highlight_attr[] and |
9465 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of | 9591 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of |