diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 32 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 33 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 1 |
3 files changed, 36 insertions, 30 deletions
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 2b55d7bee..de8d65851 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -134,6 +134,29 @@ gui_color_search (const char *color_name) } /* + * Get Curses attributes corresponding to extended attributes flags in a color. + */ + +int +gui_color_get_extended_attrs (int color) +{ + int attributes; + + attributes = 0; + + if (color & GUI_COLOR_EXTENDED_BOLD_FLAG) + attributes |= A_BOLD; + if (color & GUI_COLOR_EXTENDED_REVERSE_FLAG) + attributes |= A_REVERSE; + if (color & GUI_COLOR_EXTENDED_ITALIC_FLAG) + attributes |= A_ITALIC; + if (color & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) + attributes |= A_UNDERLINE; + + return attributes; +} + +/* * Assigns a WeeChat color (read from configuration). * * Returns: @@ -511,14 +534,7 @@ gui_color_build (int number, int foreground, int background) gui_color[number]->foreground = gui_weechat_colors[foreground & GUI_COLOR_EXTENDED_MASK].foreground; gui_color[number]->attributes = gui_weechat_colors[foreground & GUI_COLOR_EXTENDED_MASK].attributes; } - if (foreground & GUI_COLOR_EXTENDED_BOLD_FLAG) - gui_color[number]->attributes |= A_BOLD; - if (foreground & GUI_COLOR_EXTENDED_REVERSE_FLAG) - gui_color[number]->attributes |= A_REVERSE; - if (foreground & GUI_COLOR_EXTENDED_ITALIC_FLAG) - gui_color[number]->attributes |= A_ITALIC; - if (foreground & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) - gui_color[number]->attributes |= A_UNDERLINE; + gui_color[number]->attributes |= gui_color_get_extended_attrs (foreground); /* set background */ if (background & GUI_COLOR_EXTENDED_FLAG) diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 0406a905f..2d13cf712 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -176,7 +176,8 @@ gui_window_clear_weechat (WINDOW *window, int weechat_color) if (!gui_init_ok) return; - wbkgdset (window, ' ' | COLOR_PAIR (gui_color_weechat_get_pair (weechat_color))); + wbkgdset (window, ' ' | COLOR_PAIR (gui_color_weechat_get_pair (weechat_color)) | + gui_color[weechat_color]->attributes); werase (window); wmove (window, 0, 0); } @@ -188,9 +189,13 @@ gui_window_clear_weechat (WINDOW *window, int weechat_color) void gui_window_clear (WINDOW *window, int fg, int bg) { + int attrs; + if (!gui_init_ok) return; + attrs = gui_color_get_extended_attrs (fg); + if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG)) fg &= GUI_COLOR_EXTENDED_MASK; else @@ -201,7 +206,7 @@ gui_window_clear (WINDOW *window, int fg, int bg) else bg = gui_weechat_colors[bg & GUI_COLOR_EXTENDED_MASK].background; - wbkgdset (window, ' ' | COLOR_PAIR (gui_color_get_pair (fg, bg))); + wbkgdset (window, ' ' | COLOR_PAIR (gui_color_get_pair (fg, bg)) | attrs); werase (window); wmove (window, 0, 0); } @@ -413,16 +418,8 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg) { if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) gui_window_remove_color_style (window, A_ALL_ATTR); - attributes = 0; - if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG) - attributes |= A_BOLD; - if (fg & GUI_COLOR_EXTENDED_REVERSE_FLAG) - attributes |= A_REVERSE; - if (fg & GUI_COLOR_EXTENDED_ITALIC_FLAG) - attributes |= A_ITALIC; - if (fg & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) - attributes |= A_UNDERLINE; - attributes |= gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes; + attributes = gui_color_get_extended_attrs (fg) | + gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes; gui_window_set_color_style (window, attributes); fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground; @@ -505,16 +502,8 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg) { if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) gui_window_remove_color_style (window, A_ALL_ATTR); - attributes = 0; - if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG) - attributes |= A_BOLD; - if (fg & GUI_COLOR_EXTENDED_REVERSE_FLAG) - attributes |= A_REVERSE; - if (fg & GUI_COLOR_EXTENDED_ITALIC_FLAG) - attributes |= A_ITALIC; - if (fg & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) - attributes |= A_UNDERLINE; - attributes |= gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes; + attributes = gui_color_get_extended_attrs (fg) | + gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes; gui_window_set_color_style (window, attributes); fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground; diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 2ec767410..74345ae5d 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -85,6 +85,7 @@ extern int gui_color_buffer_refresh_needed; extern int gui_window_current_emphasis; /* color functions */ +extern int gui_color_get_extended_attrs (int color); extern int gui_color_get_pair (int fg, int bg); extern int gui_color_weechat_get_pair (int weechat_color); extern void gui_color_pre_init (); |