To: vim_dev@googlegroups.com Subject: Patch 8.2.3664 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3664 Problem: Cannot adjust sign highlighting for 'cursorline'. Solution: Add CursorLineSign and CursorLineFold highlight groups. (Gregory Anders, closes #9201) Files: runtime/doc/sign.txt, runtime/doc/syntax.txt, src/drawline.c, src/highlight.c, src/optiondefs.h, src/popupwin.c, src/proto/sign.pro, src/sign.c, src/structs.h, src/vim.h, src/testdir/test_signs.vim *** ../vim-8.2.3663/runtime/doc/sign.txt 2021-09-17 20:06:53.120560956 +0100 --- runtime/doc/sign.txt 2021-11-24 16:07:43.386152794 +0000 *************** *** 53,58 **** --- 53,60 ---- :highlight SignColumn guibg=darkgrey < + If 'cursorline' is enabled, then the CursorLineSign highlight group is used + |hl-CursorLineSign|. *sign-identifier* Each placed sign is identified by a number called the sign identifier. This identifier is used to jump to the sign or to remove the sign. The identifier *************** *** 146,151 **** --- 148,160 ---- texthl={group} Highlighting group used for the text item. + culhl={group} + Highlighting group used for the text item when the cursor is + on the same line as the sign and 'cursorline' is enabled. + + Example: > + :sign define MySign text=>> texthl=Search linehl=DiffText + < DELETING A SIGN *:sign-undefine* *E155* *************** *** 377,382 **** --- 399,407 ---- text text that is displayed when there is no icon or the GUI is not being used. texthl highlight group used for the text item + culhl highlight group used for the text item when + the cursor is on the same line as the sign and + 'cursorline' is enabled. If the sign named {name} already exists, then the attributes of the sign are updated. *************** *** 421,426 **** --- 446,454 ---- text text that is displayed when there is no icon or the GUI is not being used. texthl highlight group used for the text item + culhl highlight group used for the text item when + the cursor is on the same line as the sign and + 'cursorline' is enabled. Returns an empty List if there are no signs and when {name} is not found. *** ../vim-8.2.3663/runtime/doc/syntax.txt 2021-11-03 21:56:41.218795250 +0000 --- runtime/doc/syntax.txt 2021-11-24 16:07:43.390152785 +0000 *************** *** 5198,5206 **** LineNrBelow Line number for when the 'relativenumber' option is set, below the cursor line. *hl-CursorLineNr* ! CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' is ! set to "number" or "both", or 'relativenumber' is set, for ! the cursor line. *hl-MatchParen* MatchParen The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| --- 5249,5260 ---- LineNrBelow Line number for when the 'relativenumber' option is set, below the cursor line. *hl-CursorLineNr* ! CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' ! contains "number" or is "both", for the cursor line. ! *hl-CursorLineSign* ! CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line. ! *hl-CursorLineFold* ! CursorLineFold Like FoldColumn when 'cursorline' is set for the cursor line. *hl-MatchParen* MatchParen The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| *** ../vim-8.2.3663/src/drawline.c 2021-09-10 15:58:24.446743066 +0100 --- src/drawline.c 2021-11-24 16:15:26.017253325 +0000 *************** *** 77,82 **** --- 77,93 ---- #ifdef FEAT_SIGNS /* + * Return TRUE if CursorLineSign highlight is to be used. + */ + static int + use_cursor_line_sign(win_T *wp, linenr_T lnum) + { + return wp->w_p_cul + && lnum == wp->w_cursor.lnum + && (wp->w_p_culopt_flags & CULOPT_NBR); + } + + /* * Get information needed to display the sign in line 'lnum' in window 'wp'. * If 'nrcol' is TRUE, the sign is going to be displayed in the number column. * Otherwise the sign is going to be displayed in the sign column. *************** *** 85,91 **** get_sign_display_info( int nrcol, win_T *wp, ! linenr_T lnum UNUSED, sign_attrs_T *sattr, int wcr_attr, int row, --- 96,102 ---- get_sign_display_info( int nrcol, win_T *wp, ! linenr_T lnum, sign_attrs_T *sattr, int wcr_attr, int row, *************** *** 111,117 **** *n_extrap = number_width(wp) + 1; else { ! *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC)); *n_extrap = 2; } --- 122,131 ---- *n_extrap = number_width(wp) + 1; else { ! if (use_cursor_line_sign(wp, lnum)) ! *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLS)); ! else ! *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC)); *n_extrap = 2; } *************** *** 176,182 **** *c_finalp = NUL; *n_extrap = (int)STRLEN(*pp_extra); } ! *char_attrp = sattr->sat_texthl; } } } --- 190,200 ---- *c_finalp = NUL; *n_extrap = (int)STRLEN(*pp_extra); } ! ! if (use_cursor_line_sign(wp, lnum) && sattr->sat_culhl > 0) ! *char_attrp = sattr->sat_culhl; ! else ! *char_attrp = sattr->sat_texthl; } } } *************** *** 1051,1057 **** p_extra = p_extra_free; c_extra = NUL; c_final = NUL; ! char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_FC)); } } } --- 1069,1080 ---- p_extra = p_extra_free; c_extra = NUL; c_final = NUL; ! if (use_cursor_line_sign(wp, lnum)) ! char_attr = ! hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLF)); ! else ! char_attr = ! hl_combine_attr(wcr_attr, HL_ATTR(HLF_FC)); } } } *** ../vim-8.2.3663/src/highlight.c 2021-11-20 13:45:37.806729612 +0000 --- src/highlight.c 2021-11-24 16:07:43.390152785 +0000 *************** *** 153,158 **** --- 153,160 ---- "lCursor guibg=fg guifg=bg", // should be different, but what? #endif "default link QuickFixLine Search", + "default link CursorLineSign SignColumn", + "default link CursorLineFold FoldColumn", CENT("Normal cterm=NONE", "Normal gui=NONE"), NULL }; *** ../vim-8.2.3663/src/optiondefs.h 2021-10-17 14:13:04.832665843 +0100 --- src/optiondefs.h 2021-11-24 16:07:43.390152785 +0000 *************** *** 298,304 **** # define ISP_LATIN1 (char_u *)"@,161-255" #endif ! # define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC" // Default python version for pyx* commands #if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) --- 298,304 ---- # define ISP_LATIN1 (char_u *)"@,161-255" #endif ! # define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow,N:CursorLineNr,G:CursorLineSign,O:CursorLineFold,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC" // Default python version for pyx* commands #if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) *** ../vim-8.2.3663/src/popupwin.c 2021-11-20 13:45:37.806729612 +0000 --- src/popupwin.c 2021-11-24 16:07:43.390152785 +0000 *************** *** 632,638 **** if (syn_name2id((char_u *)linehl) == 0) linehl = "PmenuSel"; ! sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL); } sign_place(&sign_id, (char_u *)"PopUpMenu", sign_name, --- 632,638 ---- if (syn_name2id((char_u *)linehl) == 0) linehl = "PmenuSel"; ! sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL, NULL); } sign_place(&sign_id, (char_u *)"PopUpMenu", sign_name, *** ../vim-8.2.3663/src/proto/sign.pro 2019-12-12 11:55:33.000000000 +0000 --- src/proto/sign.pro 2021-11-24 16:07:43.390152785 +0000 *************** *** 8,14 **** int buf_signcount(buf_T *buf, linenr_T lnum); void buf_delete_signs(buf_T *buf, char_u *group); void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after); ! int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text, char_u *texthl); int sign_exists_by_name(char_u *name); int sign_undefine_by_name(char_u *name, int give_error); int sign_place(int *sign_id, char_u *sign_group, char_u *sign_name, buf_T *buf, linenr_T lnum, int prio); --- 8,14 ---- int buf_signcount(buf_T *buf, linenr_T lnum); void buf_delete_signs(buf_T *buf, char_u *group); void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after); ! int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text, char_u *texthl, char_u *culhl); int sign_exists_by_name(char_u *name); int sign_undefine_by_name(char_u *name, int give_error); int sign_place(int *sign_id, char_u *sign_group, char_u *sign_name, buf_T *buf, linenr_T lnum, int prio); *** ../vim-8.2.3663/src/sign.c 2021-09-17 20:06:53.120560956 +0100 --- src/sign.c 2021-11-24 16:07:43.390152785 +0000 *************** *** 32,37 **** --- 32,38 ---- char_u *sn_text; // text used instead of pixmap int sn_line_hl; // highlight ID for line int sn_text_hl; // highlight ID for text + int sn_cul_hl; // highlight ID for text on current line when 'cursorline' is set }; static sign_T *first_sign = NULL; *************** *** 517,522 **** --- 518,525 ---- sattr->sat_texthl = syn_id2attr(sp->sn_text_hl); if (sp->sn_line_hl > 0) sattr->sat_linehl = syn_id2attr(sp->sn_line_hl); + if (sp->sn_cul_hl > 0) + sattr->sat_culhl = syn_id2attr(sp->sn_cul_hl); sattr->sat_priority = sign->se_priority; // If there is another sign next with the same priority, may *************** *** 540,545 **** --- 543,550 ---- sattr->sat_texthl = syn_id2attr(next_sp->sn_text_hl); if (sp->sn_line_hl <= 0 && next_sp->sn_line_hl > 0) sattr->sat_linehl = syn_id2attr(next_sp->sn_line_hl); + if (sp->sn_cul_hl <= 0 && next_sp->sn_cul_hl > 0) + sattr->sat_culhl = syn_id2attr(next_sp->sn_cul_hl); } } return TRUE; *************** *** 1035,1041 **** char_u *icon, char_u *linehl, char_u *text, ! char_u *texthl) { sign_T *sp_prev; sign_T *sp; --- 1040,1047 ---- char_u *icon, char_u *linehl, char_u *text, ! char_u *texthl, ! char_u *culhl) { sign_T *sp_prev; sign_T *sp; *************** *** 1077,1082 **** --- 1083,1091 ---- if (texthl != NULL) sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl)); + if (culhl != NULL) + sp->sn_cul_hl = syn_check_group(culhl, (int)STRLEN(culhl)); + return OK; } *************** *** 1298,1303 **** --- 1307,1313 ---- char_u *text = NULL; char_u *linehl = NULL; char_u *texthl = NULL; + char_u *culhl = NULL; int failed = FALSE; // set values for a defined sign. *************** *** 1327,1332 **** --- 1337,1347 ---- arg += 7; texthl = vim_strnsave(arg, p - arg); } + else if (STRNCMP(arg, "culhl=", 6) == 0) + { + arg += 6; + culhl = vim_strnsave(arg, p - arg); + } else { semsg(_(e_invarg2), arg); *************** *** 1336,1347 **** } if (!failed) ! sign_define_by_name(sign_name, icon, linehl, text, texthl); vim_free(icon); vim_free(text); vim_free(linehl); vim_free(texthl); } /* --- 1351,1363 ---- } if (!failed) ! sign_define_by_name(sign_name, icon, linehl, text, texthl, culhl); vim_free(icon); vim_free(text); vim_free(linehl); vim_free(texthl); + vim_free(culhl); } /* *************** *** 1712,1717 **** --- 1728,1740 ---- p = (char_u *)"NONE"; dict_add_string(retdict, "texthl", (char_u *)p); } + if (sp->sn_cul_hl > 0) + { + p = get_highlight_name_ext(NULL, sp->sn_cul_hl - 1, FALSE); + if (p == NULL) + p = (char_u *)"NONE"; + dict_add_string(retdict, "culhl", (char_u *)p); + } } /* *************** *** 1883,1888 **** --- 1906,1920 ---- else msg_puts((char *)p); } + if (sp->sn_cul_hl > 0) + { + msg_puts(" culhl="); + p = get_highlight_name_ext(NULL, sp->sn_cul_hl - 1, FALSE); + if (p == NULL) + msg_puts("NONE"); + else + msg_puts((char *)p); + } } /* *************** *** 2173,2178 **** --- 2205,2211 ---- char_u *linehl = NULL; char_u *text = NULL; char_u *texthl = NULL; + char_u *culhl = NULL; int retval = -1; if (name_arg == NULL) *************** *** 2191,2199 **** linehl = dict_get_string(dict, (char_u *)"linehl", TRUE); text = dict_get_string(dict, (char_u *)"text", TRUE); texthl = dict_get_string(dict, (char_u *)"texthl", TRUE); } ! if (sign_define_by_name(name, icon, linehl, text, texthl) == OK) retval = 0; cleanup: --- 2224,2233 ---- linehl = dict_get_string(dict, (char_u *)"linehl", TRUE); text = dict_get_string(dict, (char_u *)"text", TRUE); texthl = dict_get_string(dict, (char_u *)"texthl", TRUE); + culhl = dict_get_string(dict, (char_u *)"culhl", TRUE); } ! if (sign_define_by_name(name, icon, linehl, text, texthl, culhl) == OK) retval = 0; cleanup: *************** *** 2202,2207 **** --- 2236,2242 ---- vim_free(linehl); vim_free(text); vim_free(texthl); + vim_free(culhl); return retval; } *** ../vim-8.2.3663/src/structs.h 2021-11-20 13:45:37.810729599 +0000 --- src/structs.h 2021-11-24 16:07:43.390152785 +0000 *************** *** 853,858 **** --- 853,859 ---- char_u *sat_text; int sat_texthl; int sat_linehl; + int sat_culhl; int sat_priority; } sign_attrs_T; *** ../vim-8.2.3663/src/vim.h 2021-11-19 11:35:28.886137594 +0000 --- src/vim.h 2021-11-24 16:07:43.394152775 +0000 *************** *** 1411,1416 **** --- 1411,1418 ---- , HLF_LNA // LineNrAbove , HLF_LNB // LineNrBelow , HLF_CLN // current line number + , HLF_CLS // current line sign column + , HLF_CLF // current line fold , HLF_R // return to continue message and yes/no questions , HLF_S // status lines , HLF_SNC // status lines of not-current windows *************** *** 1451,1457 **** // The HL_FLAGS must be in the same order as the HLF_ enums! // When changing this also adjust the default for 'highlight'. #define HL_FLAGS {'8', '~', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \ ! 'n', 'a', 'b', 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', \ 'w', 'W', 'f', 'F', 'A', 'C', 'D', 'T', '-', '>', \ 'B', 'P', 'R', 'L', \ '+', '=', 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q', \ --- 1453,1459 ---- // The HL_FLAGS must be in the same order as the HLF_ enums! // When changing this also adjust the default for 'highlight'. #define HL_FLAGS {'8', '~', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \ ! 'n', 'a', 'b', 'N', 'G', 'O', 'r', 's', 'S', 'c', 't', 'v', 'V', \ 'w', 'W', 'f', 'F', 'A', 'C', 'D', 'T', '-', '>', \ 'B', 'P', 'R', 'L', \ '+', '=', 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q', \ *** ../vim-8.2.3663/src/testdir/test_signs.vim 2021-08-28 13:42:20.044971678 +0100 --- src/testdir/test_signs.vim 2021-11-24 16:07:43.390152785 +0000 *************** *** 15,27 **** " the icon name when listing signs. sign define Sign1 text=x ! call Sign_command_ignore_error('sign define Sign2 text=xy texthl=Title linehl=Error icon=../../pixmaps/stock_vim_find_help.png') " Test listing signs. let a=execute('sign list') call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' . \ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' . ! \ 'linehl=Error texthl=Title$', a) let a=execute('sign list Sign1') call assert_equal("\nsign Sign1 text=x ", a) --- 15,27 ---- " the icon name when listing signs. sign define Sign1 text=x ! call Sign_command_ignore_error('sign define Sign2 text=xy texthl=Title linehl=Error culhl=Search icon=../../pixmaps/stock_vim_find_help.png') " Test listing signs. let a=execute('sign list') call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' . \ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' . ! \ 'linehl=Error texthl=Title culhl=Search$', a) let a=execute('sign list Sign1') call assert_equal("\nsign Sign1 text=x ", a) *************** *** 392,410 **** call sign_undefine() " Tests for sign_define() ! let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'} call assert_equal(0, "sign1"->sign_define(attr)) call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', ! \ 'linehl' : 'Search', 'text' : '=>'}], sign_getdefined()) " Define a new sign without attributes and then update it call sign_define("sign2") let attr = {'text' : '!!', 'linehl' : 'DiffAdd', 'texthl' : 'DiffChange', ! \ 'icon' : 'sign2.ico'} call Sign_define_ignore_error("sign2", attr) call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange', ! \ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}], ! \ "sign2"->sign_getdefined()) " Test for a sign name with digits call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'})) --- 392,412 ---- call sign_undefine() " Tests for sign_define() ! let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error', ! \ 'culhl': 'Visual'} call assert_equal(0, "sign1"->sign_define(attr)) call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', ! \ 'linehl' : 'Search', 'culhl' : 'Visual', 'text' : '=>'}], ! \ sign_getdefined()) " Define a new sign without attributes and then update it call sign_define("sign2") let attr = {'text' : '!!', 'linehl' : 'DiffAdd', 'texthl' : 'DiffChange', ! \ 'culhl': 'DiffDelete', 'icon' : 'sign2.ico'} call Sign_define_ignore_error("sign2", attr) call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange', ! \ 'linehl' : 'DiffAdd', 'culhl' : 'DiffDelete', 'text' : '!!', ! \ 'icon' : 'sign2.ico'}], "sign2"->sign_getdefined()) " Test for a sign name with digits call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'})) *** ../vim-8.2.3663/src/version.c 2021-11-24 15:32:53.723778915 +0000 --- src/version.c 2021-11-24 16:18:07.492996736 +0000 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3664, /**/ -- There are only two hard things in programming: Cache invalidation, naming things and off-by-one errors. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///