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;
}
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);
hilight_remove_config(rec);
hilights = g_slist_remove(hilights, rec);
signal_emit("hilight destroyed", 1, rec);
hilight_destroy(rec);
}
@ -435,11 +461,7 @@ static void read_hilight_config(void)
rec->fullword = config_node_get_bool(node, "fullword", FALSE);
rec->regexp = config_node_get_bool(node, "regexp", FALSE);
#ifdef HAVE_REGEX_H
rec->regexp_compiled = !rec->regexp ? FALSE :
regcomp(&rec->preg, rec->text,
REG_EXTENDED|REG_ICASE) == 0;
#endif
hilight_init_rec(rec);
node = config_node_section(node, "channels", -1);
if (node != NULL) rec->channels = config_node_get_list(node);
@ -527,9 +549,6 @@ static void cmd_hilight(const char *data)
rec->channels = channels;
} else {
g_strfreev(channels);
hilight_remove_config(rec);
hilights = g_slist_remove(hilights, rec);
}
rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 :
@ -564,15 +583,7 @@ static void cmd_hilight(const char *data)
rec->act_color = g_strdup(actcolorarg);
}
#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
hilights = g_slist_append(hilights, rec);
hilight_add_config(rec);
hilight_create(rec);
hilight_print(g_slist_index(hilights, rec)+1, rec);
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,
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_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);
g_hash_table_remove(keys, rec->key);
signal_emit("key destroyed", 1, rec);
if (!key_config_frozen)
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);
g_hash_table_insert(keys, rec->key, rec);
signal_emit("key created", 1, rec);
if (!key_config_frozen)
key_states_rescan();
}

View File

@ -4,20 +4,22 @@
#include "signals.h"
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 *description;
GSList *keys, *default_keys;
} KEYINFO_REC;
};
typedef struct {
struct _KEY_REC {
KEYINFO_REC *info;
char *key;
char *data;
} KEY_REC;
};
extern GSList *keyinfos;