From de2aa4f24a05802913e9ec82bcf910ae3abb42d4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 20 Oct 2016 10:07:48 +0200 Subject: [PATCH] rcfile: add an option to customize the color of line numbers --- doc/man/nanorc.5 | 4 ++++ doc/syntax/nanorc.nanorc | 4 ++-- doc/texinfo/nano.texi | 4 ++++ src/nano.c | 1 + src/nano.h | 1 + src/rcfile.c | 3 +++ src/winio.c | 4 ++-- 7 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5 index 6fec53a6..86978198 100644 --- a/doc/man/nanorc.5 +++ b/doc/man/nanorc.5 @@ -153,6 +153,10 @@ Don't automatically add a newline to the ends of files. .B set nowrap Don't hard-wrap text at all. .TP +.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR +Specify the color combination to use for line numbers. +See \fBset titlecolor\fR for more details. +.TP .B set operatingdir "\fIdirectory\fP" \fBnano\fP will only read and write files inside \fIdirectory\fP and its subdirectories. Also, the current directory is changed to here, so diff --git a/doc/syntax/nanorc.nanorc b/doc/syntax/nanorc.nanorc index 8b911bb0..92d33193 100644 --- a/doc/syntax/nanorc.nanorc +++ b/doc/syntax/nanorc.nanorc @@ -8,8 +8,8 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|ma # Keywords icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>" -icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" -icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+" +icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" +icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+" icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$" diff --git a/doc/texinfo/nano.texi b/doc/texinfo/nano.texi index d4f64265..2b5c8539 100644 --- a/doc/texinfo/nano.texi +++ b/doc/texinfo/nano.texi @@ -731,6 +731,10 @@ Don't add newlines to the ends of files. @item set nowrap Don't hard-wrap text at all. +@item set numbercolor @var{fgcolor},@var{bgcolor} +Specify the color combination to use for line numbers. +See @code{set titlecolor} for more details. + @item set operatingdir "directory" @code{nano} will only read and write files inside "directory" and its subdirectories. Also, the current directory is changed to here, so diff --git a/src/nano.c b/src/nano.c index d1ee039b..a4f43c42 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2577,6 +2577,7 @@ int main(int argc, char **argv) set_colorpairs(); #else interface_color_pair[TITLE_BAR] = hilite_attribute; + interface_color_pair[LINE_NUMBER] = hilite_attribute; interface_color_pair[STATUS_BAR] = hilite_attribute; interface_color_pair[KEY_COMBO] = hilite_attribute; interface_color_pair[FUNCTION_TAG] = A_NORMAL; diff --git a/src/nano.h b/src/nano.h index 4e1e35f8..93ec5e1b 100644 --- a/src/nano.h +++ b/src/nano.h @@ -488,6 +488,7 @@ typedef struct subnfunc { enum { TITLE_BAR = 0, + LINE_NUMBER, STATUS_BAR, KEY_COMBO, FUNCTION_TAG, diff --git a/src/rcfile.c b/src/rcfile.c index 72a58808..a570952c 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -111,6 +111,7 @@ static const rcoption rcopts[] = { #endif #ifndef DISABLE_COLOR {"titlecolor", 0}, + {"numbercolor", 0}, {"statuscolor", 0}, {"keycolor", 0}, {"functioncolor", 0}, @@ -1121,6 +1122,8 @@ void parse_rcfile(FILE *rcstream #ifndef DISABLE_COLOR if (strcasecmp(rcopts[i].name, "titlecolor") == 0) specified_color_combo[TITLE_BAR] = option; + else if (strcasecmp(rcopts[i].name, "numbercolor") == 0) + specified_color_combo[LINE_NUMBER] = option; else if (strcasecmp(rcopts[i].name, "statuscolor") == 0) specified_color_combo[STATUS_BAR] = option; else if (strcasecmp(rcopts[i].name, "keycolor") == 0) diff --git a/src/winio.c b/src/winio.c index d2d6e167..4330814b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2278,12 +2278,12 @@ void edit_draw(filestruct *fileptr, const char *converted, int } /* Show the line number only for the non-softwrapped parts. */ - wattron(edit, hilite_attribute); + wattron(edit, interface_color_pair[LINE_NUMBER]); if (last_drawn_line != fileptr->lineno || last_line_y >= line) mvwprintw(edit, line, 0, "%*i", margin - 1, fileptr->lineno); else mvwprintw(edit, line, 0, "%*s", margin - 1, " "); - wattroff(edit, hilite_attribute); + wattroff(edit, interface_color_pair[LINE_NUMBER]); } else { margin = 0; editwincols = COLS;