core: add color attribute "|" and value "resetcolor" for function weechat_color in plugin API (bug #34550)

v2.8-utf8proc
Sebastien Helleu 2011-10-15 13:54:53 +02:00
parent 0bbddad6a6
commit ac7c27949b
15 changed files with 190 additions and 50 deletions

View File

@ -1,12 +1,15 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.6-rc2, 2011-10-10
v0.3.6-rc2, 2011-10-15
Version 0.3.6 (under dev!)
--------------------------
* core: add color attribute "|" (keep attributes) and value "resetcolor" for
function weechat_color in plugin API (used by irc plugin to keep
bold/reverse/underlined in message when changing color) (bug #34550)
* core: fix compilation error (INSTALLPREFIX undeclared) on OS X and when
compiling with included gettext (bug #26690)
* core: display timeout for hook_process command only if debug for core is

View File

@ -940,9 +940,12 @@ Attribute
Er ist möglich einer Farbe ein Attribut hinzuzufügen. Dazu wird dem
Farbnamen oder der Farbnummer ein- oder mehrere Attribute vorangestellt.
* `*`: fett
* `!`: invertierte Darstellung
* `_`: unterstrichen
* `*` : fett
* `!` : invertierte Darstellung
* `_` : unterstrichen
// TRANSLATION MISSING
* `|` : keep attributes: do not reset bold/reverse/underlined when changing
color
Um zum Beispiel dem eigenen Nick die Farbe weiß und unterstrichen
zuzuordnen:

View File

@ -5878,7 +5878,7 @@ Arguments:
* 'color_name': name of color, one of:
** WeeChat option name (from weechat.color.xxx), for example 'chat_delimiters'
** color with optional background, for example 'yellow' or 'yellow,red'
** color with optional attributes/background (see below)
** attribute:
*** 'bold': set bold
*** '-bold': remove bold
@ -5892,6 +5892,26 @@ Arguments:
*** 'bar_fg': foreground color for bar
*** 'bar_delim': delimiters color for bar
*** 'bar_bg': background color for bar
** reset:
*** 'reset': reset color and attributes
*** 'resetcolor': reset color (keep attributes) (_new in version 0.3.6_)
Format of color is: attributes (optional) + color name + ",background"
(optional). Possible attributes are:
* `*` : bold text
* `!` : reverse video
* `_` : underlined text
* `|` : keep attributes: do not reset bold/reverse/underlined when changing
color (_new in version 0.3.6_)
Examples:
* `yellow` : yellow
* `_green` : underlined green
* `*214` : bold orange
* `yellow,red` : yellow on red
* `|cyan` : cyan (and keep any attribute which was set previously)
Return value:

View File

@ -932,9 +932,11 @@ Attributes
It is possible to use some attributes for colors. One or more attributes can be
added before color name or number:
* `*`: bold text
* `!`: reverse video
* `_`: underlined text
* `*` : bold text
* `!` : reverse video
* `_` : underlined text
* `|` : keep attributes: do not reset bold/reverse/underlined when changing
color
For example if you want self nick as white underlined, do:

View File

@ -5941,7 +5941,7 @@ Paramètres :
* 'color_name' : nom de la couleur, parmi :
** une option WeeChat (de weechat.color.xxx), par exemple 'chat_delimiters'
** une couleur avec un fond optionnel, par exemple 'yellow' ou 'yellow,red'
** une couleur avec des attributs/fond optionnels (voir ci-dessous)
** un attribut :
*** 'bold' : activer le gras
*** '-bold' : désactiver le gras
@ -5955,6 +5955,27 @@ Paramètres :
*** 'bar_fg' : couleur de texte pour la barre
*** 'bar_delim' : couleur des délimiteurs pour la barre
*** 'bar_bg' : couleur de fond pour la barre
** réinitialisation :
*** 'reset' : réinitialiser la couleur et les attributs
*** 'resetcolor' : réinitialiser la couleur (garder les attributs)
(_nouveau dans la version 0.3.6_)
Le format de la couleur est : attributs (optionnel) + nom de couleur + ",fond"
(optionnel). Les attributs possibles sont :
* `*` : texte gras
* `!` : mode vidéo inverse
* `_` : texte souligné
* `|` : garder les attributs : ne pas réinitialiser gras/inverse/souligné lors
du changement de couleur (_nouveau dans la version 0.3.6_)
Exemples :
* `yellow` : jaune
* `_green` : vert souligné
* `*214` : orange gras
* `yellow,red` : jaune sur rouge
* `|cyan` : cyan (et garder tout attribut définit précédemment)
Valeur de retour :

View File

@ -959,6 +959,8 @@ attributs peuvent être ajoutés avant le nom ou le numéro de la couleur :
* `*` : texte gras
* `!` : mode vidéo inverse
* `_` : texte souligné
* `|` : garder les attributs : ne pas réinitialiser gras/inverse/souligné lors
du changement de couleur
Par exemple si vous voulez votre pseudo en blanc souligné, faites :

View File

@ -5883,7 +5883,8 @@ Argomenti:
* 'color_name': nome del colore, uno di:
** nome opzione di WeeChat (da weechat.color.xxx), ad esempio 'chat_delimiters'
** colore con sfondo opzionale, ad esempio 'yellow' o 'yellow,red'
// TRANSLATION MISSING
** color with optional attributes/background (see below)
** attributo:
*** 'bold': imposta grassetto
*** '-bold': rimuove grassetto
@ -5897,6 +5898,29 @@ Argomenti:
*** 'bar_fg': colore di primo piano della barra
*** 'bar_delim': colore dei delimitatori della barra
*** 'bar_bg': colore di sfondo della barra
// TRANSLATION MISSING
** reset:
*** 'reset': reset color and attributes
*** 'resetcolor': reset color (keep attributes) (_new in version 0.3.6_)
// TRANSLATION MISSING
Format of color is: attributes (optional) + color name + ",background"
(optional). Possible attributes are:
* `*` : bold text
* `!` : reverse video
* `_` : underlined text
* `|` : keep attributes: do not reset bold/reverse/underlined when changing
color (_new in version 0.3.6_)
// TRANSLATION MISSING
Examples:
* `yellow` : yellow
* `_green` : underlined green
* `*214` : bold orange
* `yellow,red` : yellow on red
* `|cyan` : cyan (and keep any attribute which was set previously)
Valore restituito:

View File

@ -722,7 +722,7 @@ Esempio di eventi:
[TIP]
Quando si associa un tasto nel contesto "mouse", è possibile far corrispondere
più eventi usando '*' all'inizio o alla fine del nome, ad esempio
più eventi usando `*` all'inizio o alla fine del nome, ad esempio
`button1-gesture-*` corrisponderà ad ogni azione compiuta col tasto sinistro.
[TIP]
@ -948,9 +948,12 @@ Attributi
Esistono alcuni attributi per i colori. Uno o più attributi vanno aggiunti prima
del nome o del numero del colore:
* `*`: testo in grassetto
* `!`: video inverso
* `_`: testo sottolineato
* `*` : testo in grassetto
* `!` : video inverso
* `_` : testo sottolineato
// TRANSLATION MISSING
* `|` : keep attributes: do not reset bold/reverse/underlined when changing
color
Ad esempio se si vuole il proprio nick bianco e sottolineato:

View File

@ -283,6 +283,12 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
break;
}
break;
case GUI_COLOR_RESET_CHAR: /* reset color (keep attributes) */
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]));
break;
default:
gui_window_string_apply_color_weechat ((unsigned char **)&string,
GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);

