To: vim_dev@googlegroups.com Subject: Patch 8.0.1544 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1544 Problem: When using 'termguicolors' SpellBad doesn't show. Solution: When the GUI colors are not set fall back to the cterm colors. Files: src/syntax.c, src/screen.c, src/gui.h, src/structs.h *** ../vim-8.0.1543/src/syntax.c 2018-02-27 13:04:55.028256869 +0100 --- src/syntax.c 2018-02-27 14:36:40.461896013 +0100 *************** *** 8952,8959 **** vim_memset(&at_en, 0, sizeof(attrentry_T)); at_en.ae_attr = attr; ! at_en.ae_u.cterm.fg_rgb = fg; ! at_en.ae_u.cterm.bg_rgb = bg; return get_attr_entry(&cterm_attr_table, &at_en); } #endif --- 8952,8969 ---- vim_memset(&at_en, 0, sizeof(attrentry_T)); at_en.ae_attr = attr; ! if (fg == INVALCOLOR && bg == INVALCOLOR) ! { ! /* If both GUI colors are not set fall back to the cterm colors. Helps ! * if the GUI only has an attribute, such as undercurl. */ ! at_en.ae_u.cterm.fg_rgb = CTERMCOLOR; ! at_en.ae_u.cterm.bg_rgb = CTERMCOLOR; ! } ! else ! { ! at_en.ae_u.cterm.fg_rgb = fg; ! at_en.ae_u.cterm.bg_rgb = bg; ! } return get_attr_entry(&cterm_attr_table, &at_en); } #endif *************** *** 9094,9103 **** 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_TERMGUICOLORS ! 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 } } --- 9104,9126 ---- 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_TERMGUICOLORS ! /* If both fg and bg are not set fall back to cterm colors. ! * Helps for SpellBad which uses undercurl in the GUI. */ ! if (COLOR_INVALID(spell_aep->ae_u.cterm.fg_rgb) ! && COLOR_INVALID(spell_aep->ae_u.cterm.bg_rgb)) ! { ! if (spell_aep->ae_u.cterm.fg_color > 0) ! new_en.ae_u.cterm.fg_rgb = CTERMCOLOR; ! if (spell_aep->ae_u.cterm.bg_color > 0) ! new_en.ae_u.cterm.bg_rgb = CTERMCOLOR; ! } ! else ! { ! 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 } } *************** *** 9592,9597 **** --- 9615,9628 ---- # endif at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg); at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg); + if (at_en.ae_u.cterm.fg_rgb == INVALCOLOR + && at_en.ae_u.cterm.bg_rgb == INVALCOLOR) + { + /* If both fg and bg are invalid fall back to the cterm colors. + * Helps when the GUI only uses an attribute, e.g. undercurl. */ + at_en.ae_u.cterm.fg_rgb = CTERMCOLOR; + at_en.ae_u.cterm.bg_rgb = CTERMCOLOR; + } # endif sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en); } *** ../vim-8.0.1543/src/screen.c 2018-02-22 21:06:44.566818882 +0100 --- src/screen.c 2018-02-27 14:21:13.835865569 +0100 *************** *** 8066,8081 **** } if ((attr & HL_BOLD) && *T_MD != NUL) /* bold */ out_str(T_MD); ! else if (aep != NULL && cterm_normal_fg_bold && #ifdef FEAT_TERMGUICOLORS ! (p_tgc ? ! (aep->ae_u.cterm.fg_rgb != INVALCOLOR): #endif ! (t_colors > 1 && aep->ae_u.cterm.fg_color) ! #ifdef FEAT_TERMGUICOLORS ! ) ! #endif ! ) /* If the Normal FG color has BOLD attribute and the new HL * has a FG color defined, clear BOLD. */ out_str(T_ME); --- 8066,8078 ---- } if ((attr & HL_BOLD) && *T_MD != NUL) /* bold */ out_str(T_MD); ! else if (aep != NULL && cterm_normal_fg_bold && ( #ifdef FEAT_TERMGUICOLORS ! p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR ! ? aep->ae_u.cterm.fg_rgb != INVALCOLOR ! : #endif ! t_colors > 1 && aep->ae_u.cterm.fg_color)) /* If the Normal FG color has BOLD attribute and the new HL * has a FG color defined, clear BOLD. */ out_str(T_ME); *************** *** 8101,8128 **** if (aep != NULL) { #ifdef FEAT_TERMGUICOLORS ! if (p_tgc) { 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 (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); ! } } } } --- 8098,8136 ---- if (aep != NULL) { #ifdef FEAT_TERMGUICOLORS ! /* When 'termguicolors' is set but fg or bg is unset, ! * fall back to the cterm colors. This helps for SpellBad, ! * where the GUI uses a red undercurl. */ ! if (p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR) { if (aep->ae_u.cterm.fg_rgb != INVALCOLOR) term_fg_rgb_color(aep->ae_u.cterm.fg_rgb); + } + else + #endif + if (t_colors > 1) + { + if (aep->ae_u.cterm.fg_color) + term_fg_color(aep->ae_u.cterm.fg_color - 1); + } + #ifdef FEAT_TERMGUICOLORS + if (p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR) + { if (aep->ae_u.cterm.bg_rgb != INVALCOLOR) term_bg_rgb_color(aep->ae_u.cterm.bg_rgb); } else #endif + if (t_colors > 1) + { + if (aep->ae_u.cterm.bg_color) + term_bg_color(aep->ae_u.cterm.bg_color - 1); + } + + if (t_colors <= 1) { ! if (aep->ae_u.term.start != NULL) ! out_str(aep->ae_u.term.start); } } } *************** *** 8162,8178 **** * Assume that t_me restores the original colors! */ aep = syn_cterm_attr2entry(screen_attr); ! if (aep != NULL && #ifdef FEAT_TERMGUICOLORS ! (p_tgc ? ! (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_TERMGUICOLORS ! ) #endif ! ) do_ME = TRUE; } else --- 8170,8188 ---- * Assume that t_me restores the original colors! */ aep = syn_cterm_attr2entry(screen_attr); ! if (aep != NULL && (( #ifdef FEAT_TERMGUICOLORS ! p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR ! ? aep->ae_u.cterm.fg_rgb != INVALCOLOR ! : #endif ! aep->ae_u.cterm.fg_color) || ( #ifdef FEAT_TERMGUICOLORS ! p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR ! ? aep->ae_u.cterm.bg_rgb != INVALCOLOR ! : #endif ! aep->ae_u.cterm.bg_color))) do_ME = TRUE; } else *** ../vim-8.0.1543/src/gui.h 2017-11-18 22:13:04.749908702 +0100 --- src/gui.h 2018-02-27 13:41:49.758915785 +0100 *************** *** 207,212 **** --- 207,214 ---- #define INVALCOLOR (guicolor_T)-11111 /* number for invalid color; on 32 bit displays there is a tiny chance this is an actual color */ + #define CTERMCOLOR (guicolor_T)-11110 /* only used for cterm.bg_rgb and + cterm.fg_rgb: use cterm color */ #ifdef FEAT_GUI_GTK typedef PangoFontDescription *GuiFont; /* handle for a GUI font */ *** ../vim-8.0.1543/src/structs.h 2018-02-11 19:06:20.269418910 +0100 --- src/structs.h 2018-02-27 13:42:58.618494224 +0100 *************** *** 101,107 **** --- 101,110 ---- # endif # define guicolor_T long # define INVALCOLOR ((guicolor_T)0x1ffffff) + /* only used for cterm.bg_rgb and cterm.fg_rgb: use cterm color */ + # define CTERMCOLOR ((guicolor_T)0x1fffffe) #endif + #define COLOR_INVALID(x) ((x) == INVALCOLOR || (x) == CTERMCOLOR) /* * marks: positions in a file *** ../vim-8.0.1543/src/version.c 2018-02-27 13:04:55.028256869 +0100 --- src/version.c 2018-02-27 14:25:32.306239017 +0100 *************** *** 780,781 **** --- 780,783 ---- { /* Add new patch number below this line */ + /**/ + 1544, /**/ -- FROG: How you English say: I one more time, mac, I unclog my nose towards you, sons of a window-dresser, so, you think you could out-clever us French fellows with your silly knees-bent creeping about advancing behaviour. (blows a raspberry) I wave my private parts at your aunties, you brightly-coloured, mealy-templed, cranberry-smelling, electric donkey-bottom biters. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///