summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-27 22:54:58 +0100
committerBram Moolenaar <Bram@vim.org>2019-10-27 22:54:58 +0100
commitefae76ab1a43d5a628d8c2fa4218ace6ba597f5d (patch)
treeb7ef1d63325f64c076647f00ceee34ef74388172
parent38ba4dce4a8574e60f6ddb111922880b0c7affdc (diff)
patch 8.1.2229: cannot color number column above/below cursor differentlyv8.1.2229
Problem: Cannot color number column above/below cursor differently. Solution: Add LineNrAbove and LineNrBelow. (Shaun Brady, closes #624)
-rw-r--r--runtime/doc/options.txt5
-rw-r--r--runtime/doc/syntax.txt6
-rw-r--r--src/drawline.c10
-rw-r--r--src/optiondefs.h2
-rw-r--r--src/testdir/dumps/Test_relnr_colors_1.dump10
-rw-r--r--src/testdir/dumps/Test_relnr_colors_2.dump10
-rw-r--r--src/testdir/dumps/Test_relnr_colors_3.dump10
-rw-r--r--src/testdir/dumps/Test_relnr_colors_4.dump10
-rw-r--r--src/testdir/test_number.vim34
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h6
11 files changed, 102 insertions, 3 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 82cac9df12..1ef944d62d 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -3923,6 +3923,7 @@ A jump table for the options with a short description can be found at |Q_op|.
"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,
@@ -3954,6 +3955,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|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
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index e45ff81951..1c4988ade8 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -5071,6 +5071,12 @@ IncSearch 'incsearch' highlighting; also used for the text replaced with
*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
diff --git a/src/drawline.c b/src/drawline.c
index 869bdaa0ef..7caba051b6 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -1127,6 +1127,16 @@ win_line(
|| 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));
}
}
}
diff --git a/src/optiondefs.h b/src/optiondefs.h
index b557771cfb..a1d37f8341 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -289,7 +289,7 @@ struct vimoption
# 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"
+# 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)
diff --git a/src/testdir/dumps/Test_relnr_colors_1.dump b/src/testdir/dumps/Test_relnr_colors_1.dump
new file mode 100644
index 0000000000..ad0ddd9323
--- /dev/null
+++ b/src/testdir/dumps/Test_relnr_colors_1.dump
@@ -0,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|%|
diff --git a/src/testdir/dumps/Test_relnr_colors_2.dump b/src/testdir/dumps/Test_relnr_colors_2.dump
new file mode 100644
index 0000000000..0e80fc61fd
--- /dev/null
+++ b/src/testdir/dumps/Test_relnr_colors_2.dump
@@ -0,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|%|
diff --git a/src/testdir/dumps/Test_relnr_colors_3.dump b/src/testdir/dumps/Test_relnr_colors_3.dump
new file mode 100644
index 0000000000..f54a5befc8
--- /dev/null
+++ b/src/testdir/dumps/Test_relnr_colors_3.dump
@@ -0,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|%|
diff --git a/src/testdir/dumps/Test_relnr_colors_4.dump b/src/testdir/dumps/Test_relnr_colors_4.dump
new file mode 100644
index 0000000000..82028190ee
--- /dev/null
+++ b/src/testdir/dumps/Test_relnr_colors_4.dump
@@ -0,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|%|
diff --git a/src/testdir/test_number.vim b/src/testdir/test_number.vim
index 81326bce14..5417585136 100644
--- a/src/testdir/test_number.vim
+++ b/src/testdir/test_number.vim
@@ -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,3 +266,34 @@ func Test_relativenumber_uninitialised()
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
diff --git a/src/version.c b/src/version.c
index 01c95b335f..350f596027 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2229,
+/**/
2228,
/**/
2227,
diff --git a/src/vim.h b/src/vim.h
index 230f5b3f8d..7b2aa5be5b 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1382,6 +1382,8 @@ typedef enum
, 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,8 +1425,8 @@ typedef enum
// 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', '-', '>', \
+ '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'}