mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 01:33:12 +02:00
core: add support of italic text (requires ncurses >= 5.9 patch 20130831)
This commit is contained in:
@@ -2400,7 +2400,8 @@ COMMAND_CALLBACK(help)
|
||||
"an alias; attributes are allowed before "
|
||||
"color (for text color only, not "
|
||||
"background): \"*\" for bold, \"!\" for "
|
||||
"reverse, \"_\" for underline"));
|
||||
"reverse, \"/\" for italic, \"_\" for "
|
||||
"underline"));
|
||||
if (ptr_option->default_value)
|
||||
{
|
||||
gui_chat_printf (NULL, " %s: %s",
|
||||
|
||||
@@ -2131,8 +2131,9 @@ config_weechat_init_options ()
|
||||
weechat_config_file, ptr_section,
|
||||
"emphasized_attributes", "string",
|
||||
N_("attributes for emphasized text: one or more attribute chars ("
|
||||
"\"*\" for bold, \"!\" for reverse, \"_\" for underline); if the "
|
||||
"string is empty, the colors weechat.color.emphasized* are used"),
|
||||
"\"*\" for bold, \"!\" for reverse, \"/\" for italic, \"_\" for "
|
||||
"underline); if the string is empty, the colors "
|
||||
"weechat.color.emphasized* are used"),
|
||||
NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_emphasized_attributes, NULL, NULL, NULL);
|
||||
config_look_highlight = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -2727,7 +2727,7 @@ irc_config_init ()
|
||||
"colors_send", "boolean",
|
||||
N_("allow user to send colors with special codes (ctrl-c + a code and "
|
||||
"optional color: b=bold, cxx=color, cxx,yy=color+background, "
|
||||
"u=underline, r=reverse)"),
|
||||
"i=italic, o=disable color/attributes, r=reverse, u=underline)"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_network_lag_check = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
|
||||
Reference in New Issue
Block a user