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
master
Benno Schulenberg 2014-05-10 19:15:04 +00:00
parent 77afd32e68
commit e7d6e55332
8 changed files with 67 additions and 25 deletions

View File

@ -1,3 +1,7 @@
2014-05-10 Mark Majeres <mark@engine12.com>
* src/*.h, src/*.c: Make it possible for the foreground colour of
interface elements to be bright.
2014-05-09 Benno Schulenberg <bensberg@justemail.net> 2014-05-09 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (get_mouseinput): Count only shortcuts that are actually * src/winio.c (get_mouseinput): Count only shortcuts that are actually
shown, so that clicking on the ones after ^T (Speller/Linter) will work shown, so that clicking on the ones after ^T (Speller/Linter) will work

View File

@ -38,7 +38,7 @@
void set_colorpairs(void) void set_colorpairs(void)
{ {
const syntaxtype *this_syntax = syntaxes; const syntaxtype *this_syntax = syntaxes;
bool bright = FALSE, defok = FALSE; bool defok = FALSE;
short fg, bg; short fg, bg;
size_t i; size_t i;
@ -50,16 +50,24 @@ void set_colorpairs(void)
#endif #endif
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) { for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
bool bright = FALSE;
if (parse_color_names(specified_color_combo[i], &fg, &bg, &bright)) { if (parse_color_names(specified_color_combo[i], &fg, &bg, &bright)) {
if (fg == -1 && !defok) if (fg == -1 && !defok)
fg = COLOR_WHITE; fg = COLOR_WHITE;
if (bg == -1 && !defok) if (bg == -1 && !defok)
bg = COLOR_BLACK; bg = COLOR_BLACK;
init_pair(i + 1, fg, bg); 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) { if (specified_color_combo[i] != NULL) {
free(specified_color_combo[i]); free(specified_color_combo[i]);
@ -69,7 +77,7 @@ void set_colorpairs(void)
for (; this_syntax != NULL; this_syntax = this_syntax->next) { for (; this_syntax != NULL; this_syntax = this_syntax->next) {
colortype *this_color = this_syntax->color; 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) { for (; this_color != NULL; this_color = this_color->next) {
const colortype *beforenow = this_syntax->color; const colortype *beforenow = this_syntax->color;
@ -84,8 +92,8 @@ void set_colorpairs(void)
if (beforenow != this_color) if (beforenow != this_color)
this_color->pairnum = beforenow->pairnum; this_color->pairnum = beforenow->pairnum;
else { else {
this_color->pairnum = color_pair; this_color->pairnum = clr_pair;
color_pair++; clr_pair++;
} }
} }
} }

View File

@ -209,7 +209,7 @@ int hilite_attribute = A_REVERSE;
char* specified_color_combo[] = {}; char* specified_color_combo[] = {};
/* The color combinations as specified in the rcfile. */ /* The color combinations as specified in the rcfile. */
#endif #endif
int interface_color_pair[] = {}; color_pair interface_color_pair[] = {};
/* The processed color pairs for the interface elements. */ /* The processed color pairs for the interface elements. */
char *homedir = NULL; char *homedir = NULL;

View File

@ -2660,10 +2660,14 @@ int main(int argc, char **argv)
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
set_colorpairs(); set_colorpairs();
#else #else
interface_color_pair[TITLE_BAR] = hilite_attribute; interface_color_pair[TITLE_BAR].pairnum = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute; interface_color_pair[STATUS_BAR].pairnum = hilite_attribute;
interface_color_pair[KEY_COMBO] = hilite_attribute; interface_color_pair[KEY_COMBO].pairnum = hilite_attribute;
interface_color_pair[FUNCTION_TAG] = A_NORMAL; 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 #endif
#ifdef DEBUG #ifdef DEBUG

View File

@ -191,6 +191,14 @@ typedef enum {
ADD, DEL, REPLACE, SPLIT, UNSPLIT, CUT, UNCUT, ENTER, INSERT, OTHER ADD, DEL, REPLACE, SPLIT, UNSPLIT, CUT, UNCUT, ENTER, INSERT, OTHER
} undo_type; } 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 #ifndef DISABLE_COLOR
typedef struct colortype { typedef struct colortype {
short fg; short fg;

View File

@ -853,7 +853,9 @@ void update_statusbar_line(const char *curranswer, size_t index)
index = strnlenpt(curranswer, index); index = strnlenpt(curranswer, index);
page_start = get_statusbar_page_start(start_col, start_col + 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(); blank_statusbar();
@ -866,7 +868,8 @@ void update_statusbar_line(const char *curranswer, size_t index)
waddstr(bottomwin, expanded); waddstr(bottomwin, expanded);
free(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(); statusbar_pww = statusbar_xplustabs();
reset_statusbar_cursor(); reset_statusbar_cursor();
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);
@ -1273,12 +1276,15 @@ int do_yesno_prompt(bool all, const char *msg)
onekey("^C", _("Cancel"), width); 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(); blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1)); 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 /* Refresh the edit window and the statusbar before getting
* input. */ * input. */

View File

@ -134,7 +134,7 @@ extern int hilite_attribute;
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
extern char* specified_color_combo[NUMBER_OF_ELEMENTS]; extern char* specified_color_combo[NUMBER_OF_ELEMENTS];
#endif #endif
extern int interface_color_pair[NUMBER_OF_ELEMENTS]; extern color_pair interface_color_pair[NUMBER_OF_ELEMENTS];
extern char *homedir; extern char *homedir;

View File

@ -2095,7 +2095,9 @@ void titlebar(const char *path)
assert(path != NULL || openfile->filename != NULL); 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(); 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); wnoutrefresh(topwin);
reset_cursor(); reset_cursor();
@ -2296,12 +2299,15 @@ void statusbar(const char *msg, ...)
start_x = (COLS - strlenpt(foo) - 4) / 2; start_x = (COLS - strlenpt(foo) - 4) / 2;
wmove(bottomwin, 0, start_x); 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, "[ ");
waddstr(bottomwin, foo); waddstr(bottomwin, foo);
free(foo); free(foo);
waddstr(bottomwin, " ]"); waddstr(bottomwin, " ]");
wattroff(bottomwin, interface_color_pair[STATUS_BAR]); wattroff(bottomwin, A_BOLD);
wattroff(bottomwin, interface_color_pair[STATUS_BAR].pairnum);
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);
reset_cursor(); reset_cursor();
wnoutrefresh(edit); wnoutrefresh(edit);
@ -2401,9 +2407,12 @@ void onekey(const char *keystroke, const char *desc, size_t len)
assert(keystroke != NULL && desc != NULL); 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)); 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) if (len > keystroke_len)
len -= keystroke_len; len -= keystroke_len;
@ -2411,10 +2420,13 @@ void onekey(const char *keystroke, const char *desc, size_t len)
len = 0; len = 0;
if (len > 0) { if (len > 0) {
wattron(bottomwin, interface_color_pair[FUNCTION_TAG]);
waddch(bottomwin, ' '); 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)); 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);
} }
} }