1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -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:
Timo Sirainen 2001-01-13 14:04:11 +00:00 committed by cras
parent 8609a08f13
commit 8cb5ebc0a3
2 changed files with 32 additions and 27 deletions

View File

@ -33,11 +33,9 @@
#include "printtext.h" #include "printtext.h"
#include "formats.h" #include "formats.h"
#define DEFAULT_HILIGHT_LEVEL \
(MSGLEVEL_PUBLIC | MSGLEVEL_MSGS | MSGLEVEL_DCCMSGS)
static HILIGHT_REC *next_hilight; static HILIGHT_REC *next_hilight;
static int hilight_stop_next; static int hilight_stop_next;
static int default_hilight_level;
GSList *hilights; GSList *hilights;
static void hilight_add_config(HILIGHT_REC *rec) 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) { for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
HILIGHT_REC *rec = tmp->data; 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; continue;
if (!rec->nick && nickmask != NULL) if (!rec->nick && nickmask != NULL)
continue; continue;
@ -450,7 +448,7 @@ static void cmd_hilight(const char *data)
level2bits(replace_chars(levelarg, ',', ' ')); level2bits(replace_chars(levelarg, ',', ' '));
rec->priority = priorityarg == NULL ? 0 : atoi(priorityarg); rec->priority = priorityarg == NULL ? 0 : atoi(priorityarg);
rec->nick = settings_get_bool("hilight_only_nick") && 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, "nonick") == NULL :
g_hash_table_lookup(optlist, "nick") != NULL; g_hash_table_lookup(optlist, "nick") != NULL;
rec->nickmask = g_hash_table_lookup(optlist, "mask") != 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) void hilight_text_init(void)
{ {
next_hilight = NULL; next_hilight = NULL;
hilight_stop_next = FALSE; hilight_stop_next = FALSE;
read_hilight_config(); read_hilight_config();
settings_add_str("misc", "hilight_color", "8"); settings_add_str("lookandfeel", "hilight_color", "8");
settings_add_bool("misc", "hilight_only_nick", TRUE); 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 stripped", (SIGNAL_FUNC) sig_print_text_stripped);
signal_add_first("print text", (SIGNAL_FUNC) sig_print_text); signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config); 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("hilight", NULL, (SIGNAL_FUNC) cmd_hilight);
command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight); 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 stripped", (SIGNAL_FUNC) sig_print_text_stripped);
signal_remove("print text", (SIGNAL_FUNC) sig_print_text); signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config); 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("hilight", (SIGNAL_FUNC) cmd_hilight);
command_unbind("dehilight", (SIGNAL_FUNC) cmd_dehilight); command_unbind("dehilight", (SIGNAL_FUNC) cmd_dehilight);

View File

@ -32,8 +32,8 @@
#include "hilight-text.h" #include "hilight-text.h"
#include "formats.h" #include "formats.h"
static char **noact_channels; static char **hide_targets;
static int hilight_level, activity_level; static int hilight_levels, msg_levels;
static void window_activity(WINDOW_REC *window, static void window_activity(WINDOW_REC *window,
int data_level, int hilight_color) 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) \ #define hide_target_activity(data_level, target) \
((data_level) < DATA_LEVEL_HILIGHT && (target) != NULL && \ ((data_level) < DATA_LEVEL_HILIGHT && (target) != NULL && \
(noact_channels) != NULL && \ hide_targets != NULL && strarray_find(hide_targets, target) != -1)
strarray_find((noact_channels), target) != -1)
static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg) 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))) (dest->level & (MSGLEVEL_NEVER|MSGLEVEL_NO_ACT)))
return; return;
data_level = (dest->level & hilight_level) ? data_level = (dest->level & hilight_levels) ?
DATA_LEVEL_HILIGHT+dest->hilight_priority : DATA_LEVEL_HILIGHT+dest->hilight_priority :
((dest->level & activity_level) ? ((dest->level & msg_levels) ?
DATA_LEVEL_MSG : DATA_LEVEL_TEXT); DATA_LEVEL_MSG : DATA_LEVEL_TEXT);
if (hide_target_activity(data_level, dest->target)) 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) static void read_settings(void)
{ {
const char *channels; const char *targets;
if (noact_channels != NULL) if (hide_targets != NULL)
g_strfreev(noact_channels); g_strfreev(hide_targets);
channels = settings_get_str("noact_channels"); targets = settings_get_str("activity_hide_targets");
noact_channels = *channels == '\0' ? NULL : hide_targets = *targets == '\0' ? NULL :
g_strsplit(channels, " ", -1); g_strsplit(targets, " ", -1);
activity_level = level2bits(settings_get_str("activity_levels")); msg_levels = level2bits(settings_get_str("activity_msg_levels"));
hilight_level = MSGLEVEL_HILIGHT | hilight_levels = MSGLEVEL_HILIGHT |
level2bits(settings_get_str("hilight_levels")); level2bits(settings_get_str("activity_hilight_levels"));
} }
void window_activity_init(void) void window_activity_init(void)
{ {
settings_add_str("lookandfeel", "noact_channels", ""); settings_add_str("lookandfeel", "activity_hide_targets", "");
settings_add_str("lookandfeel", "activity_levels", "PUBLIC"); settings_add_str("lookandfeel", "activity_msg_levels", "PUBLIC");
settings_add_str("lookandfeel", "hilight_levels", "MSGS DCCMSGS"); settings_add_str("lookandfeel", "activity_hilight_levels", "MSGS DCCMSGS");
read_settings(); read_settings();
signal_add("print text", (SIGNAL_FUNC) sig_hilight_text); signal_add("print text", (SIGNAL_FUNC) sig_hilight_text);
@ -143,8 +142,8 @@ void window_activity_init(void)
void window_activity_deinit(void) void window_activity_deinit(void)
{ {
if (noact_channels != NULL) if (hide_targets != NULL)
g_strfreev(noact_channels); g_strfreev(hide_targets);
signal_remove("print text", (SIGNAL_FUNC) sig_hilight_text); signal_remove("print text", (SIGNAL_FUNC) sig_hilight_text);
signal_remove("window changed", (SIGNAL_FUNC) sig_dehilight_window); signal_remove("window changed", (SIGNAL_FUNC) sig_dehilight_window);