]> granicus.if.org Git - vim/commitdiff
patch 8.2.1771: synIDattr() cannot get the value of ctermul v8.2.1771
authorBram Moolenaar <Bram@vim.org>
Tue, 29 Sep 2020 18:59:17 +0000 (20:59 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 29 Sep 2020 18:59:17 +0000 (20:59 +0200)
Problem:    synIDattr() cannot get the value of ctermul.
Solution:   Add the "ul" value for "what". (closes #7037)

runtime/doc/eval.txt
src/evalfunc.c
src/highlight.c
src/testdir/test_highlight.vim
src/version.c

index 58c390ebb4bc58bfe66112385490463b388375d1..6bf205d4e35fd3b7da48899d05d244e5d32b0342 100644 (file)
@@ -10348,7 +10348,9 @@ synIDattr({synID}, {what} [, {mode}])                   *synIDattr()*
                "bg"            background color (as with "fg")
                "font"          font name (only available in the GUI)
                                |highlight-font|
-               "sp"            special color (as with "fg") |highlight-guisp|
+               "sp"            special color for the GUI (as with "fg")
+                               |highlight-guisp|
+               "ul"            underline color for cterm: number as a string
                "fg#"           like "fg", but for the GUI and the GUI is
                                running the name in "#RRGGBB" form
                "bg#"           like "fg#" for "bg"
index 2af4bc00d6b6192cfce8326439ee5cca184dc5b2..cf1e26533045810e94d923e4b97a41c15e512654 100644 (file)
@@ -8604,7 +8604,9 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
                break;
 
        case 'u':
-               if (STRLEN(what) <= 5 || TOLOWER_ASC(what[5]) != 'c')
+               if (TOLOWER_ASC(what[1]) == 'l')        // ul
+                   p = highlight_color(id, what, modec);
+               else if (STRLEN(what) <= 5 || TOLOWER_ASC(what[5]) != 'c')
                                                        // underline
                    p = highlight_has_attr(id, HL_UNDERLINE, modec);
                else
index 0a014473b137db9397a6b37fbe803d909b65d031..56b1988835046bee1f6d4110b70422eaaa122673 100644 (file)
@@ -2684,13 +2684,14 @@ highlight_has_attr(
     char_u *
 highlight_color(
     int                id,
-    char_u     *what,  // "font", "fg", "bg", "sp", "fg#", "bg#" or "sp#"
+    char_u     *what,  // "font", "fg", "bg", "sp", "ul", "fg#", "bg#" or "sp#"
     int                modec)  // 'g' for GUI, 'c' for cterm, 't' for term
 {
     static char_u      name[20];
     int                        n;
     int                        fg = FALSE;
     int                        sp = FALSE;
+    int                        ul = FALSE;
     int                        font = FALSE;
 
     if (id <= 0 || id > highlight_ga.ga_len)
@@ -2703,6 +2704,8 @@ highlight_color(
        font = TRUE;
     else if (TOLOWER_ASC(what[0]) == 's' && TOLOWER_ASC(what[1]) == 'p')
        sp = TRUE;
+    else if (TOLOWER_ASC(what[0]) == 'u' && TOLOWER_ASC(what[1]) == 'l')
+       ul = TRUE;
     else if (!(TOLOWER_ASC(what[0]) == 'b' && TOLOWER_ASC(what[1]) == 'g'))
        return NULL;
     if (modec == 'g')
@@ -2749,6 +2752,8 @@ highlight_color(
     {
        if (fg)
            n = HL_TABLE()[id - 1].sg_cterm_fg - 1;
+       else if (ul)
+           n = HL_TABLE()[id - 1].sg_cterm_ul - 1;
        else
            n = HL_TABLE()[id - 1].sg_cterm_bg - 1;
        if (n < 0)
index 05f215ae387a00e9a75995eb535f179eafbab00c..8bd03e2da12aad646b9c1cfe73b893e5e5844742 100644 (file)
@@ -808,6 +808,7 @@ func Test_highlight_ctermul()
   call assert_notmatch('ctermul=', HighlightArgs('Normal'))
   highlight Normal ctermul=3
   call assert_match('ctermul=3', HighlightArgs('Normal'))
+  call assert_equal('3', synIDattr(synIDtrans(hlID('Normal')), 'ul'))
   highlight Normal ctermul=NONE
 endfunc
 
index 26e63c2bd23a67739f7b2606b9ebe4a25ece51ac..d390212d8ae5a8591f5f47ed9455cb102c3e2a59 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1771,
 /**/
     1770,
 /**/