mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
/SET activity_levels, hilight_levels, noact_channels ->
activity_msg_levels, activity_hilight_levels, activity_hide_targets. Added /SET hilight_levels to specify the default level for /HILIGHTs git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1109 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
8609a08f13
commit
8cb5ebc0a3
@ -33,11 +33,9 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
#define DEFAULT_HILIGHT_LEVEL \
|
||||
(MSGLEVEL_PUBLIC | MSGLEVEL_MSGS | MSGLEVEL_DCCMSGS)
|
||||
|
||||
static HILIGHT_REC *next_hilight;
|
||||
static int hilight_stop_next;
|
||||
static int default_hilight_level;
|
||||
GSList *hilights;
|
||||
|
||||
static void hilight_add_config(HILIGHT_REC *rec)
|
||||
@ -194,7 +192,7 @@ HILIGHT_REC *hilight_match(const char *channel, const char *nickmask,
|
||||
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
||||
HILIGHT_REC *rec = tmp->data;
|
||||
|
||||
if ((level & (rec->level > 0 ? rec->level : DEFAULT_HILIGHT_LEVEL)) == 0)
|
||||
if ((level & (rec->level > 0 ? rec->level : default_hilight_level)) == 0)
|
||||
continue;
|
||||
if (!rec->nick && nickmask != NULL)
|
||||
continue;
|
||||
@ -450,7 +448,7 @@ static void cmd_hilight(const char *data)
|
||||
level2bits(replace_chars(levelarg, ',', ' '));
|
||||
rec->priority = priorityarg == NULL ? 0 : atoi(priorityarg);
|
||||
rec->nick = settings_get_bool("hilight_only_nick") &&
|
||||
(rec->level == 0 || (rec->level & DEFAULT_HILIGHT_LEVEL) == rec->level) ?
|
||||
(rec->level == 0 || (rec->level & default_hilight_level) == rec->level) ?
|
||||
g_hash_table_lookup(optlist, "nonick") == NULL :
|
||||
g_hash_table_lookup(optlist, "nick") != NULL;
|
||||
rec->nickmask = g_hash_table_lookup(optlist, "mask") != NULL;
|
||||
@ -491,18 +489,25 @@ static void cmd_dehilight(const char *data)
|
||||
}
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
default_hilight_level = level2bits(settings_get_str("hilight_levels"));
|
||||
}
|
||||
|
||||
void hilight_text_init(void)
|
||||
{
|
||||
next_hilight = NULL;
|
||||
hilight_stop_next = FALSE;
|
||||
|
||||
read_hilight_config();
|
||||
settings_add_str("misc", "hilight_color", "8");
|
||||
settings_add_bool("misc", "hilight_only_nick", TRUE);
|
||||
settings_add_str("lookandfeel", "hilight_color", "8");
|
||||
settings_add_bool("lookandfeel", "hilight_only_nick", TRUE);
|
||||
settings_add_str("lookandfeel", "hilight_levels", "PUBLIC MSGS DCCMSGS");
|
||||
|
||||
signal_add_first("print text stripped", (SIGNAL_FUNC) sig_print_text_stripped);
|
||||
signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
|
||||
command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight);
|
||||
command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight);
|
||||
@ -516,6 +521,7 @@ void hilight_text_deinit(void)
|
||||
signal_remove("print text stripped", (SIGNAL_FUNC) sig_print_text_stripped);
|
||||
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
|
||||
command_unbind("hilight", (SIGNAL_FUNC) cmd_hilight);
|
||||
command_unbind("dehilight", (SIGNAL_FUNC) cmd_dehilight);
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include "hilight-text.h"
|
||||
#include "formats.h"
|
||||
|
||||
static char **noact_channels;
|
||||
static int hilight_level, activity_level;
|
||||
static char **hide_targets;
|
||||
static int hilight_levels, msg_levels;
|
||||
|
||||
static void window_activity(WINDOW_REC *window,
|
||||
int data_level, int hilight_color)
|
||||
@ -69,8 +69,7 @@ static void window_item_activity(WI_ITEM_REC *item,
|
||||
|
||||
#define hide_target_activity(data_level, target) \
|
||||
((data_level) < DATA_LEVEL_HILIGHT && (target) != NULL && \
|
||||
(noact_channels) != NULL && \
|
||||
strarray_find((noact_channels), target) != -1)
|
||||
hide_targets != NULL && strarray_find(hide_targets, target) != -1)
|
||||
|
||||
static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg)
|
||||
{
|
||||
@ -81,9 +80,9 @@ static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg)
|
||||
(dest->level & (MSGLEVEL_NEVER|MSGLEVEL_NO_ACT)))
|
||||
return;
|
||||
|
||||
data_level = (dest->level & hilight_level) ?
|
||||
data_level = (dest->level & hilight_levels) ?
|
||||
DATA_LEVEL_HILIGHT+dest->hilight_priority :
|
||||
((dest->level & activity_level) ?
|
||||
((dest->level & msg_levels) ?
|
||||
DATA_LEVEL_MSG : DATA_LEVEL_TEXT);
|
||||
|
||||
if (hide_target_activity(data_level, dest->target))
|
||||
@ -114,25 +113,25 @@ static void sig_dehilight_window(WINDOW_REC *window)
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
const char *channels;
|
||||
const char *targets;
|
||||
|
||||
if (noact_channels != NULL)
|
||||
g_strfreev(noact_channels);
|
||||
if (hide_targets != NULL)
|
||||
g_strfreev(hide_targets);
|
||||
|
||||
channels = settings_get_str("noact_channels");
|
||||
noact_channels = *channels == '\0' ? NULL :
|
||||
g_strsplit(channels, " ", -1);
|
||||
targets = settings_get_str("activity_hide_targets");
|
||||
hide_targets = *targets == '\0' ? NULL :
|
||||
g_strsplit(targets, " ", -1);
|
||||
|
||||
activity_level = level2bits(settings_get_str("activity_levels"));
|
||||
hilight_level = MSGLEVEL_HILIGHT |
|
||||
level2bits(settings_get_str("hilight_levels"));
|
||||
msg_levels = level2bits(settings_get_str("activity_msg_levels"));
|
||||
hilight_levels = MSGLEVEL_HILIGHT |
|
||||
level2bits(settings_get_str("activity_hilight_levels"));
|
||||
}
|
||||
|
||||
void window_activity_init(void)
|
||||
{
|
||||
settings_add_str("lookandfeel", "noact_channels", "");
|
||||
settings_add_str("lookandfeel", "activity_levels", "PUBLIC");
|
||||
settings_add_str("lookandfeel", "hilight_levels", "MSGS DCCMSGS");
|
||||
settings_add_str("lookandfeel", "activity_hide_targets", "");
|
||||
settings_add_str("lookandfeel", "activity_msg_levels", "PUBLIC");
|
||||
settings_add_str("lookandfeel", "activity_hilight_levels", "MSGS DCCMSGS");
|
||||
|
||||
read_settings();
|
||||
signal_add("print text", (SIGNAL_FUNC) sig_hilight_text);
|
||||
@ -143,8 +142,8 @@ void window_activity_init(void)
|
||||
|
||||
void window_activity_deinit(void)
|
||||
{
|
||||
if (noact_channels != NULL)
|
||||
g_strfreev(noact_channels);
|
||||
if (hide_targets != NULL)
|
||||
g_strfreev(hide_targets);
|
||||
|
||||
signal_remove("print text", (SIGNAL_FUNC) sig_hilight_text);
|
||||
signal_remove("window changed", (SIGNAL_FUNC) sig_dehilight_window);
|
||||
|
Loading…
Reference in New Issue
Block a user