Replace buffer local variable "no_highlight_nicks" by "hotlist_max_level_nicks"

v2.8-utf8proc
Sebastien Helleu 2010-11-29 10:17:09 +01:00
parent b6833392fe
commit 528dc258ca
8 changed files with 147 additions and 98 deletions

View File

@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.4-dev, 2010-11-25
v0.3.4-dev, 2010-11-29
Version 0.3.4 (under dev!)
@ -20,8 +20,8 @@ Version 0.3.4 (under dev!)
* core: fix default value of bar items options (bug #31422)
* core: fix bug with buffer name in "/bar scroll" command
* core: add new option weechat.look.hotlist_unique_numbers (task #10691)
* core: add property "no_highlight_nicks" in buffers to disable highlight
for some nicks in buffer
* core: add property "hotlist_max_level_nicks" in buffers to set max hotlist
level for some nicks in buffer
* core: add new options weechat.look.input_share and
weechat.look.input_share_overwrite (task #9228)
* core: add new option weechat.look.prefix_align_min (task #10650)

View File

@ -8427,7 +8427,7 @@ Arguments:
** 'text_search_input': input saved before text search
** 'highlight_words': list of words to highlight
** 'highlight_tags': list of tags to highlight
** 'no_highlight_nicks': list of nicks to NOT highlight
** 'hotlist_max_level_nicks': max hotlist level for some nicks
** 'localvar_xxx': get content of local variable "xxx" (replace "xxx" by the
name of variable to read)
@ -8584,16 +8584,18 @@ Arguments:
| highlight_tags | comma separated list of tags |
comma separated list of tags to highlight in this buffer
| no_highlight_nicks | comma separated list of nicks |
comma separated list of nicks to NOT highlight in this buffer, for example:
"joe,mike,robert"
| hotlist_max_level_nicks | comma separated list of "nick:level" |
comma separated list of nicks with max level for hotlist on this buffer
(level can be: -1: never in hotlist, 0: low, 1: message, 2: private,
3: highlight), for example: "joe:2,mike:-1,robert:-1" (joe will never produce
highlight on buffer, mike and robert will never change hotlist)
| no_highlight_nicks_add | comma separated list of nicks |
comma separated list of nicks to NOT highlight in this buffer, these words are
| hotlist_max_level_nicks_add | comma separated list of "nick:level" |
comma separated list of nicks with level for hotlist, these nicks are
added to existing nicks in buffer
| no_highlight_nicks_del | comma separated list of nicks |
comma separated list of nicks to remove from non highlighted nicks on buffer
| hotlist_max_level_nicks_del | comma separated list of nicks |
comma separated list of nicks to remove from hotlist max levels
| key_bind_xxx | any string |
bind a new key 'xxx', specific to this buffer, value is command to execute

View File

@ -8556,7 +8556,8 @@ Paramètres :
** 'text_search_input' : texte saisi sauvegardé avant la recherche de texte
** 'highlight_words' : liste des mots pour le highlight
** 'highlight_tags' : liste des étiquettes pour le highlight
** 'no_highlight_nicks' : liste des pseudos à NE PAS mettre en valeur (highlight)
** 'hotlist_max_level_nicks' : niveau maximum pour la hotlist pour certains
pseudos
** 'localvar_xxx' : contenu de la variable locale "xxx" (remplacer "xxx" par le
nom de la variable locale à lire)
@ -8720,17 +8721,19 @@ Paramètres :
| highlight_tags | liste d'étiquettes ("tags") séparées par des virgules |
liste d'étiquettes ("tags") à mettre en valeur pour ce tampon
| no_highlight_nicks | liste de pseudos séparés par des virgules |
liste de pseudos à NE PAS mettre en valeur dans ce tampon, par exemple :
"joe,mike,robert"
| hotlist_max_level_nicks | liste de "pseudo:niveau" séparés par des virgules |
liste de pseudos avec niveau max pour la hotlist sur ce tampon (le niveau peut
être : -1: jamais dans la hotlist, 0: faible, 1: message, 2: privé,
3: highlight), par exemple : "joe:2,mike:-1,robert:-1" (joe ne produira
jamais de highlight sur le tampon, mike et robert ne changeront jamais la
hotlist)
| no_highlight_nicks_add | liste de pseudos séparés par des virgules |
liste de pseudos à NE PAS mettre en valeur dans ce tampon, ces mots sont
ajoutés aux pseudos existants pour le tampon
| hotlist_max_level_nicks_add | liste de "pseudo:niveau" séparés par des virgules" |
liste de pseudos avec niveau pour la hotlist, ces pseudos sont ajoutés aux
pseudos existant dans le tampon
| no_highlight_nicks_del | liste de pseudos séparés par des virgules |
liste de pseudos à supprimer de la liste des pseudos à ne pas mettre en
valeur dans ce tampon
| hotlist_max_level_nicks_del | liste de pseudos séparés par des virgules |
liste de pseudos à supprimer des niveaux max de hotlist
| key_bind_xxx | toute chaîne |
associe la nouvelle touche 'xxx', spécifique à ce tampon, la valeur est la

View File

@ -8518,7 +8518,8 @@ Argomenti:
** 'text_search_input': input salvato prima della ricerca nel testo
** 'highlight_words': elenco di parole da evidenziare
** 'highlight_tags': elenco di tag da evidenziare
** 'no_highlight_nicks': lista di nick da NON evidenziare
// TRANSLATION MISSING
** 'hotlist_max_level_nicks': max hotlist level for some nicks
** 'localvar_xxx': ottiene il contenuto della variabile locale "xxx"
(sostituire "xxx" con il nome della variabile da leggere)
@ -8684,16 +8685,21 @@ Argomenti:
| highlight_tags | elenco separato da virgole di tag |
elenco separato da virgole di tag da evidenziare in questo buffer
| no_highlight_nicks | elenco separato da virgole di nick |
elenco separato da virgole di nick da NON evidenziare in questo buffer, ad esempio:
"joe,mike,robert"
// TRANSLATION MISSING
| hotlist_max_level_nicks | comma separated list of "nick:level" |
comma separated list of nicks with max level for hotlist on this buffer
(level can be: -1: never in hotlist, 0: low, 1: message, 2: private,
3: highlight), for example: "joe:2,mike:-1,robert:-1" (joe will never produce
highlight on buffer, mike and robert will never change hotlist)
| no_highlight_nicks_add | elenco separato da virgole di nick |
elenco separato da virgole di nick da NON evidenziare in questo buffer, queste
parole vengono aggiunte ai nick esistenti nel buffer
// TRANSLATION MISSING
| hotlist_max_level_nicks_add | comma separated list of "nick:level" |
comma separated list of nicks with level for hotlist, these nicks are
added to existing nicks in buffer
| no_highlight_nicks_del | elenco separato da virgole di nick |
elenco separato da virgole di nick da rimuovere dai nick non evidenziati nel buffer
// TRANSLATION MISSING
| hotlist_max_level_nicks_del | comma separated list of nicks |
comma separated list of nicks to remove from hotlist max levels
| key_bind_xxx | qualsiasi stringa |
assegna un nuovo tasto 'xxx', specifico per questo buffer, il valore è il

View File

@ -412,8 +412,8 @@ upgrade_weechat_read_cb (void *data,
infolist_string (infolist, "highlight_words"));
gui_buffer_set_highlight_tags (upgrade_current_buffer,
infolist_string (infolist, "highlight_tags"));
gui_buffer_set_no_highlight_nicks (upgrade_current_buffer,
infolist_string (infolist, "no_highlight_nicks"));
gui_buffer_set_hotlist_max_level_nicks (upgrade_current_buffer,
infolist_string (infolist, "hotlist_max_level_nicks"));
index = 0;
while (1)
{

View File

@ -84,7 +84,7 @@ char *gui_buffer_properties_get_integer[] =
};
char *gui_buffer_properties_get_string[] =
{ "plugin", "name", "short_name", "title", "input", "text_search_input",
"highlight_words", "highlight_tags", "no_highlight_nicks",
"highlight_words", "highlight_tags", "hotlist_max_level_nicks",
NULL
};
char *gui_buffer_properties_get_pointer[] =
@ -96,8 +96,9 @@ char *gui_buffer_properties_set[] =
"type", "notify", "title", "time_for_each_line", "nicklist",
"nicklist_case_sensitive", "nicklist_display_groups", "highlight_words",
"highlight_words_add", "highlight_words_del", "highlight_tags",
"no_highlight_nicks", "no_highlight_nicks_add", "no_highlight_nicks_del",
"input", "input_pos", "input_get_unknown_commands",
"hotlist_max_level_nicks", "hotlist_max_level_nicks_add",
"hotlist_max_level_nicks_del", "input", "input_pos",
"input_get_unknown_commands",
NULL
};
@ -459,11 +460,13 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->highlight_tags = NULL;
new_buffer->highlight_tags_count = 0;
new_buffer->highlight_tags_array = NULL;
new_buffer->no_highlight_nicks = hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
/* hotlist */
new_buffer->hotlist_max_level_nicks = hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_INTEGER,
NULL,
NULL);
/* keys */
new_buffer->keys = NULL;
@ -752,8 +755,8 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
return buffer->highlight_words;
else if (string_strcasecmp (property, "highlight_tags") == 0)
return buffer->highlight_tags;
else if (string_strcasecmp (property, "no_highlight_nicks") == 0)
return hashtable_get_string (buffer->no_highlight_nicks, "keys");
else if (string_strcasecmp (property, "hotlist_max_level_nicks") == 0)
return hashtable_get_string (buffer->hotlist_max_level_nicks, "keys_values");
else if (string_strncasecmp (property, "localvar_", 9) == 0)
{
ptr_value = (const char *)hashtable_get (buffer->local_variables,
@ -1103,26 +1106,41 @@ gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
}
/*
* gui_buffer_set_no_highlight_nicks: set no_highlight_nicks for a buffer
* gui_buffer_set_hotlist_max_level_nicks: set hotlist_max_level_nicks for a
* buffer
*/
void
gui_buffer_set_no_highlight_nicks (struct t_gui_buffer *buffer,
const char *new_no_highlight_nicks)
gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *new_hotlist_max_level_nicks)
{
char **nicks;
int nicks_count, i;
char **nicks, *pos, *error;
int nicks_count, value, i;
long number;
hashtable_remove_all (buffer->no_highlight_nicks);
hashtable_remove_all (buffer->hotlist_max_level_nicks);
if (new_no_highlight_nicks && new_no_highlight_nicks[0])
if (new_hotlist_max_level_nicks && new_hotlist_max_level_nicks[0])
{
nicks = string_split (new_no_highlight_nicks, ",", 0, 0, &nicks_count);
nicks = string_split (new_hotlist_max_level_nicks, ",", 0, 0,
&nicks_count);
if (nicks)
{
for (i = 0; i < nicks_count; i++)
{
hashtable_set (buffer->no_highlight_nicks, nicks[i], NULL);
value = -1;
pos = strchr (nicks[i], ':');
if (pos)
{
pos[0] = '\0';
pos++;
error = NULL;
number = strtol (pos, &error, 10);
if (error && !error[0])
value = (int)number;
}
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i],
&value);
}
string_free_split (nicks);
}
@ -1130,54 +1148,69 @@ gui_buffer_set_no_highlight_nicks (struct t_gui_buffer *buffer,
}
/*
* gui_buffer_add_no_highlight_nicks: add nicks to no_highlight_nicks for a
* buffer
* gui_buffer_add_hotlist_max_level_nicks: add nicks to hotlist_max_level_nicks
* for a buffer
*/
void
gui_buffer_add_no_highlight_nicks (struct t_gui_buffer *buffer,
const char *nicks_to_add)
gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *nicks_to_add)
{
char **nicks;
int nicks_count, i;
char **nicks, *pos, *error;
int nicks_count, value, i;
long number;
if (!nicks_to_add)
return;
nicks = string_split (nicks_to_add, ",", 0, 0,
&nicks_count);
nicks = string_split (nicks_to_add, ",", 0, 0, &nicks_count);
if (nicks)
{
for (i = 0; i < nicks_count; i++)
{
hashtable_set (buffer->no_highlight_nicks, nicks[i], NULL);
value = -1;
pos = strchr (nicks[i], ':');
if (pos)
{
pos[0] = '\0';
pos++;
error = NULL;
number = strtol (pos, &error, 10);
if (error && !error[0])
value = (int)number;
}
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i],
&value);
}
string_free_split (nicks);
}
}
/*
* gui_buffer_remove_no_highlight_nicks: remove nicks from no_highlight_nicks
* in a buffer
* gui_buffer_remove_hotlist_max_level_nicks: remove nicks from
* hotlist_max_level_nicks in a
* buffer
*/
void
gui_buffer_remove_no_highlight_nicks (struct t_gui_buffer *buffer,
const char *nicks_to_remove)
gui_buffer_remove_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *nicks_to_remove)
{
char **nicks;
char **nicks, *pos;
int nicks_count, i;
if (!nicks_to_remove)
return;
nicks = string_split (nicks_to_remove, ",", 0, 0,
&nicks_count);
nicks = string_split (nicks_to_remove, ",", 0, 0, &nicks_count);
if (nicks)
{
for (i = 0; i < nicks_count; i++)
{
hashtable_remove (buffer->no_highlight_nicks, nicks[i]);
pos = strchr (nicks[i], ':');
if (pos)
pos[0] = '\0';
hashtable_remove (buffer->hotlist_max_level_nicks, nicks[i]);
}
string_free_split (nicks);
}
@ -1356,17 +1389,17 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
{
gui_buffer_set_highlight_tags (buffer, value);
}
else if (string_strcasecmp (property, "no_highlight_nicks") == 0)
else if (string_strcasecmp (property, "hotlist_max_level_nicks") == 0)
{
gui_buffer_set_no_highlight_nicks (buffer, value);
gui_buffer_set_hotlist_max_level_nicks (buffer, value);
}
else if (string_strcasecmp (property, "no_highlight_nicks_add") == 0)
else if (string_strcasecmp (property, "hotlist_max_level_nicks_add") == 0)
{
gui_buffer_add_no_highlight_nicks (buffer, value);
gui_buffer_add_hotlist_max_level_nicks (buffer, value);
}
else if (string_strcasecmp (property, "no_highlight_nicks_del") == 0)
else if (string_strcasecmp (property, "hotlist_max_level_nicks_del") == 0)
{
gui_buffer_remove_no_highlight_nicks (buffer, value);
gui_buffer_remove_hotlist_max_level_nicks (buffer, value);
}
else if (string_strncasecmp (property, "key_bind_", 9) == 0)
{
@ -1944,8 +1977,8 @@ gui_buffer_close (struct t_gui_buffer *buffer)
free (buffer->highlight_tags);
if (buffer->highlight_tags_array)
string_free_split (buffer->highlight_tags_array);
if (buffer->no_highlight_nicks)
hashtable_free (buffer->no_highlight_nicks);
if (buffer->hotlist_max_level_nicks)
hashtable_free (buffer->hotlist_max_level_nicks);
gui_keyboard_free_all (&buffer->keys, &buffer->last_key,
&buffer->keys_count);
gui_buffer_local_var_remove_all (buffer);
@ -2848,7 +2881,7 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_string (ptr_item, "highlight_tags", buffer->highlight_tags))
return 0;
if (!infolist_new_var_string (ptr_item, "no_highlight_nicks", hashtable_get_string (buffer->no_highlight_nicks, "keys")))
if (!infolist_new_var_string (ptr_item, "hotlist_max_level_nicks", hashtable_get_string (buffer->hotlist_max_level_nicks, "keys_values")))
return 0;
i = 0;
for (ptr_key = buffer->keys; ptr_key; ptr_key = ptr_key->next_key)
@ -3030,10 +3063,10 @@ gui_buffer_print_log ()
log_printf (" prev_buffer. . . . . . : 0x%lx", ptr_buffer->prev_buffer);
log_printf (" next_buffer. . . . . . : 0x%lx", ptr_buffer->next_buffer);
if (ptr_buffer->no_highlight_nicks)
if (ptr_buffer->hotlist_max_level_nicks)
{
hashtable_print_log (ptr_buffer->no_highlight_nicks,
"no_highlight_nicks");
hashtable_print_log (ptr_buffer->hotlist_max_level_nicks,
"hotlist_max_level_nicks");
}
if (ptr_buffer->keys)

View File

@ -162,7 +162,10 @@ struct t_gui_buffer
int highlight_tags_count; /* number of tags to highlight */
/* (if 0, any tag is highlighted) */
char **highlight_tags_array; /* tags to highlight */
struct t_hashtable *no_highlight_nicks; /* nicks to NOT highlight */
/* hotlist settings for buffer */
struct t_hashtable *hotlist_max_level_nicks; /* max hotlist level for */
/* some nicks */
/* keys associated to buffer */
struct t_gui_key *keys; /* keys specific to buffer */
@ -232,8 +235,8 @@ extern void gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
const char *new_highlight_words);
extern void gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
const char *new_highlight_tags);
extern void gui_buffer_set_no_highlight_nicks (struct t_gui_buffer *buffer,
const char *new_no_highlight_nicks);
extern void gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *new_hotlist_max_level_nicks);
extern void gui_buffer_set_unread (struct t_gui_buffer *buffer);
extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value);

