diff --git a/doc/nano.texi b/doc/nano.texi index cd27a4635d37f5ffca7b8ea6217b66fbf5ad1e92..dbded437c886095332a780dba0eef0424f89ed6f 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -707,9 +707,9 @@ Do backwards searches by default. @item set boldtext Use bold instead of reverse video for the title bar, status bar, key combos, -function tags, line numbers, and selected text. This can be overridden for -the first five by setting the options @code{titlecolor}, @code{statuscolor}, -@code{keycolor}, @code{functioncolor}, and @code{numbercolor}. +function tags, line numbers, and selected text. This can be overridden by +setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor}, +@code{functioncolor}, @code{numbercolor}, and @code{selectedcolor}. @item set brackets "@var{string}" Set the characters treated as closing brackets when justifying @@ -852,6 +852,10 @@ won't work properly with this option enabled. @item set regexp Do extended regular expression searches by default. +@item set selectedcolor @var{fgcolor},@var{bgcolor} +Use this color combination for selected text. +@xref{@code{set functioncolor}} for valid color names. + @item set showcursor Put the cursor on the highlighted item in the file browser, to aid braille users. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 3d715cfa1bcbee8b677c3bea06d031f7d95acad8..629312e902e18b60608bc2c5807ebc2aa504b6db 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -79,9 +79,9 @@ Do backwards searches by default. .TP .B set boldtext Use bold instead of reverse video for the title bar, status bar, key combos, -function tags, line numbers, and selected text. This can be overridden for -the first five by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, -\fBkeycolor\fP, \fBfunctioncolor\fP, and \fBnumbercolor\fP. +function tags, line numbers, and selected text. This can be overridden by +setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP, +\fBfunctioncolor\fP, \fBnumbercolor\fP, and \fBselectedcolor\fP. .TP .B set brackets "\fIstring\fP" Set the characters treated as closing brackets when justifying @@ -220,6 +220,10 @@ won't work properly with this option enabled. .B set regexp Do extended regular expression searches by default. .TP +.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR +Specify the color combination to use for selected text. +See \fBset titlecolor\fR for more details. +.TP .B set showcursor Put the cursor on the highlighted item in the file browser, to aid braille users. diff --git a/doc/sample.nanorc.in b/doc/sample.nanorc.in index 2b39d9ff1da5e899988ba0a8d6e5a640f0b658bf..b6eebb152fc3514bdc4ea1570a322266c3df4054 100644 --- a/doc/sample.nanorc.in +++ b/doc/sample.nanorc.in @@ -208,12 +208,14 @@ ## These are examples; by default there are no colors. # set titlecolor brightwhite,blue # set statuscolor brightwhite,green +# set selectedcolor brightwhite,magenta # set numbercolor cyan # set keycolor cyan # set functioncolor green ## In root's .nanorc you might want to use: # set titlecolor brightwhite,red # set statuscolor brightwhite,red +# set selectedcolor brightwhite,cyan # set numbercolor magenta # set keycolor brightmagenta # set functioncolor magenta diff --git a/src/browser.c b/src/browser.c index b5cfa80fb476582347edf91563cc5402d390d32e..51ea37fa99b118a3073cd2eba6feba94e76726f4 100644 --- a/src/browser.c +++ b/src/browser.c @@ -538,7 +538,7 @@ void browser_refresh(void) /* If this is the selected item, start its highlighting, and * remember its location to be able to place the cursor on it. */ if (i == selected) { - wattron(edit, hilite_attribute); + wattron(edit, interface_color_pair[SELECTED_TEXT]); the_row = row; the_column = col; } @@ -610,7 +610,7 @@ void browser_refresh(void) /* If this is the selected item, finish its highlighting. */ if (i == selected) - wattroff(edit, hilite_attribute); + wattroff(edit, interface_color_pair[SELECTED_TEXT]); free(info); diff --git a/src/nano.c b/src/nano.c index 44b83c9d487139f927bf9ae1bcf9f887d7eb223c..17da37b18a82dff115db5173033f4ef28cfc4001 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2492,6 +2492,7 @@ int main(int argc, char **argv) #else interface_color_pair[TITLE_BAR] = hilite_attribute; interface_color_pair[LINE_NUMBER] = hilite_attribute; + interface_color_pair[SELECTED_TEXT] = 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 c6ea016d1c9cbad96be38b176c120b3f6408577f..7c52da8bf3d2ce0ecbcd7b612b433d8885ffdd84 100644 --- a/src/nano.h +++ b/src/nano.h @@ -469,6 +469,7 @@ enum { TITLE_BAR = 0, LINE_NUMBER, + SELECTED_TEXT, STATUS_BAR, KEY_COMBO, FUNCTION_TAG, diff --git a/src/rcfile.c b/src/rcfile.c index beb1742076de064f6047e8bd61482d176307c314..74348f5bf343c660942c8786fb90c00f9f39df60 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -114,6 +114,7 @@ static const rcoption rcopts[] = { #ifndef DISABLE_COLOR {"titlecolor", 0}, {"numbercolor", 0}, + {"selectedcolor", 0}, {"statuscolor", 0}, {"keycolor", 0}, {"functioncolor", 0}, @@ -1113,6 +1114,8 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) 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, "selectedcolor") == 0) + specified_color_combo[SELECTED_TEXT] = 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 4658127438b4166fcc0d34db6e8daf0f8492cedc..e3aa12219085415eb92626a1ac66c6e54b31dfa8 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2650,9 +2650,9 @@ void edit_draw(filestruct *fileptr, const char *converted, paintlen = actual_x(thetext, end_col - start_col); } - wattron(edit, hilite_attribute); + wattron(edit, interface_color_pair[SELECTED_TEXT]); mvwaddnstr(edit, row, margin + start_col, thetext, paintlen); - wattroff(edit, hilite_attribute); + wattroff(edit, interface_color_pair[SELECTED_TEXT]); } } #endif /* !NANO_TINY */ @@ -3417,7 +3417,7 @@ void spotlight(bool active, size_t from_col, size_t to_col) room--; if (active) - wattron(edit, hilite_attribute); + wattron(edit, interface_color_pair[SELECTED_TEXT]); waddnstr(edit, word, actual_x(word, room)); @@ -3425,7 +3425,7 @@ void spotlight(bool active, size_t from_col, size_t to_col) waddch(edit, '$'); if (active) - wattroff(edit, hilite_attribute); + wattroff(edit, interface_color_pair[SELECTED_TEXT]); free(word); @@ -3464,12 +3464,12 @@ void spotlight_softwrapped(bool active, size_t from_col, size_t to_col) break_col - from_col, FALSE); if (active) - wattron(edit, hilite_attribute); + wattron(edit, interface_color_pair[SELECTED_TEXT]); waddnstr(edit, word, actual_x(word, break_col)); if (active) - wattroff(edit, hilite_attribute); + wattroff(edit, interface_color_pair[SELECTED_TEXT]); free(word); diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc index ac1fa4ceb9f24155ac6a1da23b1584a2c2ce386b..8013a7f460802d6a8e11683f8530ef83f8071f9d 100644 --- a/syntax/nanorc.nanorc +++ b/syntax/nanorc.nanorc @@ -9,7 +9,7 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comm # Keywords icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|justifytrim|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|unix|view|wordbounds)\>" 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:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|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:]]+.*$"