summaryrefslogtreecommitdiff
path: root/src/gui/curses/gui-curses-bar-window.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-06-21 18:59:54 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-06-21 18:59:54 +0200
commitb0ecbdbf1da175802d3e2f82cf181060886247e3 (patch)
tree28f18dcad3ab64bd2b15bd8cf92bb63fb66654ed /src/gui/curses/gui-curses-bar-window.c
parent5b151d1639f4656f79b92b7b495251b51bc10d1d (diff)
downloadweechat-b0ecbdbf1da175802d3e2f82cf181060886247e3.zip
core: add bar option "color_bg_inactive" (issue #732)
Diffstat (limited to 'src/gui/curses/gui-curses-bar-window.c')
-rw-r--r--src/gui/curses/gui-curses-bar-window.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c
index 2204a8755..7d8eb69a1 100644
--- a/src/gui/curses/gui-curses-bar-window.c
+++ b/src/gui/curses/gui-curses-bar-window.c
@@ -164,6 +164,7 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
int
gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
+ struct t_gui_window *window,
enum t_gui_bar_filling filling,
int *x, int *y,
const char *string,
@@ -171,7 +172,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
int hide_chars_if_scrolling,
int *index_item, int *index_subitem, int *index_line)
{
- int x_with_hidden, size_on_screen, low_char, hidden;
+ int x_with_hidden, size_on_screen, low_char, hidden, color_bg;
char utf_char[16], *next_char, *output;
if (!bar_window || !string || !string[0])
@@ -179,11 +180,15 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
wmove (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, *y, *x);
+ color_bg = ((CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_TYPE]) != GUI_BAR_TYPE_ROOT)
+ && (window != gui_current_window)) ?
+ GUI_BAR_OPTION_COLOR_BG_INACTIVE : GUI_BAR_OPTION_COLOR_BG;
+
if (reset_color_before_display)
{
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ CONFIG_COLOR(bar_window->bar->options[color_bg]),
1);
}
@@ -242,7 +247,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
/* bar background */
string += 2;
gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
+ CONFIG_COLOR(bar_window->bar->options[color_bg]));
break;
case GUI_COLOR_BAR_START_INPUT_CHAR:
string += 2;
@@ -304,7 +309,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
string++;
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ CONFIG_COLOR(bar_window->bar->options[color_bg]),
0);
break;
default:
@@ -329,7 +334,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
A_ALL_ATTR);
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ CONFIG_COLOR(bar_window->bar->options[color_bg]),
1);
break;
default:
@@ -409,7 +414,7 @@ void
gui_bar_window_draw (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
- int x, y, items_count, num_lines, line;
+ int x, y, items_count, num_lines, line, color_bg;
enum t_gui_bar_filling filling;
char *content, **items;
static char str_start_input[16] = { '\0' };
@@ -434,6 +439,10 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if (!bar_window || (bar_window->x < 0) || (bar_window->y < 0))
return;
+ color_bg = ((CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_TYPE]) != GUI_BAR_TYPE_ROOT)
+ && (window != gui_current_window)) ?
+ GUI_BAR_OPTION_COLOR_BG_INACTIVE : GUI_BAR_OPTION_COLOR_BG;
+
if (!str_start_input[0])
{
snprintf (str_start_input, sizeof (str_start_input), "%c%c%c",
@@ -497,7 +506,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
gui_bar_window_set_current_size (bar_window, window, 1);
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
+ CONFIG_COLOR(bar_window->bar->options[color_bg]));
}
else
{
@@ -552,7 +561,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
+ CONFIG_COLOR(bar_window->bar->options[color_bg]));
x = 0;
y = 0;
some_data_not_displayed = 0;
@@ -645,7 +654,9 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if ((bar_window->scroll_y == 0)
|| (line >= bar_window->scroll_y))
{
- if (!gui_bar_window_print_string (bar_window, filling,
+ if (!gui_bar_window_print_string (bar_window,
+ window,
+ filling,
&x, &y,
items[line], 1, 1,
&index_item,
@@ -661,7 +672,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ CONFIG_COLOR(bar_window->bar->options[color_bg]),
1);
gui_window_remove_color_style (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
A_ALL_ATTR);
@@ -674,7 +685,9 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
while (x < bar_window->width)
{
- gui_bar_window_print_string (bar_window, filling,
+ gui_bar_window_print_string (bar_window,
+ window,
+ filling,
&x, &y, " ", 0, 0,
&index_item,
&index_subitem,
@@ -706,7 +719,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(config_color_bar_more),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ CONFIG_COLOR(bar_window->bar->options[color_bg]),
1);
mvwaddstr (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
y, x, ptr_string);
@@ -726,7 +739,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(config_color_bar_more),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]),
+ CONFIG_COLOR(bar_window->bar->options[color_bg]),
1);
mvwaddstr (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
y, x, ptr_string);
@@ -743,7 +756,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
gui_bar_window_set_current_size (bar_window, window, 1);
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
- CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
+ CONFIG_COLOR(bar_window->bar->options[color_bg]));
}
/*