View File

@ -406,7 +406,6 @@ gui_line_has_highlight (struct t_gui_line *line)
{
int rc, i;
char *msg_no_color, *highlight_words;
const char *nick;
/*
* highlights are disabled on this buffer? (special value "-" means that
@ -434,17 +433,6 @@ gui_line_has_highlight (struct t_gui_line *line)
line->data->buffer->highlight_tags_array))
return 0;
}
/*
* if a nick is defined in tags ("nick_xxx"), then check if highlight is
* disabled for this nick (using hashtable buffer->no_highlight_nicks)
*/
nick = gui_line_get_nick_tag (line);
if (nick)
{
if (hashtable_has_key (line->data->buffer->no_highlight_nicks, nick))
return 0;
}
/* remove color codes from line message */
msg_no_color = gui_color_decode (line->data->message, NULL);
@ -762,7 +750,8 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
struct t_gui_line_data *new_line_data;
struct t_gui_window *ptr_win;
char *message_for_signal;
int notify_level;
const char *nick;
int notify_level, *max_notify_level;
new_line = malloc (sizeof (*new_line));
if (!new_line)
@ -803,11 +792,23 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
new_line->data->prefix_length = (prefix) ?
gui_chat_strlen_screen (prefix) : 0;
new_line->data->message = (message) ? strdup (message) : strdup ("");
new_line->data->highlight = gui_line_has_highlight (new_line);
/* get notify level and max notify level for nick in buffer */
notify_level = gui_line_get_notify_level (new_line);
nick = gui_line_get_nick_tag (new_line);
max_notify_level = NULL;
if (nick)
max_notify_level = hashtable_get (buffer->hotlist_max_level_nicks, nick);
if (max_notify_level
&& (*max_notify_level < notify_level))
notify_level = *max_notify_level;
if (notify_level == GUI_HOTLIST_HIGHLIGHT)
new_line->data->highlight = 1;
else if (max_notify_level && (*max_notify_level < GUI_HOTLIST_HIGHLIGHT))
new_line->data->highlight = 0;
else
new_line->data->highlight = gui_line_has_highlight (new_line);
/* add line to lines list */
gui_line_add_to_list (buffer->own_lines, new_line);
@ -844,7 +845,8 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
free (message_for_signal);
}
}
gui_hotlist_add (buffer, notify_level, NULL, 1);
if (notify_level >= GUI_HOTLIST_MIN)
gui_hotlist_add (buffer, notify_level, NULL, 1);
}
}
else