Patch 8.1.2229

26 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 27, 2019, 5:55:46 PM10/27/19
to vim...@googlegroups.com

Patch 8.1.2229
Problem: Cannot color number column above/below cursor differently.
Solution: Add LineNrAbove and LineNrBelow. (Shaun Brady, closes #624)
Files: runtime/doc/syntax.txt, runtime/doc/options.txt, src/optiondefs.h,
src/drawline.c, src/vim.h, src/testdir/test_number.vim,
src/testdir/dumps/Test_relnr_colors_1.dump,
src/testdir/dumps/Test_relnr_colors_2.dump,
src/testdir/dumps/Test_relnr_colors_3.dump,
src/testdir/dumps/Test_relnr_colors_4.dump


*** ../vim-8.1.2228/runtime/doc/syntax.txt 2019-09-09 22:04:19.362736959 +0200
--- runtime/doc/syntax.txt 2019-10-27 22:17:09.410012079 +0100
***************
*** 5041,5046 ****
--- 5071,5082 ----
*hl-LineNr*
LineNr Line number for ":number" and ":#" commands, and when 'number'
or 'relativenumber' option is set.
+ *hl-LineNrAbove*
+ LineNrAbove Line number for when the 'relativenumber'
+ option is set, above the cursor line.
+ *hl-LineNrBelow*
+ 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
*** ../vim-8.1.2228/runtime/doc/options.txt 2019-10-27 18:50:19.605873781 +0100
--- runtime/doc/options.txt 2019-10-27 22:22:00.356793773 +0100
***************
*** 3924,3929 ****
--- 3923,3929 ----
"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,
***************
*** 3955,3960 ****
--- 3955,3964 ----
|hl-ModeMsg| M Mode (e.g., "-- INSERT --")
|hl-LineNr| n line number for ":number" and ":#" commands, and
when 'number' or 'relativenumber' option is set.
+ |hl-LineNrAbove| a line number above the cursor for when the
+ 'relativenumber' option is set.
+ |hl-LineNrBelow| b line number below the cursor for when the
+ 'relativenumber' option is set.
|hl-CursorLineNr| N like n for when 'cursorline' or 'relativenumber' is
set.
|hl-Question| r |hit-enter| prompt and yes/no questions
*** ../vim-8.1.2228/src/optiondefs.h 2019-10-17 22:58:59.070496999 +0200
--- src/optiondefs.h 2019-10-27 22:18:57.049561272 +0100
***************
*** 289,295 ****
# 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,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)
--- 289,295 ----
# 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)
*** ../vim-8.1.2228/src/drawline.c 2019-10-24 14:59:58.035079639 +0200
--- src/drawline.c 2019-10-27 22:37:27.484499183 +0100
***************
*** 1127,1132 ****
--- 1127,1142 ----
|| wp->w_p_culopt_flags & CULOPT_LINE))
char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLN));
#endif
+ if (wp->w_p_rnu && lnum < wp->w_cursor.lnum
+ && HL_ATTR(HLF_LNA) != 0)
+ // Use LineNrAbove
+ char_attr = hl_combine_attr(wcr_attr,
+ HL_ATTR(HLF_LNA));
+ if (wp->w_p_rnu && lnum > wp->w_cursor.lnum
+ && HL_ATTR(HLF_LNB) != 0)
+ // Use LineNrBelow
+ char_attr = hl_combine_attr(wcr_attr,
+ HL_ATTR(HLF_LNB));
}
}
}
*** ../vim-8.1.2228/src/vim.h 2019-10-27 05:12:38.288773701 +0100
--- src/vim.h 2019-10-27 22:29:38.278861050 +0100
***************
*** 1382,1387 ****
--- 1382,1389 ----
, HLF_M // "--More--" message
, HLF_CM // Mode (e.g., "-- INSERT --")
, HLF_N // line number for ":number" and ":#" commands
+ , HLF_LNA // LineNrAbove
+ , HLF_LNB // LineNrBelow
, HLF_CLN // current line number
, HLF_R // return to continue message and yes/no questions
, HLF_S // status lines
***************
*** 1423,1430 ****
// 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', 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
! 'f', 'F', 'A', 'C', 'D', 'T', '-', '>', \
'B', 'P', 'R', 'L', \
'+', '=', 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q', \
'z', 'Z'}
--- 1425,1432 ----
// 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', \
'z', 'Z'}
*** ../vim-8.1.2228/src/testdir/test_number.vim 2019-07-07 14:26:55.859493907 +0200
--- src/testdir/test_number.vim 2019-10-27 22:51:25.760665209 +0100
***************
*** 1,7 ****
--- 1,10 ----
" Test for 'number' and 'relativenumber'

+ source check.vim
source view_util.vim

