From c4372c31ce07f6fce8b41486f6b8ba2956965a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 14 Mar 2021 00:13:15 -0300 Subject: Fixed SIGWINCH when input bar is at bottom Added new HEADINGS_ODD, GRID_PAIR, and GRID_ODD types. Can be used like this: DEFINE_COLOR "cornsilk" 255 248 220 DEFINE_COLOR "wheat" 245 222 179 DEFINE_COLOR "dark_khaki" 189 183 107 DEFINE_COLOR "gray50" 127 127 127 DEFINE_COLOR "gray80" 204 204 204 DEFINE_COLOR "gray90" 229 229 229 color "type=GRID_PAIR fg=dark_khaki bg=cornsilk" color "type=GRID_ODD fg=dark_khaki bg=wheat" color "type=HEADINGS fg=dark_khaki bg=gray50" color "type=HEADINGS_ODD fg=gray50 bg=gray90" --- src/color.c | 19 +++++++--- src/color.h | 2 +- src/help.c | 14 ++++---- src/macros.h | 3 ++ src/tui.c | 114 ++++++++++++++++++++++++++++++++++++++--------------------- src/tui.h | 2 +- 6 files changed, 101 insertions(+), 53 deletions(-) diff --git a/src/color.c b/src/color.c index c17ca70..547c67b 100644 --- a/src/color.c +++ b/src/color.c @@ -97,8 +97,14 @@ void start_default_ucolors() { // Set some colors attributes ucolors[ DEFAULT ].fg = WHITE; ucolors[ DEFAULT ].bg = DEFAULT_COLOR; - ucolors[ HEADINGS ].fg = RED; - ucolors[ HEADINGS ].bg = WHITE; + ucolors[ HEADINGS ].bg = RED; + ucolors[ HEADINGS ].fg = WHITE; + ucolors[ HEADINGS_ODD ].bg = RED; + ucolors[ HEADINGS_ODD ].fg = WHITE; + ucolors[ GRID_PAIR ].fg = WHITE; + ucolors[ GRID_PAIR ].bg = DEFAULT_COLOR; + ucolors[ GRID_ODD ].fg = WHITE; + ucolors[ GRID_ODD ].bg = DEFAULT_COLOR; ucolors[ WELCOME ].fg = WHITE; ucolors[ WELCOME ].bg = DEFAULT_COLOR; ucolors[ WELCOME ].bold = 1; @@ -126,7 +132,7 @@ void start_default_ucolors() { ucolors[ MODE ].bg = DEFAULT_COLOR; ucolors[ MODE ].bold = 1; ucolors[ CELL_ID ].fg = WHITE; - ucolors[ CELL_ID ].bg = BLACK; + ucolors[ CELL_ID ].bg = DEFAULT_COLOR; ucolors[ CELL_ID ].bold = 1; ucolors[ CELL_FORMAT ].fg = RED; ucolors[ CELL_FORMAT ].bg = DEFAULT_COLOR; @@ -185,6 +191,12 @@ void set_colors_param_dict() { put(d_colors_param, "WHITE", str); sprintf(str, "%d", HEADINGS); put(d_colors_param, "HEADINGS", str); + sprintf(str, "%d", HEADINGS_ODD); + put(d_colors_param, "HEADINGS_ODD", str); + sprintf(str, "%d", GRID_PAIR); + put(d_colors_param, "GRID_PAIR", str); + sprintf(str, "%d", GRID_ODD); + put(d_colors_param, "GRID_ODD", str); sprintf(str, "%d", WELCOME); put(d_colors_param, "WELCOME", str); sprintf(str, "%d", CELL_SELECTION); @@ -619,7 +631,6 @@ int define_color(char * color, int r, int g, int b) { cc->r = r; cc->g = g; cc->b = b; - //sc_debug("modified extended color: %d", 7 + cc->number); init_extended_color(7 + cc->number, RGB(r, g, b)); if (! loading) sc_info("Defined custom color #%d with name '%s' and RGB values %d %d %d", cc->number, cc->name, cc->r, cc->g, cc->b); diff --git a/src/color.h b/src/color.h index 8216d84..0358cee 100644 --- a/src/color.h +++ b/src/color.h @@ -47,7 +47,7 @@ #include #define RGB(r, g, b) floor(r*999/255), floor(g*999/255), floor(b*999/255) -#define N_INIT_PAIRS 19 +#define N_INIT_PAIRS 24 struct ucolor { int fg; diff --git a/src/help.c b/src/help.c index 20e3b51..50282cf 100644 --- a/src/help.c +++ b/src/help.c @@ -156,7 +156,7 @@ void help() { wclrtobot(input_win); wrefresh(input_win); - ui_set_ucolor(main_win, &ucolors[NORMAL]); + ui_set_ucolor(main_win, &ucolors[NORMAL], DEFAULT_COLOR); wtimeout(input_win, -1); noecho(); curs_set(0); @@ -337,7 +337,7 @@ void find_word(char * word, char order) { if (look_result == -1) { sc_info("Pattern not found."); } - ui_set_ucolor(input_win, &ucolors[NORMAL]); + ui_set_ucolor(input_win, &ucolors[NORMAL], DEFAULT_COLOR); return; } @@ -366,8 +366,8 @@ int show_lines() { #ifdef USECOLORS bold && ! key? - ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]) : - ui_set_ucolor(main_win, &ucolors[NORMAL]); + ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC], DEFAULT_COLOR) : + ui_set_ucolor(main_win, &ucolors[NORMAL], DEFAULT_COLOR); #endif if (long_help[lineno + delta][i] == '<' || long_help[lineno + delta][i] == '{') { @@ -383,17 +383,17 @@ int show_lines() { if (long_help[lineno + delta][i] == '&') { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[NORMAL]); + ui_set_ucolor(main_win, &ucolors[NORMAL], DEFAULT_COLOR); #endif continue; } else if (look_result != -1 && i >= look_result && i < look_result + strlen(word_looked) ) { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]); + ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC], DEFAULT_COLOR); #endif } else if (key) { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[NUMB]); + ui_set_ucolor(main_win, &ucolors[NUMB], DEFAULT_COLOR); #endif } diff --git a/src/macros.h b/src/macros.h index 486c846..ca4c9b5 100644 --- a/src/macros.h +++ b/src/macros.h @@ -104,6 +104,9 @@ #define DEFAULT 18 #define DEBUG_MSG 19 #define VALUE_MSG 20 +#define GRID_PAIR 21 +#define GRID_ODD 22 +#define HEADINGS_ODD 23 void ui_sc_msg(char * s, int type, ...); #define sc_error(x, ...) ui_sc_msg(x, ERROR_MSG, ##__VA_ARGS__) diff --git a/src/tui.c b/src/tui.c index 5543b70..99f2952 100644 --- a/src/tui.c +++ b/src/tui.c @@ -235,9 +235,9 @@ void ui_sc_msg(char * s, int type, ...) { if ( ! atoi(get_conf_value("nocurses"))) { #ifdef USECOLORS if (type == ERROR_MSG) - ui_set_ucolor(input_win, &ucolors[ERROR_MSG]); + ui_set_ucolor(input_win, &ucolors[ERROR_MSG], DEFAULT_COLOR); else - ui_set_ucolor(input_win, &ucolors[INFO_MSG]); + ui_set_ucolor(input_win, &ucolors[INFO_MSG], DEFAULT_COLOR); #endif mvwprintw(input_win, 1, 0, "%s", t); wclrtoeol(input_win); @@ -299,7 +299,7 @@ void ui_do_welcome() { ui_show_sc_row_headings(main_win, mxrow); #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME], DEFAULT_COLOR); #endif // show message @@ -308,31 +308,31 @@ void ui_do_welcome() { mvwaddstr(main_win, LINES/2-1, COLS/2-strlen(msg_version)/2, msg_version); #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME], DEFAULT_COLOR); #endif for (i=0; msg_help[i] != '\0'; i++) { if (msg_help[i] == '<') { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[NUMB]); + ui_set_ucolor(main_win, &ucolors[NUMB], DEFAULT_COLOR); #endif } mvwaddstr(main_win, LINES/2, COLS/2-strlen(msg_help)/2+i, &msg_help[i]); if (msg_help[i] == '>') { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME], DEFAULT_COLOR); #endif } } for (i=0; msg_help2[i] != '\0'; i++) { if (msg_help2[i] == '<') { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[NUMB]); + ui_set_ucolor(main_win, &ucolors[NUMB], DEFAULT_COLOR); #endif } mvwaddstr(main_win, LINES/2+1, COLS/2-strlen(msg_help2)/2+i, &msg_help2[i]); if (msg_help2[i] == '>') { #ifdef USECOLORS - ui_set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME], DEFAULT_COLOR); #endif } } @@ -402,6 +402,7 @@ void ui_update(int header) { while (col_hidden[curcol]) curcol++; + // Show the content of the cells // Numeric values, strings. ui_show_content(main_win, mxrow, mxcol); @@ -478,7 +479,7 @@ void ui_print_mult_pend() { getyx(input_win, row_orig, col_orig); #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[MODE]); + ui_set_ucolor(input_win, &ucolors[MODE], DEFAULT_COLOR); #endif // Show multiplier and pending operator char strm[COLS]; @@ -570,7 +571,7 @@ void ui_print_mode() { char strm[PATHLEN+22] = ""; #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[MODE]); + ui_set_ucolor(input_win, &ucolors[MODE], DEFAULT_COLOR); #endif strm[0] = '\0'; @@ -587,7 +588,7 @@ void ui_print_mode() { ui_write_j(input_win, strm, row, RIGHT); #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[INPUT]); + ui_set_ucolor(input_win, &ucolors[INPUT], DEFAULT_COLOR); #endif // Show submode (INSERT) mvwprintw(input_win, 0, 0 + rescol, "%c", insert_edit_submode); @@ -608,7 +609,7 @@ void ui_print_mode() { ui_write_j(input_win, strm, row, RIGHT); #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[INPUT]); + ui_set_ucolor(input_win, &ucolors[INPUT], DEFAULT_COLOR); #endif // muestro ':' mvwprintw(input_win, 0, 0 + rescol, ":"); @@ -630,7 +631,7 @@ void ui_print_mode() { void ui_show_sc_row_headings(WINDOW * win, int mxrow) { int row = 0; #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[HEADINGS]); + if (has_colors()) ui_set_ucolor(win, &ucolors[HEADINGS], DEFAULT_COLOR); #endif int i; int freeze = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0; @@ -654,7 +655,7 @@ void ui_show_sc_row_headings(WINDOW * win, int mxrow) { srange * s = get_selected_range(); if ( (s != NULL && i >= s->tlrow && i <= s->brrow) || i == currow ) { #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION]); + if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION], DEFAULT_COLOR); #else wattron(win, A_REVERSE); #endif @@ -662,7 +663,7 @@ void ui_show_sc_row_headings(WINDOW * win, int mxrow) { mvwprintw (win, row+1, 0, "%*d ", rescol-1, i); #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[HEADINGS]); + if (has_colors()) ui_set_ucolor(win, &ucolors[HEADINGS], DEFAULT_COLOR); #else wattroff(win, A_REVERSE); #endif @@ -682,16 +683,21 @@ void ui_show_sc_row_headings(WINDOW * win, int mxrow) { void ui_show_sc_col_headings(WINDOW * win, int mxcol) { int i, col = rescol; int freeze = freeze_ranges && (freeze_ranges->type == 'c' || freeze_ranges->type == 'a') ? 1 : 0; + //int l; - #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[HEADINGS]); - #endif wmove(win, 0, 0); wclrtoeol(win); //for (i = 0; i <= mxcol && i < maxcols; i++) { for (i = 0; i <= mxcol; i++) { + #ifdef USECOLORS + if (has_colors() && i % 2 == 0) + ui_set_ucolor(win, &ucolors[HEADINGS], DEFAULT_COLOR); + else if (i % 2 == 1) + ui_set_ucolor(win, &ucolors[HEADINGS_ODD], DEFAULT_COLOR); + #endif + if (i >= maxcols) { sc_error("i >= maxcols in ui_show_sc_col_headings. please check calc_offscr_sc_cols."); break; @@ -710,25 +716,43 @@ void ui_show_sc_col_headings(WINDOW * win, int mxcol) { srange * s = get_selected_range(); if ( (s != NULL && i >= s->tlcol && i <= s->brcol) || i == curcol ) { #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION]); + if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION], DEFAULT_COLOR); #else wattron(win, A_REVERSE); #endif } (void) mvwprintw(win, 0, col, "%*s%-*s", k-1, " ", fwidth[i] - k + 1, coltoa(i)); + /* We also colorize the columns with alternate color + #ifdef USECOLORS + if (has_colors() && i % 2 == 0) + ui_set_ucolor(win, &ucolors[GRID_PAIR], DEFAULT_COLOR); + else if (i % 2 == 1) + ui_set_ucolor(win, &ucolors[GRID_ODD], DEFAULT_COLOR); + + for (l=1; l 0) wclrtoeol(win); #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[HEADINGS]); + if (has_colors() && i % 2 == 0) + ui_set_ucolor(win, &ucolors[HEADINGS], DEFAULT_COLOR); + else if (i % 2 == 1) + ui_set_ucolor(win, &ucolors[HEADINGS_ODD], DEFAULT_COLOR); #else wattroff(win, A_REVERSE); #endif } } + + /** * \brief Show the content of the cell * @@ -791,6 +815,7 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { break; } + nextcol = col + 1; fieldlen = fwidth[col]; @@ -821,31 +846,32 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { // Clean format #ifdef USECOLORS if ((*p) && (*p)->cellerror) { // cellerror - ui_set_ucolor(win, &ucolors[CELL_ERROR]); + ui_set_ucolor(win, &ucolors[CELL_ERROR], ucolors[CELL_ERROR].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else if ((*p) && (*p)->v < 0) { // cell negative - ui_set_ucolor(win, &ucolors[CELL_NEGATIVE]); + ui_set_ucolor(win, &ucolors[CELL_NEGATIVE], ucolors[CELL_NEGATIVE].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else if ((*p) && (*p)->expr) { - ui_set_ucolor(win, &ucolors[EXPRESSION]); + ui_set_ucolor(win, &ucolors[EXPRESSION], ucolors[EXPRESSION].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else if ((*p) && (*p)->label) { // string - ui_set_ucolor(win, &ucolors[STRG]); + ui_set_ucolor(win, &ucolors[STRG], ucolors[STRG].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else if ((*p) && (*p)->flags & is_valid && ! (*p)->format) { // numeric value - ui_set_ucolor(win, &ucolors[NUMB]); + ui_set_ucolor(win, &ucolors[NUMB], ucolors[NUMB].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else if ((*p) && (*p)->format && (*p)->format[0] == 'd') { // date format - ui_set_ucolor(win, &ucolors[DATEF]); + ui_set_ucolor(win, &ucolors[DATEF], ucolors[DATEF].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } else { - ui_set_ucolor(win, &ucolors[NORMAL]); + ui_set_ucolor(win, &ucolors[NORMAL], ucolors[NORMAL].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } #endif // Cell color! if ((*p) && (*p)->ucolor != NULL) { - ui_set_ucolor(win, (*p)->ucolor); + ui_set_ucolor(win, (*p)->ucolor, (*p)->ucolor->bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); } + // Color selected cell if ((currow == row) && (curcol == col)) { #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC]); + if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC], ucolors[CELL_SELECTION_SC].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); #else wattron(win, A_REVERSE); #endif @@ -856,7 +882,7 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { srange * s = get_selected_range(); if (s != NULL && row >= s->tlrow && row <= s->brrow && col >= s->tlcol && col <= s->brcol ) { #ifdef USECOLORS - ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC]); + if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC], ucolors[CELL_SELECTION_SC].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); #else wattron(win, A_REVERSE); #endif @@ -868,7 +894,7 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { col >= ranges->tlcol && col <= ranges->brcol ) { #ifdef USECOLORS - ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC]); + if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC], ucolors[CELL_SELECTION_SC].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); #else wattron(win, A_REVERSE); #endif @@ -922,19 +948,21 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { } + // repaint a blank cell, because of in range, or because we have a coloured empty cell! if ( !(*p) || (( !((*p)->flags & is_valid) && !(*p)->label ) && !((*p)->cellerror == CELLERROR)) ) { if ( (currow == row && curcol == col) || ( in_range && row >= ranges->tlrow && row <= ranges->brrow && col >= ranges->tlcol && col <= ranges->brcol ) ) { #ifdef USECOLORS - if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC]); + if (has_colors()) ui_set_ucolor(win, &ucolors[CELL_SELECTION_SC], ucolors[CELL_SELECTION_SC].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); #else wattron(win, A_REVERSE); #endif } else if ( !(*p) || (*p)->ucolor == NULL) { #ifdef USECOLORS - ui_set_ucolor(win, &ucolors[STRG]); // When a long string does not fit in column. + // When a long string does not fit in column. + ui_set_ucolor(win, &ucolors[STRG], ucolors[STRG].bg != DEFAULT_COLOR ? DEFAULT_COLOR : col % 2 == 0 ? ucolors[GRID_PAIR].bg : ucolors[GRID_ODD].bg); #endif } @@ -974,7 +1002,7 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) { * * \details Add details of an ent to a char * received as a parameter. * Used for 'input_win' - * + * * \param[in] d * \param[in] p1 * @@ -1031,7 +1059,7 @@ void ui_show_celldetails() { // show cell in header #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[CELL_ID]); + ui_set_ucolor(input_win, &ucolors[CELL_ID], DEFAULT_COLOR); #endif sprintf(head, "%s%d ", coltoa(curcol), currow); mvwprintw(input_win, 0, 0 + rescol, "%s", head); @@ -1039,7 +1067,7 @@ void ui_show_celldetails() { // show the current cell's format #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[CELL_FORMAT]); + ui_set_ucolor(input_win, &ucolors[CELL_FORMAT], DEFAULT_COLOR); #endif register struct ent *p1 = *ATBL(tbl, currow, curcol); @@ -1060,7 +1088,7 @@ void ui_show_celldetails() { // show expr #ifdef USECOLORS - ui_set_ucolor(input_win, &ucolors[CELL_CONTENT]); + ui_set_ucolor(input_win, &ucolors[CELL_CONTENT], DEFAULT_COLOR); #endif if (p1 && p1->expr) { linelim = 0; @@ -1128,6 +1156,7 @@ int ui_get_formated_value(struct ent ** p, int col, char * value) { return 1; } } else { // there is no format + // FIXME: error with number and text in same cell and no overlap engformat(realfmt[col], fwidth[col], precision[col], (*p)->v, value, sizeof(char) * FBUFLEN); return 1; } @@ -1182,6 +1211,7 @@ void sig_winchg() { wresize(main_win, LINES - RESROW, COLS); wresize(input_win, RESROW, COLS); + ui_mv_bottom_bar(); ui_update(TRUE); flushinp(); @@ -1321,14 +1351,15 @@ char * ui_query(char * initial_msg) { /** * \brief Set a color + * if bg_override != -1 (DEFAULT_COLOR) set this instead of uc->bg * * \param[in] w * \param[in] uc - * + * \param[in} bg_override * \return none */ -void ui_set_ucolor(WINDOW * w, struct ucolor * uc) { +void ui_set_ucolor(WINDOW * w, struct ucolor * uc, int bg_override) { short color; long attr = A_NORMAL; if (uc->bold) attr |= A_BOLD; @@ -1349,8 +1380,11 @@ void ui_set_ucolor(WINDOW * w, struct ucolor * uc) { // just apply other ncurses attributes attr_t a; wattr_get(w, &a, &color, NULL); - } else + } else if (bg_override == DEFAULT_COLOR) { color = (uc->fg+1)*def + uc->bg + 2; + } else { + color = (uc->fg+1)*def + bg_override + 2; + } wattr_set (w, attr | COLOR_PAIR(color), color, NULL); } diff --git a/src/tui.h b/src/tui.h index f135d03..bbdb2d1 100644 --- a/src/tui.h +++ b/src/tui.h @@ -88,7 +88,7 @@ char * ui_query(char * initial_msg); void ui_start_colors(); void ui_sc_msg(char * s, int type, ...); -void ui_set_ucolor(WINDOW * w, struct ucolor * uc); +void ui_set_ucolor(WINDOW * w, struct ucolor * uc, int bg_override); void ui_show_content(WINDOW * win, int mxrow, int mxcol); void ui_show_sc_row_headings(WINDOW * win, int mxrow); void ui_show_sc_col_headings(WINDOW * win, int mxcol); -- cgit v1.2.3