diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-11-02 10:58:38 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-11-02 10:58:38 +0100 |
commit | dd32052fec0edff570704d34afbeb9e9baa22168 (patch) | |
tree | ddd178a7d4912596e8122c8137f498a79eb35e34 /src/gui/curses | |
parent | cf81a6dfcdb386efc0bf2d054f7da6b6565f2734 (diff) | |
download | weechat-dd32052fec0edff570704d34afbeb9e9baa22168.zip |
core: add support of italic text (requires ncurses >= 5.9 patch 20130831)
Diffstat (limited to 'src/gui/curses')
-rw-r--r-- | src/gui/curses/gui-curses-bar-window.c | 6 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 2 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 35 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 6 |
4 files changed, 33 insertions, 16 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index 2836c15d3..f9f53fe6e 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -310,7 +310,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, case GUI_COLOR_RESET_CHAR: string++; gui_window_remove_color_style (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - A_BOLD | A_UNDERLINE | A_REVERSE); + 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])); @@ -640,13 +640,13 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]), CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); gui_window_remove_color_style (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - A_BOLD | A_UNDERLINE | A_REVERSE); + A_ALL_ATTR); wclrtobot (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar); } else { gui_window_remove_color_style (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - A_BOLD | A_UNDERLINE | A_REVERSE); + A_ALL_ATTR); } while (x < bar_window->width) { diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 95e9321fc..2b55d7bee 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -515,6 +515,8 @@ gui_color_build (int number, int foreground, int background) 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; diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 4669cf31a..d4c23157a 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -289,7 +289,7 @@ gui_window_reset_style (WINDOW *window, int weechat_color) gui_window_current_style_bg = -1; gui_window_current_color_attr = 0; - wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE); + wattroff (window, A_ALL_ATTR); wattron (window, COLOR_PAIR(gui_color_weechat_get_pair (weechat_color)) | gui_color[weechat_color]->attributes); } @@ -396,6 +396,10 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg) gui_window_set_color_style (window, A_REVERSE); else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) gui_window_remove_color_style (window, A_REVERSE); + if (fg & GUI_COLOR_EXTENDED_ITALIC_FLAG) + gui_window_set_color_style (window, A_ITALIC); + else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) + gui_window_remove_color_style (window, A_ITALIC); if (fg & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) gui_window_set_color_style (window, A_UNDERLINE); else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) @@ -407,15 +411,14 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg) else if ((fg & GUI_COLOR_EXTENDED_MASK) < GUI_CURSES_NUM_WEECHAT_COLORS) { if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) - { - gui_window_remove_color_style (window, - A_BOLD | A_REVERSE | A_UNDERLINE); - } + 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; @@ -487,6 +490,10 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg) gui_window_set_color_style (window, A_REVERSE); else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) gui_window_remove_color_style (window, A_REVERSE); + if (fg & GUI_COLOR_EXTENDED_ITALIC_FLAG) + gui_window_set_color_style (window, A_ITALIC); + else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) + gui_window_remove_color_style (window, A_ITALIC); if (fg & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) gui_window_set_color_style (window, A_UNDERLINE); else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)) @@ -496,15 +503,14 @@ 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)) - { - gui_window_remove_color_style (window, - A_BOLD | A_REVERSE | A_UNDERLINE); - } + 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; @@ -544,8 +550,7 @@ gui_window_set_custom_color_pair (WINDOW *window, int pair) { if ((pair >= 0) && (pair <= gui_color_num_pairs)) { - gui_window_remove_color_style (window, - A_BOLD | A_REVERSE | A_UNDERLINE); + gui_window_remove_color_style (window, A_ALL_ATTR); wattron (window, COLOR_PAIR(pair)); } } @@ -591,6 +596,8 @@ gui_window_emphasize (WINDOW *window, int x, int y, int count) attrs ^= A_BOLD; if (config_emphasized_attributes & GUI_COLOR_EXTENDED_REVERSE_FLAG) attrs ^= A_REVERSE; + if (config_emphasized_attributes & GUI_COLOR_EXTENDED_ITALIC_FLAG) + attrs ^= A_ITALIC; if (config_emphasized_attributes & GUI_COLOR_EXTENDED_UNDERLINE_FLAG) attrs ^= A_UNDERLINE; mvwchgat (window, y, x, count, attrs, pair, NULL); @@ -951,8 +958,9 @@ gui_window_string_apply_color_set_attr (unsigned char **string, WINDOW *window) gui_window_set_color_style (window, A_REVERSE); break; case GUI_COLOR_ATTR_ITALIC_CHAR: - /* not available in Curses GUI */ ptr_string++; + if (window) + gui_window_set_color_style (window, A_ITALIC); break; case GUI_COLOR_ATTR_UNDERLINE_CHAR: ptr_string++; @@ -991,8 +999,9 @@ gui_window_string_apply_color_remove_attr (unsigned char **string, WINDOW *windo gui_window_remove_color_style (window, A_REVERSE); break; case GUI_COLOR_ATTR_ITALIC_CHAR: - /* not available in Curses GUI */ ptr_string++; + if (window) + gui_window_remove_color_style (window, A_ITALIC); break; case GUI_COLOR_ATTR_UNDERLINE_CHAR: ptr_string++; diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 83a68b36d..2ec767410 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -40,6 +40,12 @@ struct t_gui_bar_window; #define GUI_CURSES_NUM_WEECHAT_COLORS 17 +#ifndef A_ITALIC /* A_ITALIC is defined in ncurses >= 5.9 patch 20130831 */ +#define A_ITALIC 0 +#endif + +#define A_ALL_ATTR A_BOLD | A_UNDERLINE | A_REVERSE | A_ITALIC + #define GUI_WINDOW_OBJECTS(window) \ ((struct t_gui_window_curses_objects *)(window->gui_objects)) #define GUI_BAR_WINDOW_OBJECTS(bar_window) \ |