nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0b30835dd0fc0e8bfcc665777aae2aa4802eab2b
parent a865c25eea1e5c24a98d07af6917393934c00e00
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun,  1 Apr 2018 09:49:58 +0200

tweaks: use meaningful names instead of puzzling values

Suggested-by: Brand Huntsman <alpha@qzx.com>

Diffstat:
Msrc/color.c | 8++++----
Msrc/nano.h | 5+++++
Msrc/rcfile.c | 12++++++------
3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/color.c b/src/color.c @@ -60,9 +60,9 @@ void set_colorpairs(void) colortype *combo = color_combo[i]; if (combo != NULL) { - if (combo->fg == -1 && !using_defaults) + if (combo->fg == USE_THE_DEFAULT && !using_defaults) combo->fg = COLOR_WHITE; - if (combo->bg == -1 && !using_defaults) + if (combo->bg == USE_THE_DEFAULT && !using_defaults) combo->bg = COLOR_BLACK; init_pair(i + 1, combo->fg, combo->bg); interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID | @@ -125,10 +125,10 @@ void color_init(void) foreground = ink->fg; background = ink->bg; - if (foreground == -1 && !using_defaults) + if (foreground == USE_THE_DEFAULT && !using_defaults) foreground = COLOR_WHITE; - if (background == -1 && !using_defaults) + if (background == USE_THE_DEFAULT && !using_defaults) background = COLOR_BLACK; init_pair(ink->pairnum, foreground, background); diff --git a/src/nano.h b/src/nano.h @@ -142,6 +142,11 @@ #define REPLACING 1 #define INREGION 2 +#ifdef ENABLE_COLOR +#define USE_THE_DEFAULT -1 +#define BAD_COLOR -2 +#endif + /* Enumeration types. */ typedef enum { NIX_FILE, DOS_FILE, MAC_FILE diff --git a/src/rcfile.c b/src/rcfile.c @@ -603,10 +603,10 @@ short color_to_short(const char *colorname, bool *bright) else if (strcasecmp(colorname, "black") == 0) return COLOR_BLACK; else if (strcasecmp(colorname, "normal") == 0) - return -1; + return USE_THE_DEFAULT; rcfile_error(N_("Color \"%s\" not understood"), colorname); - return -2; + return BAD_COLOR; } /* Parse the color name (or pair of color names) in the given string. @@ -621,18 +621,18 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright) rcfile_error(N_("A background color cannot be bright")); return FALSE; } - if (*bg == -2) + if (*bg == BAD_COLOR) return FALSE; *comma = '\0'; } else - *bg = -1; + *bg = USE_THE_DEFAULT; if (comma != combostr) { *fg = color_to_short(combostr, bright); - if (*fg == -2) + if (*fg == BAD_COLOR) return FALSE; } else - *fg = -1; + *fg = USE_THE_DEFAULT; return TRUE; }