From: Benno Schulenberg Date: Sat, 10 May 2014 19:15:04 +0000 (+0000) Subject: Making it possible for interface-foreground colours to be bright. X-Git-Tag: v2.3.3~77 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e7d6e55332394639d3a316b24bd3c48427e082e9;p=nano.git Making it possible for interface-foreground colours to be bright. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4853 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index a369b3f2..6894b8b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-05-10 Mark Majeres + * src/*.h, src/*.c: Make it possible for the foreground colour of + interface elements to be bright. + 2014-05-09 Benno Schulenberg * src/winio.c (get_mouseinput): Count only shortcuts that are actually shown, so that clicking on the ones after ^T (Speller/Linter) will work diff --git a/src/color.c b/src/color.c index 7f1e3135..e5d38588 100644 --- a/src/color.c +++ b/src/color.c @@ -38,7 +38,7 @@ void set_colorpairs(void) { const syntaxtype *this_syntax = syntaxes; - bool bright = FALSE, defok = FALSE; + bool defok = FALSE; short fg, bg; size_t i; @@ -50,16 +50,24 @@ void set_colorpairs(void) #endif for (i = 0; i < NUMBER_OF_ELEMENTS; i++) { + bool bright = FALSE; + if (parse_color_names(specified_color_combo[i], &fg, &bg, &bright)) { if (fg == -1 && !defok) fg = COLOR_WHITE; if (bg == -1 && !defok) bg = COLOR_BLACK; init_pair(i + 1, fg, bg); - interface_color_pair[i] = COLOR_PAIR(i + 1); + interface_color_pair[i].bright = bright; + interface_color_pair[i].pairnum = COLOR_PAIR(i + 1); + } + else { + interface_color_pair[i].bright = FALSE; + if (i != FUNCTION_TAG) + interface_color_pair[i].pairnum = hilite_attribute; + else + interface_color_pair[i].pairnum = A_NORMAL; } - else if (i != FUNCTION_TAG) - interface_color_pair[i] = hilite_attribute; if (specified_color_combo[i] != NULL) { free(specified_color_combo[i]); @@ -69,7 +77,7 @@ void set_colorpairs(void) for (; this_syntax != NULL; this_syntax = this_syntax->next) { colortype *this_color = this_syntax->color; - int color_pair = NUMBER_OF_ELEMENTS + 1; + int clr_pair = NUMBER_OF_ELEMENTS + 1; for (; this_color != NULL; this_color = this_color->next) { const colortype *beforenow = this_syntax->color; @@ -84,8 +92,8 @@ void set_colorpairs(void) if (beforenow != this_color) this_color->pairnum = beforenow->pairnum; else { - this_color->pairnum = color_pair; - color_pair++; + this_color->pairnum = clr_pair; + clr_pair++; } } } diff --git a/src/global.c b/src/global.c index 78a1ec85..c0ee1a2d 100644 --- a/src/global.c +++ b/src/global.c @@ -209,7 +209,7 @@ int hilite_attribute = A_REVERSE; char* specified_color_combo[] = {}; /* The color combinations as specified in the rcfile. */ #endif -int interface_color_pair[] = {}; +color_pair interface_color_pair[] = {}; /* The processed color pairs for the interface elements. */ char *homedir = NULL; diff --git a/src/nano.c b/src/nano.c index 17a5d70c..9bbda9b3 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2660,10 +2660,14 @@ int main(int argc, char **argv) #ifndef DISABLE_COLOR set_colorpairs(); #else - interface_color_pair[TITLE_BAR] = hilite_attribute; - interface_color_pair[STATUS_BAR] = hilite_attribute; - interface_color_pair[KEY_COMBO] = hilite_attribute; - interface_color_pair[FUNCTION_TAG] = A_NORMAL; + interface_color_pair[TITLE_BAR].pairnum = hilite_attribute; + interface_color_pair[STATUS_BAR].pairnum = hilite_attribute; + interface_color_pair[KEY_COMBO].pairnum = hilite_attribute; + interface_color_pair[FUNCTION_TAG].pairnum = A_NORMAL; + interface_color_pair[TITLE_BAR].bright = FALSE; + interface_color_pair[STATUS_BAR].bright = FALSE; + interface_color_pair[KEY_COMBO].bright = FALSE; + interface_color_pair[FUNCTION_TAG].bright = FALSE; #endif #ifdef DEBUG diff --git a/src/nano.h b/src/nano.h index 7e97ffe7..7fe8ac34 100644 --- a/src/nano.h +++ b/src/nano.h @@ -191,6 +191,14 @@ typedef enum { ADD, DEL, REPLACE, SPLIT, UNSPLIT, CUT, UNCUT, ENTER, INSERT, OTHER } undo_type; +typedef struct color_pair { + int pairnum; + /* The color pair number used for this foreground color and + * background color. */ + bool bright; + /* Is this color A_BOLD? */ +} color_pair; + #ifndef DISABLE_COLOR typedef struct colortype { short fg; diff --git a/src/prompt.c b/src/prompt.c index e8bbb868..931792f8 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -853,7 +853,9 @@ void update_statusbar_line(const char *curranswer, size_t index) index = strnlenpt(curranswer, index); page_start = get_statusbar_page_start(start_col, start_col + index); - wattron(bottomwin, interface_color_pair[TITLE_BAR]); + if (interface_color_pair[TITLE_BAR].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum); blank_statusbar(); @@ -866,7 +868,8 @@ void update_statusbar_line(const char *curranswer, size_t index) waddstr(bottomwin, expanded); free(expanded); - wattroff(bottomwin, interface_color_pair[TITLE_BAR]); + wattroff(bottomwin, A_BOLD); + wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); statusbar_pww = statusbar_xplustabs(); reset_statusbar_cursor(); wnoutrefresh(bottomwin); @@ -1273,12 +1276,15 @@ int do_yesno_prompt(bool all, const char *msg) onekey("^C", _("Cancel"), width); } - wattron(bottomwin, interface_color_pair[TITLE_BAR]); + if (interface_color_pair[TITLE_BAR].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum); blank_statusbar(); mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1)); - wattroff(bottomwin, interface_color_pair[TITLE_BAR]); + wattroff(bottomwin, A_BOLD); + wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); /* Refresh the edit window and the statusbar before getting * input. */ diff --git a/src/proto.h b/src/proto.h index c4d00e4a..be1cb89e 100644 --- a/src/proto.h +++ b/src/proto.h @@ -134,7 +134,7 @@ extern int hilite_attribute; #ifndef DISABLE_COLOR extern char* specified_color_combo[NUMBER_OF_ELEMENTS]; #endif -extern int interface_color_pair[NUMBER_OF_ELEMENTS]; +extern color_pair interface_color_pair[NUMBER_OF_ELEMENTS]; extern char *homedir; diff --git a/src/winio.c b/src/winio.c index 01289364..57ed235a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2095,7 +2095,9 @@ void titlebar(const char *path) assert(path != NULL || openfile->filename != NULL); - wattron(topwin, interface_color_pair[TITLE_BAR]); + if (interface_color_pair[TITLE_BAR].bright) + wattron(topwin, A_BOLD); + wattron(topwin, interface_color_pair[TITLE_BAR].pairnum); blank_titlebar(); @@ -2226,7 +2228,8 @@ void titlebar(const char *path) } } - wattroff(topwin, interface_color_pair[TITLE_BAR]); + wattroff(topwin, A_BOLD); + wattroff(topwin, interface_color_pair[TITLE_BAR].pairnum); wnoutrefresh(topwin); reset_cursor(); @@ -2296,12 +2299,15 @@ void statusbar(const char *msg, ...) start_x = (COLS - strlenpt(foo) - 4) / 2; wmove(bottomwin, 0, start_x); - wattron(bottomwin, interface_color_pair[STATUS_BAR]); + if (interface_color_pair[STATUS_BAR].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[STATUS_BAR].pairnum); waddstr(bottomwin, "[ "); waddstr(bottomwin, foo); free(foo); waddstr(bottomwin, " ]"); - wattroff(bottomwin, interface_color_pair[STATUS_BAR]); + wattroff(bottomwin, A_BOLD); + wattroff(bottomwin, interface_color_pair[STATUS_BAR].pairnum); wnoutrefresh(bottomwin); reset_cursor(); wnoutrefresh(edit); @@ -2401,9 +2407,12 @@ void onekey(const char *keystroke, const char *desc, size_t len) assert(keystroke != NULL && desc != NULL); - wattron(bottomwin, interface_color_pair[KEY_COMBO]); + if (interface_color_pair[KEY_COMBO].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[KEY_COMBO].pairnum); waddnstr(bottomwin, keystroke, actual_x(keystroke, len)); - wattroff(bottomwin, interface_color_pair[KEY_COMBO]); + wattroff(bottomwin, A_BOLD); + wattroff(bottomwin, interface_color_pair[KEY_COMBO].pairnum); if (len > keystroke_len) len -= keystroke_len; @@ -2411,10 +2420,13 @@ void onekey(const char *keystroke, const char *desc, size_t len) len = 0; if (len > 0) { - wattron(bottomwin, interface_color_pair[FUNCTION_TAG]); waddch(bottomwin, ' '); + if (interface_color_pair[FUNCTION_TAG].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[FUNCTION_TAG].pairnum); waddnstr(bottomwin, desc, actual_x(desc, len)); - wattroff(bottomwin, interface_color_pair[FUNCTION_TAG]); + wattroff(bottomwin, A_BOLD); + wattroff(bottomwin, interface_color_pair[FUNCTION_TAG].pairnum); } }