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>
* src/winio.c (get_mouseinput): Count only shortcuts that are actually
shown, so that clicking on the ones after ^T (Speller/Linter) will work

View File

@ -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++;
}
}
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -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);
}
}