View File

@ -107,25 +107,28 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
void
gui_chat_reset_style (struct t_gui_window *window, struct t_gui_line *line,
int reset_attributes,
int color_inactive_window, int color_inactive_buffer,
int color_default)
{
int color;
color = color_default;
if ((window != gui_current_window) &&
CONFIG_BOOLEAN(config_look_color_inactive_window))
{
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat,
color_inactive_window);
return;
color = color_inactive_window;
}
if (line && !(line->data->buffer->active)
&& CONFIG_BOOLEAN(config_look_color_inactive_buffer))
else if (line && !(line->data->buffer->active)
&& CONFIG_BOOLEAN(config_look_color_inactive_buffer))
{
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat,
color_inactive_buffer);
return;
color = color_inactive_buffer;
}
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat,
color_default);
if (reset_attributes)
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, color);
else
gui_window_reset_color (GUI_WINDOW_OBJECTS(window)->win_chat, color);
}
/*
@ -260,6 +263,24 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
break;
}
break;
case GUI_COLOR_RESET_CHAR: /* reset color (keep attributes) */
string++;
if (apply_style)
{
if (apply_style_inactive)
{
gui_chat_reset_style (window, line, 0,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
}
else
{
gui_window_reset_color (GUI_WINDOW_OBJECTS(window)->win_chat,
GUI_COLOR_CHAT);
}
}
break;
default:
gui_window_string_apply_color_weechat ((unsigned char **)&string,
(apply_style) ? GUI_WINDOW_OBJECTS(window)->win_chat : NULL);
@ -282,7 +303,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
{
if (apply_style_inactive)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -547,7 +568,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
{
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].line = line;
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -568,7 +589,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -601,7 +622,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
{
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -617,7 +638,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
(CONFIG_BOOLEAN(config_look_color_inactive_buffer)
&& CONFIG_BOOLEAN(config_look_color_inactive_prefix_buffer)
@ -673,7 +694,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
{
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -707,7 +728,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
{
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -753,7 +774,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
}
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
(CONFIG_BOOLEAN(config_look_color_inactive_buffer)
&& CONFIG_BOOLEAN(config_look_color_inactive_prefix)
@ -767,7 +788,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
{
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
(CONFIG_BOOLEAN(config_look_color_inactive_buffer)
&& CONFIG_BOOLEAN(config_look_color_inactive_prefix)
@ -813,7 +834,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
if (!simulate)
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -944,14 +965,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
{
if (CONFIG_BOOLEAN(config_look_color_inactive_message))
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
}
else
{
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT,
GUI_COLOR_CHAT,
GUI_COLOR_CHAT);
@ -1107,7 +1128,7 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
int y)
{
/* reset color & style for a new line */
gui_chat_reset_style (window, line,
gui_chat_reset_style (window, line, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
@ -1250,7 +1271,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
{
gui_window_coords_alloc (ptr_win);
gui_chat_reset_style (ptr_win, NULL,
gui_chat_reset_style (ptr_win, NULL, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);

View File

@ -247,6 +247,17 @@ gui_window_reset_style (WINDOW *window, int weechat_color)
gui_color[weechat_color]->attributes);
}
/*
* gui_window_reset_color: reset color with a weechat color for a window
*/
void
gui_window_reset_color (WINDOW *window, int weechat_color)
{
wattron (window, COLOR_PAIR(gui_color_weechat_get_pair (weechat_color)) |
gui_color[weechat_color]->attributes);
}
/*
* gui_window_set_color_style: set style for color
*/
@ -333,15 +344,15 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg)
{
if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG)
gui_window_set_color_style (window, A_BOLD);
else
else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
gui_window_remove_color_style (window, A_BOLD);
if (fg & GUI_COLOR_EXTENDED_REVERSE_FLAG)
gui_window_set_color_style (window, A_REVERSE);
else
else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
gui_window_remove_color_style (window, A_REVERSE);
if (fg & GUI_COLOR_EXTENDED_UNDERLINE_FLAG)
gui_window_set_color_style (window, A_UNDERLINE);
else
else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
gui_window_remove_color_style (window, A_UNDERLINE);
gui_window_set_color (window,
fg & GUI_COLOR_EXTENDED_MASK,
@ -349,8 +360,11 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg)
}
else if ((fg & GUI_COLOR_EXTENDED_MASK) < GUI_CURSES_NUM_WEECHAT_COLORS)
{
gui_window_remove_color_style (window,
A_BOLD | A_REVERSE | A_UNDERLINE);
if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
{
gui_window_remove_color_style (window,
A_BOLD | A_REVERSE | A_UNDERLINE);
}
attributes = 0;
if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG)
attributes |= A_BOLD;
@ -425,22 +439,25 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
{
if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG)
gui_window_set_color_style (window, A_BOLD);
else
else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
gui_window_remove_color_style (window, A_BOLD);
if (fg & GUI_COLOR_EXTENDED_REVERSE_FLAG)
gui_window_set_color_style (window, A_REVERSE);
else
else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
gui_window_remove_color_style (window, A_REVERSE);
if (fg & GUI_COLOR_EXTENDED_UNDERLINE_FLAG)
gui_window_set_color_style (window, A_UNDERLINE);
else
else if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
gui_window_remove_color_style (window, A_UNDERLINE);
fg &= GUI_COLOR_EXTENDED_MASK;
}
else if ((fg & GUI_COLOR_EXTENDED_MASK) < GUI_CURSES_NUM_WEECHAT_COLORS)
{
gui_window_remove_color_style (window,
A_BOLD | A_REVERSE | A_UNDERLINE);
if (!(fg & GUI_COLOR_EXTENDED_KEEPATTR_FLAG))
{
gui_window_remove_color_style (window,
A_BOLD | A_REVERSE | A_UNDERLINE);
}
attributes = 0;
if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG)
attributes |= A_BOLD;

View File

@ -88,6 +88,7 @@ extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer);
extern void gui_window_clear (WINDOW *window, int fg, int bg);
extern void gui_window_clrtoeol (WINDOW *window);
extern void gui_window_reset_style (WINDOW *window, int num_color);
extern void gui_window_reset_color (WINDOW *window, int num_color);
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);

View File

@ -104,6 +104,9 @@ gui_color_attr_get_flag (char c)
if (c == GUI_COLOR_EXTENDED_UNDERLINE_CHAR)
return GUI_COLOR_EXTENDED_UNDERLINE_FLAG;
if (c == GUI_COLOR_EXTENDED_KEEPATTR_CHAR)
return GUI_COLOR_EXTENDED_KEEPATTR_FLAG;
return 0;
}
@ -128,6 +131,8 @@ gui_color_attr_build_string (int color, char *str_attr)
str_attr[i++] = GUI_COLOR_EXTENDED_ITALIC_CHAR;
if (color & GUI_COLOR_EXTENDED_UNDERLINE_FLAG)
str_attr[i++] = GUI_COLOR_EXTENDED_UNDERLINE_CHAR;
if (color & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)
str_attr[i++] = GUI_COLOR_EXTENDED_KEEPATTR_CHAR;
str_attr[i] = '\0';
}
@ -159,6 +164,13 @@ gui_color_get_custom (const char *color_name)
"%c",
GUI_COLOR_RESET_CHAR);
}
else if (string_strcasecmp (color_name, "resetcolor") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
"%c%c",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_RESET_CHAR);
}
else if (string_strcasecmp (color_name, "bold") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
@ -521,6 +533,9 @@ gui_color_decode (const char *string, const char *replacement)
break;
}
break;
case GUI_COLOR_RESET_CHAR:
ptr_string++;
break;
default:
if (isdigit (ptr_string[0]) && isdigit (ptr_string[1]))
ptr_string += 2;

