rcfile: accept prefix "light" to make a color brighter without bolding it

The prefix "bright" will continue to make the color brighter AND/OR
make the typeface bold (depending on how the terminal is configured
and on its capabilities), but the prefix "light" will just make the
color brighter (if the terminal can do that).

The prefix "bright" continues to do the same as what it did before,
to not change the appearance of user-defined syntaxes.  And having
an option to change the meaning of "bright"... would be confusing.

This partially fulfills https://savannah.gnu.org/bugs/?58503.
master
Benno Schulenberg 2020-06-08 11:55:31 +02:00
parent 926bc6751e
commit 4d10f583e4
2 changed files with 22 additions and 14 deletions

View File

@ -980,15 +980,22 @@ void parse_includes(char *ptr)
free(expanded); free(expanded);
} }
/* Return the short value corresponding to the color named in colorname, /* Return the short value corresponding to the given color name, and set
* and set bright to TRUE if that color is bright. */ * vivid to TRUE for a lighter color, and thick for a heavier typeface. */
short color_to_short(const char *colorname, bool *bright) short color_to_short(const char *colorname, bool *vivid, bool *thick)
{ {
if (strncmp(colorname, "bright", 6) == 0) { if (strncmp(colorname, "bright", 6) == 0) {
*bright = TRUE; *vivid = TRUE;
*thick = TRUE;
colorname += 6; colorname += 6;
} else } else if (strncmp(colorname, "light", 5) == 0) {
*bright = FALSE; *vivid = TRUE;
*thick = FALSE;
colorname += 5;
} else {
*vivid = FALSE;
*thick = FALSE;
}
if (strcmp(colorname, "green") == 0) if (strcmp(colorname, "green") == 0)
return COLOR_GREEN; return COLOR_GREEN;
@ -1018,13 +1025,13 @@ short color_to_short(const char *colorname, bool *bright)
bool parse_combination(char *combostr, short *fg, short *bg, int *attributes) bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
{ {
char *comma = strchr(combostr, ','); char *comma = strchr(combostr, ',');
bool bright; bool vivid, thick;
*attributes = A_NORMAL; *attributes = A_NORMAL;
if (comma != NULL) { if (comma != NULL) {
*bg = color_to_short(comma + 1, &bright); *bg = color_to_short(comma + 1, &vivid, &thick);
if (bright) { if (vivid) {
jot_error(N_("A background color cannot be bright")); jot_error(N_("A background color cannot be bright"));
return FALSE; return FALSE;
} }
@ -1035,11 +1042,12 @@ bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
*bg = USE_THE_DEFAULT; *bg = USE_THE_DEFAULT;
if (comma != combostr) { if (comma != combostr) {
*fg = color_to_short(combostr, &bright); *fg = color_to_short(combostr, &vivid, &thick);
if (*fg == BAD_COLOR) if (*fg == BAD_COLOR)
return FALSE; return FALSE;
if (vivid && !thick && COLORS > 8)
if (bright) *fg += 8;
else if (vivid)
*attributes = A_BOLD; *attributes = A_BOLD;
} else } else
*fg = USE_THE_DEFAULT; *fg = USE_THE_DEFAULT;

View File

@ -8,7 +8,7 @@ color brightred ".*"
# Keywords # Keywords
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|indicator|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|trimblanks|unix|view|wordbounds|zap)\>" color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|indicator|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|trimblanks|unix|view|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>" color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+" color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>" color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)" color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)"
@ -21,7 +21,7 @@ color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|f
color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)" color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)"
# Colors # Colors
color yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>" color yellow "^[[:space:]]*i?color[[:space:]]*(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
color magenta "^[[:space:]]*i?color\>" "\<(start|end)=" color magenta "^[[:space:]]*i?color\>" "\<(start|end)="
# Comments # Comments