diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 25 | ||||
-rw-r--r-- | src/gui.c | 2 | ||||
-rw-r--r-- | src/hardcopy.c | 1 | ||||
-rw-r--r-- | src/highlight.c | 33 | ||||
-rw-r--r-- | src/optiondefs.h | 5 | ||||
-rw-r--r-- | src/screen.c | 22 | ||||
-rw-r--r-- | src/term.c | 4 | ||||
-rw-r--r-- | src/termdefs.h | 6 | ||||
-rw-r--r-- | src/testdir/test_highlight.vim | 10 | ||||
-rw-r--r-- | src/testdir/test_options.vim | 12 | ||||
-rw-r--r-- | src/testdir/test_syn_attr.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 11 |
13 files changed, 110 insertions, 30 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 0b8fd43966..f51aade495 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -10104,14 +10104,27 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv) break; case 'u': - if (TOLOWER_ASC(what[1]) == 'l') // ul - p = highlight_color(id, what, modec); - else if (STRLEN(what) <= 5 || TOLOWER_ASC(what[5]) != 'c') + if (STRLEN(what) >= 9) + { + if (TOLOWER_ASC(what[5]) == 'l') // underline - p = highlight_has_attr(id, HL_UNDERLINE, modec); - else + p = highlight_has_attr(id, HL_UNDERLINE, modec); + else if (TOLOWER_ASC(what[5]) != 'd') // undercurl - p = highlight_has_attr(id, HL_UNDERCURL, modec); + p = highlight_has_attr(id, HL_UNDERCURL, modec); + else if (TOLOWER_ASC(what[6]) != 'o') + // underdashed + p = highlight_has_attr(id, HL_UNDERDASHED, modec); + else if (TOLOWER_ASC(what[7]) == 'u') + // underdouble + p = highlight_has_attr(id, HL_UNDERDOUBLE, modec); + else + // underdotted + p = highlight_has_attr(id, HL_UNDERDOTTED, modec); + } + else + // ul + p = highlight_color(id, what, modec); break; } @@ -2501,6 +2501,8 @@ gui_outstr_nowrap( if (hl_mask_todo & HL_UNDERCURL) draw_flags |= DRAW_UNDERC; + // TODO: HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED + // Do we strikethrough the text? if (hl_mask_todo & HL_STRIKETHROUGH) draw_flags |= DRAW_STRIKE; diff --git a/src/hardcopy.c b/src/hardcopy.c index e2e5211624..dd1f2e071e 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -293,6 +293,7 @@ prt_get_attr( pattr->italic = (highlight_has_attr(hl_id, HL_ITALIC, modec) != NULL); pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL); pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL); + // TODO: HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) if (USE_24BIT) diff --git a/src/highlight.c b/src/highlight.c index bf876d16f1..575451e705 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -25,10 +25,16 @@ * following names, separated by commas (but no spaces!). */ static char *(hl_name_table[]) = - {"bold", "standout", "underline", "undercurl", - "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"}; + {"bold", "standout", "underline", + "undercurl", "underdouble", "underdotted", "underdashed", + "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"}; static int hl_attr_table[] = - {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0}; + {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, + HL_UNDERCURL, HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED, + HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0}; +// length of all attribute names, plus commas, together (and a bit more) +#define MAX_ATTR_LEN 120 + #define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? (attr_b) : (attr_a)) | (attr_b)) /* @@ -2963,7 +2969,7 @@ highlight_list_arg( char_u *sarg, char *name) { - char_u buf[100]; + char_u buf[MAX_ATTR_LEN]; char_u *ts; int i; @@ -2984,8 +2990,8 @@ highlight_list_arg( if (iarg & hl_attr_table[i]) { if (buf[0] != NUL) - vim_strcat(buf, (char_u *)",", 100); - vim_strcat(buf, (char_u *)hl_name_table[i], 100); + vim_strcat(buf, (char_u *)",", MAX_ATTR_LEN); + vim_strcat(buf, (char_u *)hl_name_table[i], MAX_ATTR_LEN); iarg &= ~hl_attr_table[i]; // don't want "inverse" } } @@ -3287,7 +3293,8 @@ set_hl_attr( at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg); // Only use the underline/undercurl color when used, it may clear the // background color if not supported. - if (sgp->sg_cterm & (HL_UNDERLINE | HL_UNDERCURL)) + if (sgp->sg_cterm & (HL_UNDERLINE | HL_UNDERCURL + | HL_UNDERDOUBLE | HL_UNDERDOTTED | HL_UNDERDASHED)) at_en.ae_u.cterm.ul_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_sp); else at_en.ae_u.cterm.ul_rgb = INVALCOLOR; @@ -3801,6 +3808,12 @@ highlight_changed(void) break; case 'c': attr |= HL_UNDERCURL; break; + case '2': attr |= HL_UNDERDOUBLE; + break; + case 'd': attr |= HL_UNDERDOTTED; + break; + case '=': attr |= HL_UNDERDASHED; + break; case 't': attr |= HL_STRIKETHROUGH; break; case ':': ++p; // highlight group name @@ -4362,9 +4375,9 @@ hlg_add_or_update(dict_T *dict) { char_u *name; int error; - char_u term_attr[80]; - char_u cterm_attr[80]; - char_u gui_attr[80]; + char_u term_attr[MAX_ATTR_LEN]; + char_u cterm_attr[MAX_ATTR_LEN]; + char_u gui_attr[MAX_ATTR_LEN]; char_u *start; char_u *stop; char_u *ctermfg; diff --git a/src/optiondefs.h b/src/optiondefs.h index aca3737550..03e472ff9e 100644 --- a/src/optiondefs.h +++ b/src/optiondefs.h @@ -2893,9 +2893,9 @@ static struct vimoption options[] = p_term("t_BD", T_BD) p_term("t_cd", T_CD) p_term("t_ce", T_CE) + p_term("t_Ce", T_UCE) p_term("t_cl", T_CL) p_term("t_cm", T_CM) - p_term("t_Ce", T_UCE) p_term("t_Co", T_CCO) p_term("t_CS", T_CCS) p_term("t_Cs", T_UCS) @@ -2905,6 +2905,8 @@ static struct vimoption options[] = p_term("t_db", T_DB) p_term("t_DL", T_CDL) p_term("t_dl", T_DL) + p_term("t_ds", T_DS) + p_term("t_Ds", T_CDS) p_term("t_EC", T_CEC) p_term("t_EI", T_CEI) p_term("t_fs", T_FS) @@ -2952,6 +2954,7 @@ static struct vimoption options[] = p_term("t_u7", T_U7) p_term("t_ue", T_UE) p_term("t_us", T_US) + p_term("t_Us", T_USS) p_term("t_ut", T_UT) p_term("t_vb", T_VB) p_term("t_ve", T_VE) diff --git a/src/screen.c b/src/screen.c index 82a0e91ddc..01518882f2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1855,8 +1855,17 @@ screen_start_highlight(int attr) out_str(T_SO); if ((attr & HL_UNDERCURL) && *T_UCS != NUL) // undercurl out_str(T_UCS); - if (((attr & HL_UNDERLINE) // underline or undercurl - || ((attr & HL_UNDERCURL) && *T_UCS == NUL)) + if ((attr & HL_UNDERDOUBLE) && *T_USS != NUL) // double underline + out_str(T_USS); + if ((attr & HL_UNDERDOTTED) && *T_DS != NUL) // dotted underline + out_str(T_DS); + if ((attr & HL_UNDERDASHED) && *T_CDS != NUL) // dashed underline + out_str(T_CDS); + if (((attr & HL_UNDERLINE) // underline or undercurl, etc. + || ((attr & HL_UNDERCURL) && *T_UCS == NUL) + || ((attr & HL_UNDERDOUBLE) && *T_USS == NUL) + || ((attr & HL_UNDERDOTTED) && *T_DS == NUL) + || ((attr & HL_UNDERDASHED) && *T_CDS == NUL)) && *T_US != NUL) out_str(T_US); if ((attr & HL_ITALIC) && *T_CZH != NUL) // italic @@ -1951,6 +1960,8 @@ screen_stop_highlight(void) else #endif { + int is_under; + if (screen_attr > HL_ALL) // special HL attr. { attrentry_T *aep; @@ -2030,15 +2041,16 @@ screen_stop_highlight(void) else out_str(T_SE); } - if ((screen_attr & HL_UNDERCURL) && *T_UCE != NUL) + is_under = (screen_attr & (HL_UNDERCURL + | HL_UNDERDOUBLE | HL_UNDERDOTTED | HL_UNDERDASHED)); + if (is_under && *T_UCE != NUL) { if (STRCMP(T_UCE, T_ME) == 0) do_ME = TRUE; else out_str(T_UCE); } - if ((screen_attr & HL_UNDERLINE) - || ((screen_attr & HL_UNDERCURL) && *T_UCE == NUL)) + if ((screen_attr & HL_UNDERLINE) || (is_under && *T_UCE == NUL)) { if (STRCMP(T_UE, T_ME) == 0) do_ME = TRUE; diff --git a/src/term.c b/src/term.c index b365831146..754ef822d8 100644 --- a/src/term.c +++ b/src/term.c @@ -1187,6 +1187,9 @@ static struct builtin_term builtin_termcaps[] = {(int)KS_US, "[US]"}, {(int)KS_UCE, "[UCE]"}, {(int)KS_UCS, "[UCS]"}, + {(int)KS_USS, "[USS]"}, + {(int)KS_DS, "[DS]"}, + {(int)KS_CDS, "[CDS]"}, {(int)KS_STE, "[STE]"}, {(int)KS_STS, "[STS]"}, {(int)KS_MS, "[MS]"}, @@ -1669,6 +1672,7 @@ get_term_entries(int *height, int *width) {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, + {KS_USS, "Us"}, {KS_DS, "ds"}, {KS_CDS, "Ds"}, {KS_STE,"Te"}, {KS_STS,"Ts"}, {KS_CM, "cm"}, {KS_SR, "sr"}, {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, diff --git a/src/termdefs.h b/src/termdefs.h index a3d8299990..133641b5c0 100644 --- a/src/termdefs.h +++ b/src/termdefs.h @@ -55,6 +55,9 @@ enum SpecialKey KS_US, // underscore (underline) mode KS_UCE, // exit undercurl mode KS_UCS, // undercurl mode + KS_USS, // double underline mode + KS_DS, // dotted underline mode + KS_CDS, // dashed underline mode KS_STE, // exit strikethrough mode KS_STS, // strikethrough mode KS_MS, // save to move cur in reverse mode @@ -160,6 +163,9 @@ extern char_u *(term_strings[]); // current terminal strings #define T_US (TERM_STR(KS_US)) // underscore (underline) mode #define T_UCE (TERM_STR(KS_UCE)) // exit undercurl mode #define T_UCS (TERM_STR(KS_UCS)) // undercurl mode +#define T_USS (TERM_STR(KS_USS)) // double underline mode +#define T_DS (TERM_STR(KS_DS)) // dotted underline mode +#define T_CDS (TERM_STR(KS_CDS)) // dashed underline mode #define T_STE (TERM_STR(KS_STE)) // exit strikethrough mode #define T_STS (TERM_STR(KS_STS)) // strikethrough mode #define T_MS (TERM_STR(KS_MS)) // save to move cur in reverse mode diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim index 3400052a7c..ef9c70e7e9 100644 --- a/src/testdir/test_highlight.vim +++ b/src/testdir/test_highlight.vim @@ -888,8 +888,8 @@ endfunc " Test for setting various 'term' attributes func Test_highlight_term_attr() - hi HlGrp3 term=bold,underline,undercurl,strikethrough,reverse,italic,standout - call assert_equal('hi HlGrp3 term=bold,standout,underline,undercurl,italic,reverse,strikethrough', HighlightArgs('HlGrp3')) + hi HlGrp3 term=bold,underline,undercurl,underdouble,underdotted,underdashed,strikethrough,reverse,italic,standout + call assert_equal('hi HlGrp3 term=bold,standout,underline,undercurl,underdouble,underdotted,underdashed,italic,reverse,strikethrough', HighlightArgs('HlGrp3')) hi HlGrp3 term=NONE call assert_equal('hi HlGrp3 cleared', HighlightArgs('HlGrp3')) hi clear @@ -1174,12 +1174,14 @@ func Test_hlset() " Test for setting all the 'term', 'cterm' and 'gui' attributes of a " highlight group let lines =<< trim END - VAR attr = {'bold': v:true, 'underline': v:true, 'undercurl': v:true, + VAR attr = {'bold': v:true, 'underline': v:true, + \ 'undercurl': v:true, 'underdouble': v:true, + \ 'underdotted': v:true, 'underdashed': v:true, \ 'strikethrough': v:true, 'reverse': v:true, 'italic': v:true, \ 'standout': v:true, 'nocombine': v:true} call hlset([{'name': 'myhlg2', 'term': attr, 'cterm': attr, 'gui': attr}]) VAR id2 = hlID('myhlg2') - VAR expected = "myhlg2 xxx term=bold,standout,underline,undercurl,italic,reverse,nocombine,strikethrough cterm=bold,standout,underline,undercurl,italic,reverse,nocombine,strikethrough gui=bold,standout,underline,undercurl,italic,reverse,nocombine,strikethrough" + VAR expected = "myhlg2 xxx term=bold,standout,underline,undercurl,underdouble,underdotted,underdashed,italic,reverse,nocombine,strikethrough cterm=bold,standout,underline,undercurl,underdouble,underdotted,underdashed,italic,reverse,nocombine,strikethrough gui=bold,standout,underline,undercurl,underdouble,underdotted,underdashed,italic,reverse,nocombine,strikethrough" VAR output = execute('highlight myhlg2') LET output = output->split("\n")->join()->substitute('\s\+', ' ', 'g') call assert_equal(expected, output) diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 0a533152b9..fbe592d165 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -955,6 +955,18 @@ func Test_opt_set_keycode() set <F9>=xyz call assert_equal('xyz', &t_k9) set <t_k9>& + + " should we test all of them? + set t_Ce=testCe + set t_Cs=testCs + set t_Us=testUs + set t_ds=testds + set t_Ds=testDs + call assert_equal('testCe', &t_Ce) + call assert_equal('testCs', &t_Cs) + call assert_equal('testUs', &t_Us) + call assert_equal('testds', &t_ds) + call assert_equal('testDs', &t_Ds) endfunc " Test for changing options in a sandbox diff --git a/src/testdir/test_syn_attr.vim b/src/testdir/test_syn_attr.vim index db9c9e93af..366f39f468 100644 --- a/src/testdir/test_syn_attr.vim +++ b/src/testdir/test_syn_attr.vim @@ -11,10 +11,17 @@ func Test_missing_attr() hi Mine term=reverse cterm=inverse call assert_equal('1', synIDattr(hlID("Mine"), "reverse", 'term')) call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm')) + hi Mine term=underline cterm=standout gui=undercurl call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term')) call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm')) call assert_equal('1', synIDattr("Mine"->hlID(), "undercurl", 'gui')) + + hi Mine term=underdouble cterm=underdotted gui=underdashed + call assert_equal('1', synIDattr(hlID("Mine"), "underdouble", 'term')) + call assert_equal('1', synIDattr(hlID("Mine"), "underdotted", 'cterm')) + call assert_equal('1', synIDattr("Mine"->hlID(), "underdashed", 'gui')) + hi Mine gui=strikethrough call assert_equal('1', synIDattr(hlID("Mine"), "strikethrough", 'gui')) hi Mine term=NONE cterm=NONE gui=NONE diff --git a/src/version.c b/src/version.c index 98227fa445..e6255059d6 100644 --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 7, +/**/ 6, /**/ 5, @@ -659,10 +659,13 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring); #define HL_ITALIC 0x04 #define HL_UNDERLINE 0x08 #define HL_UNDERCURL 0x10 -#define HL_STANDOUT 0x20 -#define HL_NOCOMBINE 0x40 -#define HL_STRIKETHROUGH 0x80 -#define HL_ALL 0xff +#define HL_UNDERDOUBLE 0x20 +#define HL_UNDERDOTTED 0x40 +#define HL_UNDERDASHED 0x80 +#define HL_STANDOUT 0x100 +#define HL_NOCOMBINE 0x200 +#define HL_STRIKETHROUGH 0x400 +#define HL_ALL 0x7ff // special attribute addition: Put message in history #define MSG_HIST 0x1000 |