comparison src/highlight.c @ 29328:60977de70684 v9.0.0007

patch 9.0.0007: no support for double, dotted and dashed underlines Commit: https://github.com/vim/vim/commit/84f546363068e4ddfe14a8a2a2322bb8d3a25417 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 29 18:39:11 2022 +0100 patch 9.0.0007: no support for double, dotted and dashed underlines Problem: No support for double, dotted and dashed underlines. Solution: Add the termcap entries and highlight modes. (closes https://github.com/vim/vim/issues/9553)
author Bram Moolenaar <Bram@vim.org>
date Wed, 29 Jun 2022 19:45:03 +0200
parents a74398c432a4
children 827d9f2b7a71
comparison
equal deleted inserted replaced
29327:4675995a5b8a 29328:60977de70684
23 /* 23 /*
24 * The "term", "cterm" and "gui" arguments can be any combination of the 24 * The "term", "cterm" and "gui" arguments can be any combination of the
25 * following names, separated by commas (but no spaces!). 25 * following names, separated by commas (but no spaces!).
26 */ 26 */
27 static char *(hl_name_table[]) = 27 static char *(hl_name_table[]) =
28 {"bold", "standout", "underline", "undercurl", 28 {"bold", "standout", "underline",
29 "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"}; 29 "undercurl", "underdouble", "underdotted", "underdashed",
30 "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"};
30 static int hl_attr_table[] = 31 static int hl_attr_table[] =
31 {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0}; 32 {HL_BOLD, HL_STANDOUT, HL_UNDERLINE,
33 HL_UNDERCURL, HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED,
34 HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0};
35 // length of all attribute names, plus commas, together (and a bit more)
36 #define MAX_ATTR_LEN 120
37
32 #define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? (attr_b) : (attr_a)) | (attr_b)) 38 #define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? (attr_b) : (attr_a)) | (attr_b))
33 39
34 /* 40 /*
35 * Structure that stores information about a highlight group. 41 * Structure that stores information about a highlight group.
36 * The ID of a highlight group is also called group ID. It is the index in 42 * The ID of a highlight group is also called group ID. It is the index in
2961 int type, 2967 int type,
2962 int iarg, 2968 int iarg,
2963 char_u *sarg, 2969 char_u *sarg,
2964 char *name) 2970 char *name)
2965 { 2971 {
2966 char_u buf[100]; 2972 char_u buf[MAX_ATTR_LEN];
2967 char_u *ts; 2973 char_u *ts;
2968 int i; 2974 int i;
2969 2975
2970 if (got_int) 2976 if (got_int)
2971 return FALSE; 2977 return FALSE;
2982 for (i = 0; hl_attr_table[i] != 0; ++i) 2988 for (i = 0; hl_attr_table[i] != 0; ++i)
2983 { 2989 {
2984 if (iarg & hl_attr_table[i]) 2990 if (iarg & hl_attr_table[i])
2985 { 2991 {
2986 if (buf[0] != NUL) 2992 if (buf[0] != NUL)
2987 vim_strcat(buf, (char_u *)",", 100); 2993 vim_strcat(buf, (char_u *)",", MAX_ATTR_LEN);
2988 vim_strcat(buf, (char_u *)hl_name_table[i], 100); 2994 vim_strcat(buf, (char_u *)hl_name_table[i], MAX_ATTR_LEN);
2989 iarg &= ~hl_attr_table[i]; // don't want "inverse" 2995 iarg &= ~hl_attr_table[i]; // don't want "inverse"
2990 } 2996 }
2991 } 2997 }
2992 } 2998 }
2993 2999
3285 # ifdef FEAT_TERMGUICOLORS 3291 # ifdef FEAT_TERMGUICOLORS
3286 at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg); 3292 at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg);
3287 at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg); 3293 at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg);
3288 // Only use the underline/undercurl color when used, it may clear the 3294 // Only use the underline/undercurl color when used, it may clear the
3289 // background color if not supported. 3295 // background color if not supported.
3290 if (sgp->sg_cterm & (HL_UNDERLINE | HL_UNDERCURL)) 3296 if (sgp->sg_cterm & (HL_UNDERLINE | HL_UNDERCURL
3297 | HL_UNDERDOUBLE | HL_UNDERDOTTED | HL_UNDERDASHED))
3291 at_en.ae_u.cterm.ul_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_sp); 3298 at_en.ae_u.cterm.ul_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_sp);
3292 else 3299 else
3293 at_en.ae_u.cterm.ul_rgb = INVALCOLOR; 3300 at_en.ae_u.cterm.ul_rgb = INVALCOLOR;
3294 if (at_en.ae_u.cterm.fg_rgb == INVALCOLOR 3301 if (at_en.ae_u.cterm.fg_rgb == INVALCOLOR
3295 && at_en.ae_u.cterm.bg_rgb == INVALCOLOR) 3302 && at_en.ae_u.cterm.bg_rgb == INVALCOLOR)
3799 break; 3806 break;
3800 case 'u': attr |= HL_UNDERLINE; 3807 case 'u': attr |= HL_UNDERLINE;
3801 break; 3808 break;
3802 case 'c': attr |= HL_UNDERCURL; 3809 case 'c': attr |= HL_UNDERCURL;
3803 break; 3810 break;
3811 case '2': attr |= HL_UNDERDOUBLE;
3812 break;
3813 case 'd': attr |= HL_UNDERDOTTED;
3814 break;
3815 case '=': attr |= HL_UNDERDASHED;
3816 break;
3804 case 't': attr |= HL_STRIKETHROUGH; 3817 case 't': attr |= HL_STRIKETHROUGH;
3805 break; 3818 break;
3806 case ':': ++p; // highlight group name 3819 case ':': ++p; // highlight group name
3807 if (attr || *p == NUL) // no combinations 3820 if (attr || *p == NUL) // no combinations
3808 return FAIL; 3821 return FAIL;
4360 static int 4373 static int
4361 hlg_add_or_update(dict_T *dict) 4374 hlg_add_or_update(dict_T *dict)
4362 { 4375 {
4363 char_u *name; 4376 char_u *name;
4364 int error; 4377 int error;
4365 char_u term_attr[80]; 4378 char_u term_attr[MAX_ATTR_LEN];
4366 char_u cterm_attr[80]; 4379 char_u cterm_attr[MAX_ATTR_LEN];
4367 char_u gui_attr[80]; 4380 char_u gui_attr[MAX_ATTR_LEN];
4368 char_u *start; 4381 char_u *start;
4369 char_u *stop; 4382 char_u *stop;
4370 char_u *ctermfg; 4383 char_u *ctermfg;
4371 char_u *ctermbg; 4384 char_u *ctermbg;
4372 char_u *ctermul; 4385 char_u *ctermul;