diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-04-21 21:10:14 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-04-21 21:10:14 +0200 |
commit | 8a633e3427b47286869aa4b96f2bfc1fe65b25cd (patch) | |
tree | eec90d2e5fdc9a9da532a024ca59993e000813f6 /src | |
parent | 6d4431e7b675ba7a0194c0b8eb84b7d92e4e7953 (diff) |
patch 7.4.1770v7.4.1770
Problem: Cannot use true color in the terminal.
Solution: Add the 'guicolors' option. (Nikolai Pavlov)
Diffstat (limited to 'src')
-rwxr-xr-x | src/auto/configure | 18 | ||||
-rw-r--r-- | src/config.h.in | 3 | ||||
-rw-r--r-- | src/configure.in | 9 | ||||
-rw-r--r-- | src/eval.c | 3 | ||||
-rw-r--r-- | src/globals.h | 4 | ||||
-rw-r--r-- | src/hardcopy.c | 6 | ||||
-rw-r--r-- | src/option.c | 24 | ||||
-rw-r--r-- | src/option.h | 3 | ||||
-rw-r--r-- | src/proto/term.pro | 5 | ||||
-rw-r--r-- | src/screen.c | 100 | ||||
-rw-r--r-- | src/structs.h | 8 | ||||
-rw-r--r-- | src/syntax.c | 296 | ||||
-rw-r--r-- | src/term.c | 208 | ||||
-rw-r--r-- | src/term.h | 8 | ||||
-rw-r--r-- | src/version.c | 7 | ||||
-rw-r--r-- | src/vim.h | 25 |
16 files changed, 609 insertions, 118 deletions
diff --git a/src/auto/configure b/src/auto/configure index ff3a63b4b5..ba0d0b05ab 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -810,6 +810,7 @@ with_tclsh enable_rubyinterp with_ruby_command enable_cscope +enable_termtruecolor enable_workshop enable_netbeans enable_channel @@ -1476,6 +1477,7 @@ Optional Features: --enable-tclinterp=OPTS Include Tcl interpreter. default=no OPTS=no/yes/dynamic --enable-rubyinterp=OPTS Include Ruby interpreter. default=no OPTS=no/yes/dynamic --enable-cscope Include cscope interface. + --enable-termtruecolor Include support for 24-bit colors in ISO-8613-3 compatible terminals --enable-workshop Include Sun Visual Workshop support. --disable-netbeans Disable NetBeans integration support. --disable-channel Disable process communication support. @@ -7216,6 +7218,22 @@ if test "$enable_cscope" = "yes"; then fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-termtruecolor argument" >&5 +$as_echo_n "checking --enable-termtruecolor argument... " >&6; } +# Check whether --enable-termtruecolor was given. +if test "${enable_termtruecolor+set}" = set; then : + enableval=$enable_termtruecolor; +else + enable_termtruecolor="no" +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_termtruecolor" >&5 +$as_echo "$enable_termtruecolor" >&6; } +if test "$enable_termtruecolor" = "yes"; then + $as_echo "#define FEAT_TERMTRUECOLOR 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-workshop argument" >&5 $as_echo_n "checking --enable-workshop argument... " >&6; } # Check whether --enable-workshop was given. diff --git a/src/config.h.in b/src/config.h.in index 9d35e48fa6..6c0f7798de 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -362,6 +362,9 @@ /* Define for linking via dlopen() or LoadLibrary() */ #undef DYNAMIC_TCL +/* Define if you want 24-bit colors in ISO-8613-3 compatible terminals. */ +#undef FEAT_TERMTRUECOLOR + /* Define if you want to add support for ACL */ #undef HAVE_POSIX_ACL #undef HAVE_SOLARIS_ZFS_ACL diff --git a/src/configure.in b/src/configure.in index 279ed47227..d1d7838802 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1926,6 +1926,15 @@ if test "$enable_cscope" = "yes"; then AC_DEFINE(FEAT_CSCOPE) fi +AC_MSG_CHECKING(--enable-termtruecolor argument) +AC_ARG_ENABLE(termtruecolor, + [ --enable-termtruecolor Include support for 24-bit colors in ISO-8613-3 compatible terminals], , + [enable_termtruecolor="no"]) +AC_MSG_RESULT($enable_termtruecolor) +if test "$enable_termtruecolor" = "yes"; then + AC_DEFINE(FEAT_TERMTRUECOLOR) +fi + AC_MSG_CHECKING(--enable-workshop argument) AC_ARG_ENABLE(workshop, [ --enable-workshop Include Sun Visual Workshop support.], , diff --git a/src/eval.c b/src/eval.c index b82a98fdb1..3542b777f4 100644 --- a/src/eval.c +++ b/src/eval.c @@ -14044,6 +14044,9 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef FEAT_TERMRESPONSE "termresponse", #endif +#ifdef FEAT_TERMTRUECOLOR + "termtruecolor", +#endif #ifdef FEAT_TEXTOBJ "textobjects", #endif diff --git a/src/globals.h b/src/globals.h index 5effdb5630..8cc9bedf9b 100644 --- a/src/globals.h +++ b/src/globals.h @@ -369,6 +369,10 @@ EXTERN char_u *use_gvimrc INIT(= NULL); /* "-U" cmdline argument */ EXTERN int cterm_normal_fg_color INIT(= 0); EXTERN int cterm_normal_fg_bold INIT(= 0); EXTERN int cterm_normal_bg_color INIT(= 0); +#ifdef FEAT_TERMTRUECOLOR +EXTERN long_u cterm_normal_fg_gui_color INIT(= INVALCOLOR); +EXTERN long_u cterm_normal_bg_gui_color INIT(= INVALCOLOR); +#endif #ifdef FEAT_AUTOCMD EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */ diff --git a/src/hardcopy.c b/src/hardcopy.c index f65a6dd40a..aaa20102c8 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -164,7 +164,7 @@ parse_printoptions(void) #if (defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)) || defined(PROTO) /* - * Parse 'printoptions' and set the flags in "printer_opts". + * Parse 'printmbfont' and set the flags in "mbfont_opts". * Returns an error message or NULL; */ char_u * @@ -307,8 +307,8 @@ prt_get_attr( pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL); pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL); -# ifdef FEAT_GUI - if (gui.in_use) +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) + if (USE_24BIT) { bg_color = highlight_gui_color_rgb(hl_id, FALSE); if (bg_color == PRCOLOR_BLACK) diff --git a/src/option.c b/src/option.c index a5b403cf9f..da02864123 100644 --- a/src/option.c +++ b/src/option.c @@ -1305,7 +1305,16 @@ static struct vimoption options[] = {(char_u *)NULL, (char_u *)0L} #endif SCRIPTID_INIT}, - {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, + {"guicolors", "gcol", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, +#ifdef FEAT_TERMTRUECOLOR + (char_u *)&p_guicolors, PV_NONE, + {(char_u *)FALSE, (char_u *)FALSE} +#else + (char_u*)NULL, PV_NONE, + {(char_u *)FALSE, (char_u *)FALSE} +#endif + SCRIPTID_INIT}, + {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, #ifdef CURSOR_SHAPE (char_u *)&p_guicursor, PV_NONE, { @@ -3011,6 +3020,8 @@ static struct vimoption options[] = p_term("t_xs", T_XS) p_term("t_ZH", T_CZH) p_term("t_ZR", T_CZR) + p_term("t_8f", T_8F) + p_term("t_8b", T_8B) /* terminal key codes are not in here */ @@ -8353,6 +8364,17 @@ set_bool_option( #endif +#ifdef FEAT_TERMTRUECOLOR + /* 'guicolors' */ + else if ((int *)varp == &p_guicolors) + { +# ifdef FEAT_GUI + if (!gui.in_use && !gui.starting) +# endif + highlight_gui_started(); + } +#endif + /* * End of handling side effects for bool options. */ diff --git a/src/option.h b/src/option.h index cf7ba04e7e..60889ab432 100644 --- a/src/option.h +++ b/src/option.h @@ -527,6 +527,9 @@ EXTERN char_u *p_popt; /* 'printoptions' */ EXTERN char_u *p_header; /* 'printheader' */ #endif EXTERN int p_prompt; /* 'prompt' */ +#ifdef FEAT_TERMTRUECOLOR +EXTERN int p_guicolors; /* 'guicolors' */ +#endif #ifdef FEAT_GUI EXTERN char_u *p_guifont; /* 'guifont' */ # ifdef FEAT_XFONTSET diff --git a/src/proto/term.pro b/src/proto/term.pro index 58369794c6..cd2ca26d38 100644 --- a/src/proto/term.pro +++ b/src/proto/term.pro @@ -1,4 +1,7 @@ /* term.c */ +guicolor_T termtrue_mch_get_color(char_u *name); +guicolor_T termtrue_get_color(char_u *name); +long_u termtrue_mch_get_rgb(guicolor_T color); int set_termname(char_u *term); void set_mouse_termcode(int n, char_u *s); void del_mouse_termcode(int n); @@ -22,6 +25,8 @@ void term_set_winpos(int x, int y); void term_set_winsize(int width, int height); void term_fg_color(int n); void term_bg_color(int n); +void term_fg_rgb_color(long_u rgb); +void term_bg_rgb_color(long_u rgb); void term_settitle(char_u *title); void ttest(int pairs); void add_long_to_buf(long_u val, char_u *dst); diff --git a/src/screen.c b/src/screen.c index b92cbf9e26..5dc8ffe280 100644 --- a/src/screen.c +++ b/src/screen.c @@ -7828,7 +7828,7 @@ screen_start_highlight(int attr) { if (attr > HL_ALL) /* special HL attr. */ { - if (t_colors > 1) + if (IS_CTERM) aep = syn_cterm_attr2entry(attr); else aep = syn_term_attr2entry(attr); @@ -7839,8 +7839,16 @@ screen_start_highlight(int attr) } if ((attr & HL_BOLD) && T_MD != NULL) /* bold */ out_str(T_MD); - else if (aep != NULL && t_colors > 1 && aep->ae_u.cterm.fg_color - && cterm_normal_fg_bold) + else if (aep != NULL && cterm_normal_fg_bold && +#ifdef FEAT_TERMTRUECOLOR + (p_guicolors ? + (aep->ae_u.cterm.fg_rgb != INVALCOLOR): +#endif + (t_colors > 1 && aep->ae_u.cterm.fg_color) +#ifdef FEAT_TERMTRUECOLOR + ) +#endif + ) /* If the Normal FG color has BOLD attribute and the new HL * has a FG color defined, clear BOLD. */ out_str(T_ME); @@ -7860,17 +7868,29 @@ screen_start_highlight(int attr) */ if (aep != NULL) { - if (t_colors > 1) +#ifdef FEAT_TERMTRUECOLOR + if (p_guicolors) { - if (aep->ae_u.cterm.fg_color) - term_fg_color(aep->ae_u.cterm.fg_color - 1); - if (aep->ae_u.cterm.bg_color) - term_bg_color(aep->ae_u.cterm.bg_color - 1); + if (aep->ae_u.cterm.fg_rgb != INVALCOLOR) + term_fg_rgb_color(aep->ae_u.cterm.fg_rgb); + if (aep->ae_u.cterm.bg_rgb != INVALCOLOR) + term_bg_rgb_color(aep->ae_u.cterm.bg_rgb); } else +#endif { - if (aep->ae_u.term.start != NULL) - out_str(aep->ae_u.term.start); + if (t_colors > 1) + { + if (aep->ae_u.cterm.fg_color) + term_fg_color(aep->ae_u.cterm.fg_color - 1); + if (aep->ae_u.cterm.bg_color) + term_bg_color(aep->ae_u.cterm.bg_color - 1); + } + else + { + if (aep->ae_u.term.start != NULL) + out_str(aep->ae_u.term.start); + } } } } @@ -7904,14 +7924,23 @@ screen_stop_highlight(void) { attrentry_T *aep; - if (t_colors > 1) + if (IS_CTERM) { /* * Assume that t_me restores the original colors! */ aep = syn_cterm_attr2entry(screen_attr); - if (aep != NULL && (aep->ae_u.cterm.fg_color - || aep->ae_u.cterm.bg_color)) + if (aep != NULL && +#ifdef FEAT_TERMTRUECOLOR + (p_guicolors ? + (aep->ae_u.cterm.fg_rgb != INVALCOLOR || + aep->ae_u.cterm.bg_rgb != INVALCOLOR): +#endif + (aep->ae_u.cterm.fg_color || aep->ae_u.cterm.bg_color) +#ifdef FEAT_TERMTRUECOLOR + ) +#endif + ) do_ME = TRUE; } else @@ -7959,15 +7988,27 @@ screen_stop_highlight(void) if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE))) out_str(T_ME); - if (t_colors > 1) +#ifdef FEAT_TERMTRUECOLOR + if (p_guicolors) { - /* set Normal cterm colors */ - if (cterm_normal_fg_color != 0) - term_fg_color(cterm_normal_fg_color - 1); - if (cterm_normal_bg_color != 0) - term_bg_color(cterm_normal_bg_color - 1); - if (cterm_normal_fg_bold) - out_str(T_MD); + if (cterm_normal_fg_gui_color != INVALCOLOR) + term_fg_rgb_color(cterm_normal_fg_gui_color); + if (cterm_normal_bg_gui_color != INVALCOLOR) + term_bg_rgb_color(cterm_normal_bg_gui_color); + } + else +#endif + { + if (t_colors > 1) + { + /* set Normal cterm colors */ + if (cterm_normal_fg_color != 0) + term_fg_color(cterm_normal_fg_color - 1); + if (cterm_normal_bg_color != 0) + term_bg_color(cterm_normal_bg_color - 1); + if (cterm_normal_fg_bold) + out_str(T_MD); + } } } } @@ -7981,10 +8022,17 @@ screen_stop_highlight(void) void reset_cterm_colors(void) { - if (t_colors > 1) + if (IS_CTERM) { /* set Normal cterm colors */ +#ifdef FEAT_TERMTRUECOLOR + if (p_guicolors ? + (cterm_normal_fg_gui_color != INVALCOLOR + || cterm_normal_bg_gui_color != INVALCOLOR): + (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)) +#else if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) +#endif { out_str(T_OP); screen_attr = -1; @@ -8228,7 +8276,7 @@ screen_fill( #ifdef FEAT_GUI !gui.in_use && #endif - t_colors <= 1); + !IS_CTERM); for (row = start_row; row < end_row; ++row) { #ifdef FEAT_MBYTE @@ -8911,6 +8959,9 @@ can_clear(char_u *p) #ifdef FEAT_GUI || gui.in_use #endif +#ifdef FEAT_TERMTRUECOLOR + || (p_guicolors && cterm_normal_bg_gui_color != INVALCOLOR) +#endif || cterm_normal_bg_color == 0 || *T_UT != NUL)); } @@ -10242,6 +10293,9 @@ draw_tabline(void) #ifdef FEAT_GUI && !gui.in_use #endif +#ifdef FEAT_TERMTRUECOLOR + && !p_guicolors +#endif ); redraw_tabline = FALSE; diff --git a/src/structs.h b/src/structs.h index adee3e807e..1775256996 100644 --- a/src/structs.h +++ b/src/structs.h @@ -84,7 +84,9 @@ typedef struct file_buffer buf_T; /* forward declaration */ # ifdef FEAT_XCLIPBOARD # include <X11/Intrinsic.h> # endif -# define guicolor_T int /* avoid error in prototypes */ +# define guicolor_T long_u /* avoid error in prototypes and + * make FEAT_TERMTRUECOLOR work */ +# define INVALCOLOR ((guicolor_T)0x1ffffff) #endif /* @@ -911,6 +913,10 @@ typedef struct attr_entry /* These colors need to be > 8 bits to hold 256. */ short_u fg_color; /* foreground color number */ short_u bg_color; /* background color number */ +# ifdef FEAT_TERMTRUECOLOR + long_u fg_rgb; /* foreground color RGB */ + long_u bg_rgb; /* background color RGB */ +# endif } cterm; # ifdef FEAT_GUI struct diff --git a/src/syntax.c b/src/syntax.c index 31c1d0d533..76a5976551 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -33,10 +33,12 @@ struct hl_group int sg_cterm_fg; /* terminal fg color number + 1 */ int sg_cterm_bg; /* terminal bg color number + 1 */ int sg_cterm_attr; /* Screen attr for color term mode */ -#ifdef FEAT_GUI /* for when using the GUI */ +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) guicolor_T sg_gui_fg; /* GUI foreground color handle */ guicolor_T sg_gui_bg; /* GUI background color handle */ +#endif +#ifdef FEAT_GUI guicolor_T sg_gui_sp; /* GUI special color handle */ GuiFont sg_font; /* GUI font handle */ #ifdef FEAT_XFONTSET @@ -97,10 +99,12 @@ static int syn_list_header(int did_header, int outlen, int id); static int hl_has_settings(int idx, int check_link); static void highlight_clear(int idx); -#ifdef FEAT_GUI +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) static void gui_do_one_color(int idx, int do_menu, int do_tooltip); -static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip); static guicolor_T color_name2handle(char_u *name); +#endif +#ifdef FEAT_GUI +static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip); static GuiFont font_name2handle(char_u *name); # ifdef FEAT_XFONTSET static GuiFontset fontset_name2handle(char_u *name, int fixed_width); @@ -7333,8 +7337,8 @@ do_highlight( for (idx = 0; idx < highlight_ga.ga_len; ++idx) highlight_clear(idx); init_highlight(TRUE, TRUE); -#ifdef FEAT_GUI - if (gui.in_use) +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) + if (USE_24BIT) highlight_gui_started(); #endif highlight_changed(); @@ -7788,10 +7792,16 @@ do_highlight( if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; -# ifdef FEAT_GUI +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) /* In GUI guifg colors are only used when recognized */ i = color_name2handle(arg); - if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) + if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 +# ifdef FEAT_GUI + || !(USE_24BIT) +# else + || !p_guicolors +# endif + ) { HL_TABLE()[idx].sg_gui_fg = i; # endif @@ -7800,7 +7810,7 @@ do_highlight( HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg); else HL_TABLE()[idx].sg_gui_fg_name = NULL; -# ifdef FEAT_GUI +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) # ifdef FEAT_GUI_X11 if (is_menu_group) gui.menu_fg_pixel = i; @@ -7825,10 +7835,10 @@ do_highlight( if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; -# ifdef FEAT_GUI +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) /* In GUI guifg colors are only used when recognized */ i = color_name2handle(arg); - if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) + if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT) { HL_TABLE()[idx].sg_gui_bg = i; # endif @@ -7837,7 +7847,7 @@ do_highlight( HL_TABLE()[idx].sg_gui_bg_name = vim_strsave(arg); else HL_TABLE()[idx].sg_gui_bg_name = NULL; -# ifdef FEAT_GUI +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) # ifdef FEAT_GUI_X11 if (is_menu_group) gui.menu_bg_pixel = i; @@ -7997,7 +8007,9 @@ do_highlight( * Need to update all groups, because they might be using "bg" * and/or "fg", which have been changed now. */ - if (gui.in_use) +#endif +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) + if (USE_24BIT) highlight_gui_started(); #endif } @@ -8068,6 +8080,10 @@ restore_cterm_colors(void) cterm_normal_fg_color = 0; cterm_normal_fg_bold = 0; cterm_normal_bg_color = 0; +# ifdef FEAT_TERMTRUECOLOR + cterm_normal_fg_gui_color = INVALCOLOR; + cterm_normal_bg_gui_color = INVALCOLOR; +# endif #endif } @@ -8118,9 +8134,11 @@ highlight_clear(int idx) vim_free(HL_TABLE()[idx].sg_gui_sp_name); HL_TABLE()[idx].sg_gui_sp_name = NULL; #endif -#ifdef FEAT_GUI +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; HL_TABLE()[idx].sg_gui_bg = INVALCOLOR; +#endif +#ifdef FEAT_GUI HL_TABLE()[idx].sg_gui_sp = INVALCOLOR; gui_mch_free_font(HL_TABLE()[idx].sg_font); HL_TABLE()[idx].sg_font = NOFONT; @@ -8140,7 +8158,7 @@ highlight_clear(int idx) #endif } -#if defined(FEAT_GUI) || defined(PROTO) +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) || defined(PROTO) /* * Set the normal foreground and background colors according to the "Normal" * highlighting group. For X11 also set "Menu", "Scrollbar", and @@ -8149,44 +8167,78 @@ highlight_clear(int idx) void set_normal_colors(void) { - if (set_group_colors((char_u *)"Normal", - &gui.norm_pixel, &gui.back_pixel, - FALSE, TRUE, FALSE)) - { - gui_mch_new_colors(); - must_redraw = CLEAR; - } -#ifdef FEAT_GUI_X11 - if (set_group_colors((char_u *)"Menu", - &gui.menu_fg_pixel, &gui.menu_bg_pixel, - TRUE, FALSE, FALSE)) - { -# ifdef FEAT_MENU - gui_mch_new_menu_colors(); +#ifdef FEAT_GUI +# ifdef FEAT_TERMTRUECOLOR + if (gui.in_use) # endif - must_redraw = CLEAR; - } -# ifdef FEAT_BEVAL - if (set_group_colors((char_u *)"Tooltip", - &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel, - FALSE, FALSE, TRUE)) { -# ifdef FEAT_TOOLBAR - gui_mch_new_tooltip_colors(); + if (set_group_colors((char_u *)"Normal", + &gui.norm_pixel, &gui.back_pixel, + FALSE, TRUE, FALSE)) + { + gui_mch_new_colors(); + must_redraw = CLEAR; + } +# ifdef FEAT_GUI_X11 + if (set_group_colors((char_u *)"Menu", + &gui.menu_fg_pixel, &gui.menu_bg_pixel, + TRUE, FALSE, FALSE)) + { +# ifdef FEAT_MENU + gui_mch_new_menu_colors(); +# endif + must_redraw = CLEAR; + } +# ifdef FEAT_BEVAL + if (set_group_colors((char_u *)"Tooltip", + &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel, + FALSE, FALSE, TRUE)) + { +# ifdef FEAT_TOOLBAR + gui_mch_new_tooltip_colors(); +# endif + must_redraw = CLEAR; + } +# endif + if (set_group_colors((char_u *)"Scrollbar", + &gui.scroll_fg_pixel, &gui.scroll_bg_pixel, + FALSE, FALSE, FALSE)) + { + gui_new_scrollbar_colors(); + must_redraw = CLEAR; + } # endif - must_redraw = CLEAR; } #endif - if (set_group_colors((char_u *)"Scrollbar", - &gui.scroll_fg_pixel, &gui.scroll_bg_pixel, - FALSE, FALSE, FALSE)) +#ifdef FEAT_TERMTRUECOLOR +# ifdef FEAT_GUI + else +# endif { - gui_new_scrollbar_colors(); - must_redraw = CLEAR; + int idx; + + idx = syn_name2id((char_u *)"Normal") - 1; + if (idx >= 0) + { + gui_do_one_color(idx, FALSE, FALSE); + + if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR) + { + cterm_normal_fg_gui_color = HL_TABLE()[idx].sg_gui_fg; + must_redraw = CLEAR; + } + if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR) + { + cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg; + must_redraw = CLEAR; + } + } } #endif } +#endif +#if defined(FEAT_GUI) || defined(PROTO) /* * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". */ @@ -8299,24 +8351,6 @@ hl_set_fg_color_name( } /* - * Return the handle for a color name. - * Returns INVALCOLOR when failed. - */ - static guicolor_T -color_name2handle(char_u *name) -{ - if (STRCMP(name, "NONE") == 0) - return INVALCOLOR; - - if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) - return gui.norm_pixel; - if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) - return gui.back_pixel; - - return gui_get_color(name); -} - -/* * Return the handle for a font name. * Returns NOFONT when failed. */ @@ -8439,6 +8473,52 @@ hl_do_font( #endif /* FEAT_GUI */ +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) || defined(PROTO) +/* + * Return the handle for a color name. + * Returns INVALCOLOR when failed. + */ + static guicolor_T +color_name2handle(char_u *name) +{ + if (STRCMP(name, "NONE") == 0) + return INVALCOLOR; + + if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) + { +#if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) + if (gui.in_use) +#endif +#ifdef FEAT_GUI + return gui.norm_pixel; +#endif +#if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) + else +#endif +#ifdef FEAT_TERMTRUECOLOR + return cterm_normal_fg_gui_color; +#endif + } + if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) + { +#if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) + if (gui.in_use) +#endif +#ifdef FEAT_GUI + return gui.back_pixel; +#endif +#if defined(FEAT_TERMTRUECOLOR) && defined(FEAT_GUI) + else +#endif +#ifdef FEAT_TERMTRUECOLOR + return cterm_normal_bg_gui_color; +#endif + } + + return GUI_GET_COLOR(name); +} +#endif + /* * Table with the specifications for an attribute number. * Note that this table is used by ALL buffers. This is required because the @@ -8514,8 +8594,15 @@ get_attr_entry(garray_T *table, attrentry_T *aep) && aep->ae_u.cterm.fg_color == taep->ae_u.cterm.fg_color && aep->ae_u.cterm.bg_color - == taep->ae_u.cterm.bg_color) - )) + == taep->ae_u.cterm.bg_color +#ifdef FEAT_TERMTRUECOLOR + && aep->ae_u.cterm.fg_rgb + == taep->ae_u.cterm.fg_rgb + && aep->ae_u.cterm.bg_rgb + == taep->ae_u.cterm.bg_rgb +#endif + + ))) return i + ATTR_OFF; } @@ -8580,6 +8667,10 @@ get_attr_entry(garray_T *table, attrentry_T *aep) { taep->ae_u.cterm.fg_color = aep->ae_u.cterm.fg_color; taep->ae_u.cterm.bg_color = aep->ae_u.cterm.bg_color; +#ifdef FEAT_TERMTRUECOLOR + taep->ae_u.cterm.fg_rgb = aep->ae_u.cterm.fg_rgb; + taep->ae_u.cterm.bg_rgb = aep->ae_u.cterm.bg_rgb; +#endif } ++table->ga_len; return (table->ga_len - 1 + ATTR_OFF); @@ -8671,7 +8762,7 @@ hl_combine_attr(int char_attr, int prim_attr) } #endif - if (t_colors > 1) + if (IS_CTERM) { if (char_attr > HL_ALL) char_aep = syn_cterm_attr2entry(char_attr); @@ -8696,6 +8787,12 @@ hl_combine_attr(int char_attr, int prim_attr) new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color; if (spell_aep->ae_u.cterm.bg_color > 0) new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; +#ifdef FEAT_TERMTRUECOLOR + if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR) + new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb; + if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR) + new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb; +#endif } } return get_attr_entry(&cterm_attr_table, &new_en); @@ -8757,10 +8854,10 @@ syn_attr2attr(int attr) aep = syn_gui_attr2entry(attr); else #endif - if (t_colors > 1) - aep = syn_cterm_attr2entry(attr); - else - aep = syn_term_attr2entry(attr); + if (IS_CTERM) + aep = syn_cterm_attr2entry(attr); + else + aep = syn_term_attr2entry(attr); if (aep == NULL) /* highlighting not set */ return 0; @@ -8959,13 +9056,15 @@ highlight_color( return NULL; if (modec == 'g') { -# ifdef FEAT_GUI +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) +# ifdef FEAT_GUI /* return font name */ if (font) return HL_TABLE()[id - 1].sg_font_name; +# endif /* return #RRGGBB form (only possible when GUI is running) */ - if (gui.in_use && what[2] == '#') + if ((USE_24BIT) && what[2] == '#') { guicolor_T color; long_u rgb; @@ -8974,19 +9073,23 @@ highlight_color( if (fg) color = HL_TABLE()[id - 1].sg_gui_fg; else if (sp) +# ifdef FEAT_GUI color = HL_TABLE()[id - 1].sg_gui_sp; +# else + color = INVALCOLOR; +# endif else color = HL_TABLE()[id - 1].sg_gui_bg; if (color == INVALCOLOR) return NULL; - rgb = gui_mch_get_rgb(color); + rgb = GUI_MCH_GET_RGB(color); sprintf((char *)buf, "#%02x%02x%02x", (unsigned)(rgb >> 16), (unsigned)(rgb >> 8) & 255, (unsigned)rgb & 255); return buf; } -#endif +# endif if (fg) return (HL_TABLE()[id - 1].sg_gui_fg_name); if (sp) @@ -9011,8 +9114,9 @@ highlight_color( } #endif -#if (defined(FEAT_SYN_HL) && defined(FEAT_GUI) && defined(FEAT_PRINTER)) \ - || defined(PROTO) +#if (defined(FEAT_SYN_HL) \ + && (defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR)) \ + && defined(FEAT_PRINTER)) || defined(PROTO) /* * Return color name of highlight group "id" as RGB value. */ @@ -9034,7 +9138,7 @@ highlight_gui_color_rgb( if (color == INVALCOLOR) return 0L; - return gui_mch_get_rgb(color); + return GUI_MCH_GET_RGB(color); } #endif @@ -9150,13 +9254,22 @@ 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 +# ifdef FEAT_TERMTRUECOLOR + && sgp->sg_gui_fg == INVALCOLOR + && sgp->sg_gui_bg == INVALCOLOR +# endif + ) sgp->sg_cterm_attr = sgp->sg_cterm; else { at_en.ae_attr = 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; +# ifdef FEAT_TERMTRUECOLOR + at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB(sgp->sg_gui_fg); + at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB(sgp->sg_gui_bg); +# endif sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en); } } @@ -9307,10 +9420,12 @@ syn_add_group(char_u *name) vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group)); HL_TABLE()[highlight_ga.ga_len].sg_name = name; HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); -#ifdef FEAT_GUI +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; +# ifdef FEAT_GUI HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR; +# endif #endif ++highlight_ga.ga_len; @@ -9349,7 +9464,7 @@ syn_id2attr(int hl_id) attr = sgp->sg_gui_attr; else #endif - if (t_colors > 1) + if (IS_CTERM) attr = sgp->sg_cterm_attr; else attr = sgp->sg_term_attr; @@ -9403,7 +9518,7 @@ syn_get_final_id(int hl_id) return hl_id; } -#ifdef FEAT_GUI +#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) /* * Call this function just after the GUI has started. * It finds the font and color handles for the highlighting groups. @@ -9414,7 +9529,12 @@ highlight_gui_started(void) int idx; /* First get the colors from the "Normal" and "Menu" group, if set */ - set_normal_colors(); +# if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR) +# ifdef FEAT_TERMTRUECOLOR + if (USE_24BIT) +# endif + set_normal_colors(); +# endif for (idx = 0; idx < highlight_ga.ga_len; ++idx) gui_do_one_color(idx, FALSE, FALSE); @@ -9430,12 +9550,17 @@ gui_do_one_color( { int didit = FALSE; - if (HL_TABLE()[idx].sg_font_name != NULL) - { - hl_do_font(idx, HL_TABLE()[idx].sg_font_name, FALSE, do_menu, +# ifdef FEAT_GUI +# ifdef FEAT_TERMTRUECOLOR + if (gui.in_use) +# endif + if (HL_TABLE()[idx].sg_font_name != NULL) + { + hl_do_font(idx, HL_TABLE()[idx].sg_font_name, FALSE, do_menu, do_tooltip, TRUE); - didit = TRUE; - } + didit = TRUE; + } +# endif if (HL_TABLE()[idx].sg_gui_fg_name != NULL) { HL_TABLE()[idx].sg_gui_fg = @@ -9448,16 +9573,17 @@ gui_do_one_color( color_name2handle(HL_TABLE()[idx].sg_gui_bg_name); didit = TRUE; } +# ifdef FEAT_GUI if (HL_TABLE()[idx].sg_gui_sp_name != NULL) { HL_TABLE()[idx].sg_gui_sp = color_name2handle(HL_TABLE()[idx].sg_gui_sp_name); didit = TRUE; } +# endif if (didit) /* need to get a new attr number */ set_hl_attr(idx); } - #endif /* |