diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-06-21 18:59:54 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-06-21 18:59:54 +0200 |
commit | b0ecbdbf1da175802d3e2f82cf181060886247e3 (patch) | |
tree | 28f18dcad3ab64bd2b15bd8cf92bb63fb66654ed /src/gui | |
parent | 5b151d1639f4656f79b92b7b495251b51bc10d1d (diff) | |
download | weechat-b0ecbdbf1da175802d3e2f82cf181060886247e3.zip |
core: add bar option "color_bg_inactive" (issue #732)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-bar-window.c | 41 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 64 | ||||
-rw-r--r-- | src/gui/gui-bar.h | 3 |
3 files changed, 80 insertions, 28 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])); } /* diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 7367de28a..f683ecc16 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -50,11 +50,11 @@ char *gui_bar_option_string[GUI_BAR_NUM_OPTIONS] = { "hidden", "priority", "type", "conditions", "position", "filling_top_bottom", "filling_left_right", "size", "size_max", "color_fg", "color_delim", - "color_bg", "separator", "items" }; + "color_bg", "color_bg_inactive", "separator", "items" }; char *gui_bar_option_default[GUI_BAR_NUM_OPTIONS] = { "0", "0", "0", "", "top", "horizontal", "vertical", "0", "0", "default", "default", - "default", "off", "" }; + "default", "default", "off", "" }; char *gui_bar_type_string[GUI_BAR_NUM_TYPES] = { "root", "window" }; char *gui_bar_position_string[GUI_BAR_NUM_POSITIONS] = @@ -1187,6 +1187,8 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name) config_file_option_rename (bar->options[GUI_BAR_OPTION_COLOR_DELIM], option_name); snprintf (option_name, length, "%s.color_bg", name); config_file_option_rename (bar->options[GUI_BAR_OPTION_COLOR_BG], option_name); + snprintf (option_name, length, "%s.color_bg_inactive", name); + config_file_option_rename (bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE], option_name); snprintf (option_name, length, "%s.separator", name); config_file_option_rename (bar->options[GUI_BAR_OPTION_SEPARATOR], option_name); snprintf (option_name, length, "%s.items", name); @@ -1277,6 +1279,12 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value) gui_bar_refresh (bar); return 1; } + else if (string_strcasecmp (property, "color_bg_inactive") == 0) + { + config_file_option_set (bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE], value, 1); + gui_bar_refresh (bar); + return 1; + } else if (string_strcasecmp (property, "separator") == 0) { config_file_option_set (bar->options[GUI_BAR_OPTION_SEPARATOR], @@ -1476,6 +1484,17 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value &gui_bar_config_change_color, NULL, NULL, NULL, NULL, NULL); break; + case GUI_BAR_OPTION_COLOR_BG_INACTIVE: + ptr_option = config_file_new_option ( + weechat_config_file, weechat_config_section_bar, + option_name, "color", + N_("background color for a bar with type \"window\" which is " + "not displayed in the active window"), + NULL, 0, 0, value, NULL, 0, + NULL, NULL, NULL, + &gui_bar_config_change_color, NULL, NULL, + NULL, NULL, NULL); + break; case GUI_BAR_OPTION_SEPARATOR: ptr_option = config_file_new_option ( weechat_config_file, weechat_config_section_bar, @@ -1583,6 +1602,7 @@ gui_bar_new_with_options (const char *name, struct t_config_option *color_fg, struct t_config_option *color_delim, struct t_config_option *color_bg, + struct t_config_option *color_bg_inactive, struct t_config_option *separator, struct t_config_option *items) { @@ -1606,6 +1626,7 @@ gui_bar_new_with_options (const char *name, new_bar->options[GUI_BAR_OPTION_COLOR_FG] = color_fg; new_bar->options[GUI_BAR_OPTION_COLOR_DELIM] = color_delim; new_bar->options[GUI_BAR_OPTION_COLOR_BG] = color_bg; + new_bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE] = color_bg_inactive; new_bar->options[GUI_BAR_OPTION_SEPARATOR] = separator; new_bar->options[GUI_BAR_OPTION_ITEMS] = items; new_bar->items_count = 0; @@ -1654,15 +1675,16 @@ gui_bar_new (const char *name, const char *hidden, const char *priority, const char *filling_top_bottom, const char *filling_left_right, const char *size, const char *size_max, const char *color_fg, const char *color_delim, - const char *color_bg, const char *separators, const char *items) + const char *color_bg, const char *color_bg_inactive, + const char *separators, const char *items) { struct t_config_option *option_hidden, *option_priority, *option_type; struct t_config_option *option_conditions, *option_position; struct t_config_option *option_filling_top_bottom, *option_filling_left_right; struct t_config_option *option_size, *option_size_max; struct t_config_option *option_color_fg, *option_color_delim; - struct t_config_option *option_color_bg, *option_separator; - struct t_config_option *option_items; + struct t_config_option *option_color_bg, *option_color_bg_inactive; + struct t_config_option *option_separator, *option_items; struct t_gui_bar *new_bar; if (!name || !name[0]) @@ -1704,20 +1726,24 @@ gui_bar_new (const char *name, const char *hidden, const char *priority, color_delim); option_color_bg = gui_bar_create_option (name, GUI_BAR_OPTION_COLOR_BG, color_bg); + option_color_bg_inactive = gui_bar_create_option (name, GUI_BAR_OPTION_COLOR_BG_INACTIVE, + color_bg_inactive); option_separator = gui_bar_create_option (name, GUI_BAR_OPTION_SEPARATOR, (config_file_string_to_boolean (separators)) ? "on" : "off"); option_items = gui_bar_create_option (name, GUI_BAR_OPTION_ITEMS, items); - new_bar = gui_bar_new_with_options (name, option_hidden, - option_priority, option_type, - option_conditions, option_position, - option_filling_top_bottom, - option_filling_left_right, - option_size, option_size_max, - option_color_fg, option_color_delim, - option_color_bg, option_separator, - option_items); + new_bar = gui_bar_new_with_options ( + name, option_hidden, + option_priority, option_type, + option_conditions, option_position, + option_filling_top_bottom, + option_filling_left_right, + option_size, option_size_max, + option_color_fg, option_color_delim, + option_color_bg, option_color_bg_inactive, + option_separator, + option_items); if (!new_bar) { if (option_hidden) @@ -1794,6 +1820,7 @@ gui_bar_use_temp_bars () ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_FG], ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_DELIM], ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_BG], + ptr_temp_bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE], ptr_temp_bar->options[GUI_BAR_OPTION_SEPARATOR], ptr_temp_bar->options[GUI_BAR_OPTION_ITEMS]); } @@ -1878,6 +1905,7 @@ gui_bar_create_default_input () "default", /* color fg */ "cyan", /* color delim */ "default", /* color bg */ + "default", /* color bg inactive */ "0", /* separators */ gui_bar_default_items (GUI_BAR_DEFAULT_NAME_INPUT))) /* items */ { @@ -1915,6 +1943,7 @@ gui_bar_create_default_title () "default", /* color fg */ "cyan", /* color delim */ "blue", /* color bg */ + "darkgray", /* color bg inactive */ "0", /* separators */ gui_bar_default_items (GUI_BAR_DEFAULT_NAME_TITLE))) /* items */ { @@ -1951,6 +1980,7 @@ gui_bar_create_default_status () "default", /* color fg */ "cyan", /* color delim */ "blue", /* color bg */ + "darkgray", /* color bg inactive */ "0", /* separators */ gui_bar_default_items (GUI_BAR_DEFAULT_NAME_STATUS))) /* items */ { @@ -1987,6 +2017,7 @@ gui_bar_create_default_nicklist () "default", /* color fg */ "cyan", /* color delim */ "default", /* color bg */ + "default", /* color bg inactive */ "1", /* separators */ gui_bar_default_items (GUI_BAR_DEFAULT_NAME_NICKLIST))) /* items */ { @@ -2321,6 +2352,8 @@ gui_bar_add_to_infolist (struct t_infolist *infolist, return 0; if (!infolist_new_var_string (ptr_item, "color_bg", gui_color_get_name (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_BG])))) return 0; + if (!infolist_new_var_string (ptr_item, "color_bg_inactive", gui_color_get_name (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE])))) + return 0; if (!infolist_new_var_integer (ptr_item, "separator", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_SEPARATOR]))) return 0; if (!infolist_new_var_string (ptr_item, "items", CONFIG_STRING(bar->options[GUI_BAR_OPTION_ITEMS]))) @@ -2400,6 +2433,9 @@ gui_bar_print_log () log_printf (" color_bg . . . . . . . : %d (%s)", CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_BG]), gui_color_get_name (CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_BG]))); + log_printf (" color_bg_inactive. . . : %d (%s)", + CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE]), + gui_color_get_name (CONFIG_COLOR(ptr_bar->options[GUI_BAR_OPTION_COLOR_BG_INACTIVE]))); log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SEPARATOR])); log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_ITEMS])); log_printf (" items_count. . . . . . : %d", ptr_bar->items_count); diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h index 8d8447efc..5f42ca2d4 100644 --- a/src/gui/gui-bar.h +++ b/src/gui/gui-bar.h @@ -43,6 +43,8 @@ enum t_gui_bar_option GUI_BAR_OPTION_COLOR_FG, /* default text color for bar */ GUI_BAR_OPTION_COLOR_DELIM, /* default delimiter color for bar */ GUI_BAR_OPTION_COLOR_BG, /* default background color for bar */ + GUI_BAR_OPTION_COLOR_BG_INACTIVE, /* bg color for inactive window */ + /* (window bars only) */ GUI_BAR_OPTION_SEPARATOR, /* true if separator line displayed */ GUI_BAR_OPTION_ITEMS, /* bar items */ /* number of bar options */ @@ -140,6 +142,7 @@ extern struct t_gui_bar *gui_bar_new (const char *name, const char *color_fg, const char *color_delim, const char *color_bg, + const char *color_bg_inactive, const char *separator, const char *items); extern void gui_bar_use_temp_bars (); |