rcfile: add an option to customize the color of line numbers

master
Benno Schulenberg 2016-10-20 10:07:48 +02:00
parent de95ca68f7
commit de2aa4f24a
7 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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:]]+.*$"

View File

@ -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

View File

@ -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;

View File

@ -488,6 +488,7 @@ typedef struct subnfunc {
enum
{
TITLE_BAR = 0,
LINE_NUMBER,
STATUS_BAR,
KEY_COMBO,
FUNCTION_TAG,

View File

@ -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)

View File

@ -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;