1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

hilight + keyboard fixes so it's possible for xirssi to modify them.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2816 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-05-19 06:50:50 +00:00 committed by cras
parent b9eda1adb6
commit dc0088f584
4 changed files with 42 additions and 22 deletions

View File

@ -112,12 +112,38 @@ static void hilights_destroy_all(void)
hilights = NULL; hilights = NULL;
} }
static void hilight_remove(HILIGHT_REC *rec) static void hilight_init_rec(HILIGHT_REC *rec)
{
#ifdef HAVE_REGEX_H
if (rec->regexp_compiled) regfree(&rec->preg);
rec->regexp_compiled = !rec->regexp ? FALSE :
regcomp(&rec->preg, rec->text, REG_EXTENDED|REG_ICASE) == 0;
#endif
}
void hilight_create(HILIGHT_REC *rec)
{
if (g_slist_find(hilights, rec) != NULL) {
hilights = g_slist_remove(hilights, rec);
hilight_remove_config(rec);
}
hilights = g_slist_append(hilights, rec);
hilight_add_config(rec);
hilight_init_rec(rec);
signal_emit("hilight created", 1, rec);
}
void hilight_remove(HILIGHT_REC *rec)
{ {
g_return_if_fail(rec != NULL); g_return_if_fail(rec != NULL);
hilight_remove_config(rec); hilight_remove_config(rec);
hilights = g_slist_remove(hilights, rec); hilights = g_slist_remove(hilights, rec);
signal_emit("hilight destroyed", 1, rec);
hilight_destroy(rec); hilight_destroy(rec);
} }
@ -435,11 +461,7 @@ static void read_hilight_config(void)
rec->fullword = config_node_get_bool(node, "fullword", FALSE); rec->fullword = config_node_get_bool(node, "fullword", FALSE);
rec->regexp = config_node_get_bool(node, "regexp", FALSE); rec->regexp = config_node_get_bool(node, "regexp", FALSE);
#ifdef HAVE_REGEX_H hilight_init_rec(rec);
rec->regexp_compiled = !rec->regexp ? FALSE :
regcomp(&rec->preg, rec->text,
REG_EXTENDED|REG_ICASE) == 0;
#endif
node = config_node_section(node, "channels", -1); node = config_node_section(node, "channels", -1);
if (node != NULL) rec->channels = config_node_get_list(node); if (node != NULL) rec->channels = config_node_get_list(node);
@ -527,9 +549,6 @@ static void cmd_hilight(const char *data)
rec->channels = channels; rec->channels = channels;
} else { } else {
g_strfreev(channels); g_strfreev(channels);
hilight_remove_config(rec);
hilights = g_slist_remove(hilights, rec);
} }
rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 : rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 :
@ -564,15 +583,7 @@ static void cmd_hilight(const char *data)
rec->act_color = g_strdup(actcolorarg); rec->act_color = g_strdup(actcolorarg);
} }
#ifdef HAVE_REGEX_H hilight_create(rec);
if (rec->regexp_compiled)
regfree(&rec->preg);
rec->regexp_compiled = !rec->regexp ? FALSE :
regcomp(&rec->preg, rec->text, REG_EXTENDED|REG_ICASE) == 0;
#endif
hilights = g_slist_append(hilights, rec);
hilight_add_config(rec);
hilight_print(g_slist_index(hilights, rec)+1, rec); hilight_print(g_slist_index(hilights, rec)+1, rec);
cmd_params_free(free_arg); cmd_params_free(free_arg);

View File

@ -40,6 +40,9 @@ char *hilight_match_nick(SERVER_REC *server, const char *channel,
const char *nick, const char *address, const char *nick, const char *address,
int level, const char *msg); int level, const char *msg);
void hilight_create(HILIGHT_REC *rec);
void hilight_remove(HILIGHT_REC *rec);
void hilight_text_init(void); void hilight_text_init(void);
void hilight_text_deinit(void); void hilight_text_deinit(void);

View File

@ -388,6 +388,8 @@ static void key_configure_destroy(KEY_REC *rec)
rec->info->keys = g_slist_remove(rec->info->keys, rec); rec->info->keys = g_slist_remove(rec->info->keys, rec);
g_hash_table_remove(keys, rec->key); g_hash_table_remove(keys, rec->key);
signal_emit("key destroyed", 1, rec);
if (!key_config_frozen) if (!key_config_frozen)
key_states_rescan(); key_states_rescan();
@ -421,6 +423,8 @@ static void key_configure_create(const char *id, const char *key,
info->keys = g_slist_append(info->keys, rec); info->keys = g_slist_append(info->keys, rec);
g_hash_table_insert(keys, rec->key, rec); g_hash_table_insert(keys, rec->key, rec);
signal_emit("key created", 1, rec);
if (!key_config_frozen) if (!key_config_frozen)
key_states_rescan(); key_states_rescan();
} }

View File

@ -4,20 +4,22 @@
#include "signals.h" #include "signals.h"
typedef struct _KEYBOARD_REC KEYBOARD_REC; typedef struct _KEYBOARD_REC KEYBOARD_REC;
typedef struct _KEYINFO_REC KEYINFO_REC;
typedef struct _KEY_REC KEY_REC;
typedef struct { struct _KEYINFO_REC {
char *id; char *id;
char *description; char *description;
GSList *keys, *default_keys; GSList *keys, *default_keys;
} KEYINFO_REC; };
typedef struct { struct _KEY_REC {
KEYINFO_REC *info; KEYINFO_REC *info;
char *key; char *key;
char *data; char *data;
} KEY_REC; };
extern GSList *keyinfos; extern GSList *keyinfos;