From 0cfbae151202a30f009ba164b262db704a9309d5 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 30 Mar 2014 08:34:32 +0200 Subject: [PATCH] core: fix reset of attributes in bars when "resetcolor" is used (closes #41) --- ChangeLog.asciidoc | 1 + src/gui/curses/gui-curses-bar-window.c | 18 ++++++++++++------ src/gui/curses/gui-curses-window.c | 7 ++++--- src/gui/curses/gui-curses.h | 3 ++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 703e6e91b..b1203d2a5 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -15,6 +15,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] == Version 0.4.4 (under dev) +* core: fix reset of attributes in bars when "resetcolor" is used (closes #41) * core: fix alignment of lines in merged buffers when options weechat.look.prefix_align and weechat.look.prefix_buffer_align are set to "none" (closes #43) diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index e4fa0583d..86d1a4f19 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -169,7 +169,8 @@ gui_bar_window_print_string (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[GUI_BAR_OPTION_COLOR_BG]), + 1); } x_with_hidden = *x; @@ -289,7 +290,8 @@ 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[GUI_BAR_OPTION_COLOR_BG]), + 0); break; default: gui_window_string_apply_color_weechat ((unsigned char **)&string, @@ -313,7 +315,8 @@ 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[GUI_BAR_OPTION_COLOR_BG]), + 1); break; default: next_char = utf8_next_char (string); @@ -640,7 +643,8 @@ 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[GUI_BAR_OPTION_COLOR_BG]), + 1); gui_window_remove_color_style (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_ALL_ATTR); wclrtobot (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar); @@ -684,7 +688,8 @@ 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[GUI_BAR_OPTION_COLOR_BG]), + 1); mvwaddstr (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, ptr_string); } @@ -703,7 +708,8 @@ 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[GUI_BAR_OPTION_COLOR_BG]), + 1); mvwaddstr (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, ptr_string); } diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index eb9929b32..2ef4cf994 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -475,7 +475,8 @@ gui_window_set_custom_color_bg (WINDOW *window, int bg) */ void -gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg) +gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg, + int reset_attributes) { int attributes; @@ -503,7 +504,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg) } else if ((fg & GUI_COLOR_EXTENDED_MASK) < GUI_CURSES_NUM_WEECHAT_COLORS) { - if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) + if (reset_attributes && !(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) gui_window_remove_color_style (window, A_ALL_ATTR); attributes = gui_color_get_extended_attrs (fg) | gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes; @@ -844,7 +845,7 @@ gui_window_string_apply_color_fg_bg (unsigned char **string, WINDOW *window) } if (window && (fg >= 0) && (bg >= 0)) { - gui_window_set_custom_color_fg_bg (window, fg, bg); + gui_window_set_custom_color_fg_bg (window, fg, bg, 1); } *string = ptr_string; diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index e2047d53c..f8c0188ff 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -108,7 +108,8 @@ extern void gui_window_set_color_style (WINDOW *window, int style); extern void gui_window_remove_color_style (WINDOW *window, int style); extern void gui_window_set_color (WINDOW *window, int fg, int bg); extern void gui_window_set_weechat_color (WINDOW *window, int num_color); -extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg); +extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg, + int reset_attributes); extern void gui_window_set_custom_color_pair (WINDOW *window, int pair); extern void gui_window_set_custom_color_fg (WINDOW *window, int fg); extern void gui_window_set_custom_color_bg (WINDOW *window, int bg);