+ source screendump.vim
+
func s:screen_lines(start, end) abort
return ScreenLines([a:start, a:end], 8)
endfunc
***************
*** 263,265 ****
--- 266,299 ----
redraw
bwipe!
endfunc
+
+ func Test_relativenumber_colors()
+ CheckScreendump
+
+ let lines =<< trim [CODE]
+ call setline(1, range(200))
+ 111
+ set number relativenumber
+ hi LineNr ctermfg=red
+ [CODE]
+ call writefile(lines, 'XTest_relnr')
+
+ " Check that the balloon shows up after a mouse move
+ let buf = RunVimInTerminal('-S XTest_relnr', {'rows': 10, 'cols': 50})
+ call term_wait(buf, 100)
+ " Default colors
+ call VerifyScreenDump(buf, 'Test_relnr_colors_1', {})
+
+ call term_sendkeys(buf, ":hi LineNrAbove ctermfg=blue\<CR>")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_2', {})
+
+ call term_sendkeys(buf, ":hi LineNrBelow ctermfg=green\<CR>")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_3', {})
+
+ call term_sendkeys(buf, ":hi clear LineNrAbove\<CR>")
+ call VerifyScreenDump(buf, 'Test_relnr_colors_4', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XTest_relnr')
+ endfunc
*** ../vim-8.1.2228/src/testdir/dumps/Test_relnr_colors_1.dump 2019-10-27 22:52:59.352248830 +0100
--- src/testdir/dumps/Test_relnr_colors_1.dump 2019-10-27 22:51:34.360626901 +0100
***************
*** 0 ****
--- 1,10 ----
+ | +0#ff404010#ffffff0@1|4| |1+0#0000000&|0|6| @42
+ | +0#ff404010&@1|3| |1+0#0000000&|0|7| @42
+ | +0#ff404010&@1|2| |1+0#0000000&|0|8| @42
+ | +0#ff404010&@1|1| |1+0#0000000&|0|9| @42
+ |1+0#ff404010&@2| >1+0#0000000&@1|0| @42
+ | +0#ff404010&@1|1| |1+0#0000000&@2| @42
+ | +0#ff404010&@1|2| |1+0#0000000&@1|2| @42
+ | +0#ff404010&@1|3| |1+0#0000000&@1|3| @42
+ | +0#ff404010&@1|4| |1+0#0000000&@1|4| @42
+ @32|1@2|,|1| @8|5@1|%|
*** ../vim-8.1.2228/src/testdir/dumps/Test_relnr_colors_2.dump 2019-10-27 22:52:59.356248812 +0100
--- src/testdir/dumps/Test_relnr_colors_2.dump 2019-10-27 22:51:35.408622233 +0100
***************
*** 0 ****
--- 1,10 ----
+ | +0#4040ff13#ffffff0@1|4| |1+0#0000000&|0|6| @42
+ | +0#4040ff13&@1|3| |1+0#0000000&|0|7| @42
+ | +0#4040ff13&@1|2| |1+0#0000000&|0|8| @42
+ | +0#4040ff13&@1|1| |1+0#0000000&|0|9| @42
+ |1+0#ff404010&@2| >1+0#0000000&@1|0| @42
+ | +0#ff404010&@1|1| |1+0#0000000&@2| @42
+ | +0#ff404010&@1|2| |1+0#0000000&@1|2| @42
+ | +0#ff404010&@1|3| |1+0#0000000&@1|3| @42
+ | +0#ff404010&@1|4| |1+0#0000000&@1|4| @42
+ |:|h|i| |L|i|n|e|N|r|A|b|o|v|e| |c|t|e|r|m|f|g|=|b|l|u|e| @3|1@2|,|1| @8|5@1|%|
*** ../vim-8.1.2228/src/testdir/dumps/Test_relnr_colors_3.dump 2019-10-27 22:52:59.360248795 +0100
--- src/testdir/dumps/Test_relnr_colors_3.dump 2019-10-27 22:51:36.456617565 +0100
***************
*** 0 ****
--- 1,10 ----
+ | +0#4040ff13#ffffff0@1|4| |1+0#0000000&|0|6| @42
+ | +0#4040ff13&@1|3| |1+0#0000000&|0|7| @42
+ | +0#4040ff13&@1|2| |1+0#0000000&|0|8| @42
+ | +0#4040ff13&@1|1| |1+0#0000000&|0|9| @42
+ |1+0#ff404010&@2| >1+0#0000000&@1|0| @42
+ | +0#40ff4011&@1|1| |1+0#0000000&@2| @42
+ | +0#40ff4011&@1|2| |1+0#0000000&@1|2| @42
+ | +0#40ff4011&@1|3| |1+0#0000000&@1|3| @42
+ | +0#40ff4011&@1|4| |1+0#0000000&@1|4| @42
+ |:|h|i| |L|i|n|e|N|r|B|e|l|o|w| |c|t|e|r|m|f|g|=|g|r|e@1|n| @2|1@2|,|1| @8|5@1|%|
*** ../vim-8.1.2228/src/testdir/dumps/Test_relnr_colors_4.dump 2019-10-27 22:52:59.364248778 +0100
--- src/testdir/dumps/Test_relnr_colors_4.dump 2019-10-27 22:51:37.500612918 +0100
***************
*** 0 ****
--- 1,10 ----
+ | +0#ff404010#ffffff0@1|4| |1+0#0000000&|0|6| @42
+ | +0#ff404010&@1|3| |1+0#0000000&|0|7| @42
+ | +0#ff404010&@1|2| |1+0#0000000&|0|8| @42
+ | +0#ff404010&@1|1| |1+0#0000000&|0|9| @42
+ |1+0#ff404010&@2| >1+0#0000000&@1|0| @42
+ | +0#40ff4011&@1|1| |1+0#0000000&@2| @42
+ | +0#40ff4011&@1|2| |1+0#0000000&@1|2| @42
+ | +0#40ff4011&@1|3| |1+0#0000000&@1|3| @42
+ | +0#40ff4011&@1|4| |1+0#0000000&@1|4| @42
+ |:|h|i| |c|l|e|a|r| |L|i|n|e|N|r|A|b|o|v|e| @10|1@2|,|1| @8|5@1|%|
*** ../vim-8.1.2228/src/version.c 2019-10-27 21:39:04.707620926 +0100
--- src/version.c 2019-10-27 22:15:25.358447955 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2229,
/**/

--
A radioactive cat has eighteen half-lives.

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages