All,

Shaun Brady here.  Thanks for the best text editor!  I had a simple want, and I
believe I have achieved this with the attached patch.

I wanted my relative line numbers to be colored differently above and below the
cursor line.  I believe a highlight group applied conditionally is the correct
way to achieve this.

This is my first foray in to the vim sources, so please let me know if I missed
the mark or could do things differently/better.

Should the patch pass inspection, I formally and humbly submit this for
inclusion.

Thank you!

Shaun Brady (SB)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 406c2260b515833064963363fd1503700a4a0039 Mon Sep 17 00:00:00 2001
From: Shaun Brady <[email protected]>
Date: Sat, 30 Jan 2016 01:47:18 -0500
Subject: [PATCH] Adding RelLineAbove and RelLineBelow highlight groups

RelLineAbove is applied to relative line numbers above the cursor line
(and Below below).  These are added in addition to LineNr so as to not
break backwards compatibility.

The idea behind these highlight groups is to color relative line numbers
above and below the cursor differently.
---
 src/option.c |  4 ++--
 src/screen.c | 10 ++++++++++
 src/vim.h    |  6 ++++--
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/option.c b/src/option.c
index 41d6ceb..8798d8d 100644
--- a/src/option.c
+++ b/src/option.c
@@ -475,9 +475,9 @@ struct vimoption
 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
 	|| defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
 	|| defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
-# define HIGHLIGHT_INIT "8:SpecialKey,@: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"
+# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,a:RelLineAbove,b:RelLineBelow,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"
 #else
-# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
+# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,a:RelLineAbove,b:RelLineBelow,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
 #endif
 
 /*
diff --git a/src/screen.c b/src/screen.c
index 69c1f40..bb2e7b8 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -3744,6 +3744,16 @@ win_line(wp, lnum, startrow, endrow, nochange)
 		    if ((wp->w_p_cul || wp->w_p_rnu)
 						 && lnum == wp->w_cursor.lnum)
 			char_attr = hl_attr(HLF_CLN);
+
+                    if (wp->w_p_rnu && (lnum < wp->w_cursor.lnum))
+                        /* high light relative above (<) cursor */
+                        char_attr = hl_combine_attr(
+                                char_attr, hl_attr(HLF_RNA));
+
+                    if (wp->w_p_rnu && (lnum > wp->w_cursor.lnum))
+                        /* high light relative above (<) cursor */
+                        char_attr = hl_combine_attr(
+                                char_attr, hl_attr(HLF_RNB));
 #endif
 		}
 	    }
diff --git a/src/vim.h b/src/vim.h
index 90a5353..5cb0bb8 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1348,6 +1348,8 @@ typedef enum
     , HLF_CM	    /* Mode (e.g., "-- INSERT --") */
     , HLF_N	    /* line number for ":number" and ":#" commands */
     , HLF_CLN	    /* current line number */
+    , HLF_RNA	    /* relative line number above current line */
+    , HLF_RNB	    /* relative line number above current line */
     , HLF_R	    /* return to continue message and yes/no questions */
     , HLF_S	    /* status lines */
     , HLF_SNC	    /* status lines of not-current windows */
@@ -1385,8 +1387,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', 'N', 'a', 'b', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', \
+		  'W', 'f', 'F', 'A', 'C', 'D', 'T', '-', '>', \
 		  'B', 'P', 'R', 'L', \
 		  '+', '=', 'x', 'X', '*', '#', '_', '!', '.', 'o'}
 
-- 
1.9.1

Raspunde prin e-mail lui