View File

@ -98,6 +98,7 @@ enum t_gui_color_enum
#define GUI_COLOR_EXTENDED_REVERSE_CHAR '!'
#define GUI_COLOR_EXTENDED_ITALIC_CHAR '/'
#define GUI_COLOR_EXTENDED_UNDERLINE_CHAR '_'
#define GUI_COLOR_EXTENDED_KEEPATTR_CHAR '|'
/* color codes specific to bars */
#define GUI_COLOR_BAR_CHAR 'b'
@ -115,6 +116,7 @@ enum t_gui_color_enum
#define GUI_COLOR_EXTENDED_REVERSE_FLAG 0x0400000
#define GUI_COLOR_EXTENDED_ITALIC_FLAG 0x0800000
#define GUI_COLOR_EXTENDED_UNDERLINE_FLAG 0x1000000
#define GUI_COLOR_EXTENDED_KEEPATTR_FLAG 0x2000000
#define GUI_COLOR_EXTENDED_MASK 0x00FFFFF
#define GUI_COLOR_EXTENDED_MAX 99999

View File

@ -176,14 +176,14 @@ irc_color_decode (const char *string, int keep_colors)
}
}
snprintf (str_color, sizeof (str_color),
"%s%s%s",
"|%s%s%s",
(fg >= 0) ? irc_color_to_weechat[fg] : "",
(bg >= 0) ? "," : "",
(bg >= 0) ? irc_color_to_weechat[bg] : "");
strcat ((char *)out, weechat_color(str_color));
}
else
strcat ((char *)out, weechat_color("reset"));
strcat ((char *)out, weechat_color("resetcolor"));
}
break;
default: