mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 21:01:24 +03:00
small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color combination for the status bar when an error message is displayed.
This commit is contained in:
parent
1a926d79c5
commit
b027263a37
@ -736,6 +736,10 @@ Note that this overrides @option{quickblank}.
|
|||||||
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
||||||
(The old form of this option, @code{set cut}, is deprecated.)
|
(The old form of this option, @code{set cut}, is deprecated.)
|
||||||
|
|
||||||
|
@item set errorcolor @var{fgcolor},@var{bgcolor}
|
||||||
|
Use this color combination for the status bar when an error message is displayed.
|
||||||
|
@xref{@code{set functioncolor}} for valid color names.
|
||||||
|
|
||||||
@item set fill @var{number}
|
@item set fill @var{number}
|
||||||
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
|
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
|
||||||
the maximum line length will be the screen width less @var{number} columns.
|
the maximum line length will be the screen width less @var{number} columns.
|
||||||
|
@ -102,6 +102,10 @@ This overrides the option \fBquickblank\fR.
|
|||||||
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
|
||||||
(The old form of this option, '\fBset cut\fR', is deprecated.)
|
(The old form of this option, '\fBset cut\fR', is deprecated.)
|
||||||
.TP
|
.TP
|
||||||
|
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||||
|
Use this color combination for the status bar when an error message is displayed.
|
||||||
|
See \fBset titlecolor\fR for valid color names.
|
||||||
|
.TP
|
||||||
.B set fill \fInumber\fR
|
.B set fill \fInumber\fR
|
||||||
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
|
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
|
||||||
the maximum line length will be the screen width less \fInumber\fP columns.
|
the maximum line length will be the screen width less \fInumber\fP columns.
|
||||||
|
@ -200,13 +200,15 @@
|
|||||||
## These are examples; by default there are no colors.
|
## These are examples; by default there are no colors.
|
||||||
# set titlecolor brightwhite,blue
|
# set titlecolor brightwhite,blue
|
||||||
# set statuscolor brightwhite,green
|
# set statuscolor brightwhite,green
|
||||||
|
# set errorcolor brightwhite,red
|
||||||
# set selectedcolor brightwhite,magenta
|
# set selectedcolor brightwhite,magenta
|
||||||
# set numbercolor cyan
|
# set numbercolor cyan
|
||||||
# set keycolor cyan
|
# set keycolor cyan
|
||||||
# set functioncolor green
|
# set functioncolor green
|
||||||
## In root's .nanorc you might want to use:
|
## In root's .nanorc you might want to use:
|
||||||
# set titlecolor brightwhite,red
|
# set titlecolor brightwhite,magenta
|
||||||
# set statuscolor brightwhite,red
|
# set statuscolor brightwhite,magenta
|
||||||
|
# set errorcolor brightwhite,red
|
||||||
# set selectedcolor brightwhite,cyan
|
# set selectedcolor brightwhite,cyan
|
||||||
# set numbercolor magenta
|
# set numbercolor magenta
|
||||||
# set keycolor brightmagenta
|
# set keycolor brightmagenta
|
||||||
|
@ -68,10 +68,13 @@ void set_colorpairs(void)
|
|||||||
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
|
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
|
||||||
(combo->bright ? A_BOLD : A_NORMAL);
|
(combo->bright ? A_BOLD : A_NORMAL);
|
||||||
} else {
|
} else {
|
||||||
if (i != FUNCTION_TAG)
|
if (i == FUNCTION_TAG)
|
||||||
interface_color_pair[i] = hilite_attribute;
|
|
||||||
else
|
|
||||||
interface_color_pair[i] = A_NORMAL;
|
interface_color_pair[i] = A_NORMAL;
|
||||||
|
else if (i == ERROR_MESSAGE) {
|
||||||
|
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
|
||||||
|
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
|
||||||
|
} else
|
||||||
|
interface_color_pair[i] = hilite_attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(color_combo[i]);
|
free(color_combo[i]);
|
||||||
|
@ -2500,6 +2500,7 @@ int main(int argc, char **argv)
|
|||||||
interface_color_pair[LINE_NUMBER] = hilite_attribute;
|
interface_color_pair[LINE_NUMBER] = hilite_attribute;
|
||||||
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
|
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
|
||||||
interface_color_pair[STATUS_BAR] = hilite_attribute;
|
interface_color_pair[STATUS_BAR] = hilite_attribute;
|
||||||
|
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
|
||||||
interface_color_pair[KEY_COMBO] = hilite_attribute;
|
interface_color_pair[KEY_COMBO] = hilite_attribute;
|
||||||
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
|
interface_color_pair[FUNCTION_TAG] = A_NORMAL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -484,6 +484,7 @@ enum
|
|||||||
LINE_NUMBER,
|
LINE_NUMBER,
|
||||||
SELECTED_TEXT,
|
SELECTED_TEXT,
|
||||||
STATUS_BAR,
|
STATUS_BAR,
|
||||||
|
ERROR_MESSAGE,
|
||||||
KEY_COMBO,
|
KEY_COMBO,
|
||||||
FUNCTION_TAG,
|
FUNCTION_TAG,
|
||||||
NUMBER_OF_ELEMENTS
|
NUMBER_OF_ELEMENTS
|
||||||
|
@ -115,6 +115,7 @@ static const rcoption rcopts[] = {
|
|||||||
{"numbercolor", 0},
|
{"numbercolor", 0},
|
||||||
{"selectedcolor", 0},
|
{"selectedcolor", 0},
|
||||||
{"statuscolor", 0},
|
{"statuscolor", 0},
|
||||||
|
{"errorcolor", 0},
|
||||||
{"keycolor", 0},
|
{"keycolor", 0},
|
||||||
{"functioncolor", 0},
|
{"functioncolor", 0},
|
||||||
#endif
|
#endif
|
||||||
@ -1098,6 +1099,8 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
|||||||
color_combo[SELECTED_TEXT] = parse_interface_color(option);
|
color_combo[SELECTED_TEXT] = parse_interface_color(option);
|
||||||
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
|
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
|
||||||
color_combo[STATUS_BAR] = parse_interface_color(option);
|
color_combo[STATUS_BAR] = parse_interface_color(option);
|
||||||
|
else if (strcasecmp(rcopts[i].name, "errorcolor") == 0)
|
||||||
|
color_combo[ERROR_MESSAGE] = parse_interface_color(option);
|
||||||
else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
|
else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
|
||||||
color_combo[KEY_COMBO] = parse_interface_color(option);
|
color_combo[KEY_COMBO] = parse_interface_color(option);
|
||||||
else if (strcasecmp(rcopts[i].name, "functioncolor") == 0)
|
else if (strcasecmp(rcopts[i].name, "functioncolor") == 0)
|
||||||
|
@ -2131,6 +2131,7 @@ void statusline(message_type importance, const char *msg, ...)
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
static int alerts = 0;
|
static int alerts = 0;
|
||||||
|
int colorpair;
|
||||||
char *compound, *message;
|
char *compound, *message;
|
||||||
size_t start_col;
|
size_t start_col;
|
||||||
bool bracketed;
|
bool bracketed;
|
||||||
@ -2169,7 +2170,9 @@ void statusline(message_type importance, const char *msg, ...)
|
|||||||
msg = _("Further warnings were suppressed");
|
msg = _("Further warnings were suppressed");
|
||||||
else if (alerts < 4)
|
else if (alerts < 4)
|
||||||
beep();
|
beep();
|
||||||
}
|
colorpair = interface_color_pair[ERROR_MESSAGE];
|
||||||
|
} else
|
||||||
|
colorpair = interface_color_pair[STATUS_BAR];
|
||||||
|
|
||||||
lastmessage = importance;
|
lastmessage = importance;
|
||||||
|
|
||||||
@ -2186,14 +2189,14 @@ void statusline(message_type importance, const char *msg, ...)
|
|||||||
bracketed = (start_col > 1);
|
bracketed = (start_col > 1);
|
||||||
|
|
||||||
wmove(bottomwin, 0, (bracketed ? start_col - 2 : start_col));
|
wmove(bottomwin, 0, (bracketed ? start_col - 2 : start_col));
|
||||||
wattron(bottomwin, interface_color_pair[STATUS_BAR]);
|
wattron(bottomwin, colorpair);
|
||||||
if (bracketed)
|
if (bracketed)
|
||||||
waddstr(bottomwin, "[ ");
|
waddstr(bottomwin, "[ ");
|
||||||
waddstr(bottomwin, message);
|
waddstr(bottomwin, message);
|
||||||
free(message);
|
free(message);
|
||||||
if (bracketed)
|
if (bracketed)
|
||||||
waddstr(bottomwin, " ]");
|
waddstr(bottomwin, " ]");
|
||||||
wattroff(bottomwin, interface_color_pair[STATUS_BAR]);
|
wattroff(bottomwin, colorpair);
|
||||||
|
|
||||||
/* Defeat a VTE/Konsole bug, where the cursor can go off-limits. */
|
/* Defeat a VTE/Konsole bug, where the cursor can go off-limits. */
|
||||||
if (ISSET(CONSTANT_SHOW) && ISSET(NO_HELP))
|
if (ISSET(CONSTANT_SHOW) && ISSET(NO_HELP))
|
||||||
|
@ -8,8 +8,8 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comm
|
|||||||
|
|
||||||
# Keywords
|
# Keywords
|
||||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|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|trimblanks|unix|view|wordbounds)\>"
|
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|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|trimblanks|unix|view|wordbounds)\>"
|
||||||
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|selected|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|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|selectedcolor|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
|
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|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:]]*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:]]*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:]]+.*$"
|
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$"
|
||||||
|
Loading…
Reference in New Issue
Block a user