From 8507dd4bd0dcc3230927abb070be3b5268b3acd4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Mon, 11 Jul 2016 22:25:56 +0200 Subject: [PATCH] color: integrate the hilite attribute into the pair number Color-pair numbers and attributes can be OR'd together -- do so, to save an attron() call whenever the hilite is on. --- src/color.c | 5 +++-- src/prompt.c | 6 ------ src/winio.c | 12 ------------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/color.c b/src/color.c index 774da9b0..1caea04a 100644 --- a/src/color.c +++ b/src/color.c @@ -62,8 +62,9 @@ void set_colorpairs(void) if (background == -1 && !using_defaults) background = COLOR_BLACK; init_pair(i + 1, foreground, background); - interface_color_pair[i].bright = bright; - interface_color_pair[i].pairnum = COLOR_PAIR(i + 1); + interface_color_pair[i].bright = FALSE; + interface_color_pair[i].pairnum = + COLOR_PAIR(i + 1) | (bright ? A_BOLD : A_NORMAL); } else { interface_color_pair[i].bright = FALSE; diff --git a/src/prompt.c b/src/prompt.c index dda95838..4c81a123 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -491,8 +491,6 @@ void update_the_statusbar(void) index = strnlenpt(answer, statusbar_x); page_start = get_statusbar_page_start(start_col, start_col + index); - if (interface_color_pair[TITLE_BAR].bright) - wattron(bottomwin, A_BOLD); wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum); blank_statusbar(); @@ -505,7 +503,6 @@ void update_the_statusbar(void) waddstr(bottomwin, expanded); free(expanded); - wattroff(bottomwin, A_BOLD); wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); statusbar_pww = statusbar_xplustabs(); @@ -855,14 +852,11 @@ int do_yesno_prompt(bool all, const char *msg) onekey("^C", _("Cancel"), width); } - 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, A_BOLD); wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); /* Refresh edit window and statusbar before getting input. */ diff --git a/src/winio.c b/src/winio.c index d26cea0d..62cbd4c2 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1868,8 +1868,6 @@ void titlebar(const char *path) assert(path != NULL || openfile->filename != NULL); - if (interface_color_pair[TITLE_BAR].bright) - wattron(topwin, A_BOLD); wattron(topwin, interface_color_pair[TITLE_BAR].pairnum); blank_titlebar(); @@ -1957,7 +1955,6 @@ void titlebar(const char *path) else if (statelen > 0) mvwaddnstr(topwin, 0, 0, state, actual_x(state, COLS)); - wattroff(topwin, A_BOLD); wattroff(topwin, interface_color_pair[TITLE_BAR].pairnum); wnoutrefresh(topwin); @@ -2027,14 +2024,11 @@ void statusline(message_type importance, const char *msg, ...) start_x = (COLS - strlenpt(foo) - 4) / 2; wmove(bottomwin, 0, start_x); - 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, A_BOLD); wattroff(bottomwin, interface_color_pair[STATUS_BAR].pairnum); /* Push the message to the screen straightaway. */ @@ -2132,22 +2126,16 @@ void onekey(const char *keystroke, const char *desc, int length) { assert(keystroke != NULL && desc != NULL); - 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, length)); - wattroff(bottomwin, A_BOLD); wattroff(bottomwin, interface_color_pair[KEY_COMBO].pairnum); length -= strlenpt(keystroke) + 1; if (length > 0) { 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, length)); - wattroff(bottomwin, A_BOLD); wattroff(bottomwin, interface_color_pair[FUNCTION_TAG].pairnum); } } -- GitLab