Hi,
This is what the patch would change...
changes to /hilight
-------------------
+ more than one hilight rule can now match against the same message.
+ rules are prioritised by their "stack" level
+ this means if more than one -nick rule matches against
the same message, the newest one (highest in stack) is
used.
+ if two different matches overlap, the highest one will
be drawn last to ensure it is visible.
e.g. if someone sent a public message "test" with the folowing rules...
/hilight -color %g test
/hilight -color %R s
't', 'e', 't' would be in green but the 's' would be in red.
if you were to swap the rules then "test" would be completly green.
- no longer limited to only having one rule with a particular mask...
one rule might be limited to serching nick names with -mask, but the other might be
intended for searching the whole message text. currently the second will overwrite the
first.
- _No_ limits on having duplicate rules...
since the meaning of rule is ultimatly determined by its poition within the stack, it
might be usefull to have multiple rules that are exactly the same but are at different
stack positions.
e.g. the following long winded, completly unbelieveable scenario...
* set up a default hilight rule for all nicks to be colored green *
/hilight -mask -color %g *
* start tracking the use of the word blah *
/hilight blah
* start tracking the use of the word foo *
/hilight foo
::
::
etc
* argh.. i want to track another really important word but these
other hilights are confusing me :) *
/hilight -mask -color %g * (notice its the same as the first rule :)
/hilight flibble
* finished tracking flibble, now want to carry on with the old tracking *
/dehilight -pop 2
changes to /dehilight
---------------------
+ added a -pop parameter
+ this allows you to "pop" <count> rules off of the stack
+ added a -clear parameter to remove all hilight rules
+ changed default behaviour with no parameters to == -pop
These changes seem to work well for me, so I thought you might like to
see if you want them aswell?
If you have any difficulties with it I will try and help, though I must
warn I have only been using irssi for a week and playing with the code
for about 3 days, so I'm not _that_ familier with it. :)
Regards,
- Rob
Only in /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/:
.hilight-text.c.swp
Only in /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/: Makefile
diff -bur irssi-0.8.6/src/fe-common/core/fe-messages.c
/var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/fe-messages.c
--- irssi-0.8.6/src/fe-common/core/fe-messages.c 2002-05-31 18:00:08.000000000
+0100
+++ /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/fe-messages.c
2003-04-05 00:50:51.000000000 +0100
@@ -152,11 +152,18 @@
if (nickrec == NULL && chanrec != NULL)
nickrec = nicklist_find(chanrec, nick);
+ /* DEBUG
+ * identify any public messages intended for me.
+ * identify if we should hilight a senders nick name.
+ */
for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
nick_match_msg(chanrec, msg, server->nick);
color = for_me ? NULL :
hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC,
msg);
+ /* DEBUG
+ * should the current active channel be displayed?
+ */
print_channel = chanrec == NULL ||
!window_item_is_active((WI_ITEM_REC *) chanrec);
if (!print_channel && settings_get_bool("print_active_channel") &&
@@ -164,7 +171,9 @@
print_channel = TRUE;
level = MSGLEVEL_PUBLIC;
- if (for_me || color != NULL)
+
+ /* if nick is being hilighted then up the level */
+ if (for_me)
level |= MSGLEVEL_HILIGHT;
if (settings_get_bool("emphasis"))
@@ -181,11 +190,14 @@
if (!print_channel) {
/* message to active channel in window */
if (color != NULL) {
- /* highlighted nick */
+ /* current channel - with highlighted nick */
printformat(server, target, level,
TXT_PUBMSG_HILIGHT,
color, printnick, msg, nickmode);
} else {
+ /* current channel - without hilighted nick
+ * (except if message directed to you)
+ */
printformat(server, target, level,
for_me ? TXT_PUBMSG_ME : TXT_PUBMSG,
printnick, msg, nickmode);
@@ -198,6 +210,8 @@
TXT_PUBMSG_HILIGHT_CHANNEL,
color, printnick, target, msg, nickmode);
} else {
+
+ /* non active channel messages */
printformat(server, target, level,
for_me ? TXT_PUBMSG_ME_CHANNEL :
TXT_PUBMSG_CHANNEL,
diff -bur irssi-0.8.6/src/fe-common/core/hilight-text.c
/var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/hilight-text.c
--- irssi-0.8.6/src/fe-common/core/hilight-text.c 2002-10-14 13:10:02.000000000
+0100
+++ /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/hilight-text.c
2003-04-05 22:38:05.000000000 +0100
@@ -38,11 +38,11 @@
static NICKMATCH_REC *nickmatch;
static int never_hilight_level, default_hilight_level;
-GSList *hilights;
+GList *hilights;
static void reset_cache(void)
{
- GSList *tmp;
+ GList *tmp;
never_hilight_level = MSGLEVEL_ALL & ~default_hilight_level;
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
@@ -55,6 +55,7 @@
nickmatch_rebuild(nickmatch);
}
+/* add a hilight record to config */
static void hilight_add_config(HILIGHT_REC *rec)
{
CONFIG_NODE *node;
@@ -81,6 +82,7 @@
}
}
+/* remove a hilight record from config */
static void hilight_remove_config(HILIGHT_REC *rec)
{
CONFIG_NODE *node;
@@ -88,9 +90,10 @@
g_return_if_fail(rec != NULL);
node = iconfig_node_traverse("hilights", FALSE);
- if (node != NULL) iconfig_node_list_remove(node, g_slist_index(hilights, rec));
+ if (node != NULL) iconfig_node_list_remove(node, g_list_index(hilights, rec));
}
+/* free() data asociated with a hilight record*/
static void hilight_destroy(HILIGHT_REC *rec)
{
g_return_if_fail(rec != NULL);
@@ -105,91 +108,74 @@
g_free(rec);
}
+/* remove and free() _ALL_ hilight records */
static void hilights_destroy_all(void)
{
- g_slist_foreach(hilights, (GFunc) hilight_destroy, NULL);
- g_slist_free(hilights);
+ g_list_foreach(hilights, (GFunc) hilight_destroy, NULL);
+ g_list_free(hilights);
hilights = NULL;
}
+/* init hilight record by compiling the regexp if neccisary */
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;
+ rec->regexp_compiled = !rec->regexp ? FALSE :regcomp(&rec->preg, rec->text,
REG_EXTENDED|REG_ICASE) == 0;
#endif
}
+/* record the new hilight record into the
+ * hilight list and add config
+ */
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);
+ /* CHANGED
+ * No longer tryes to replace duplicate records
+ * two identical records still have different priorities
+ * and it is possible that a user might want
+ * to take advantage of that.
+ */
+
+ /* append the record to the hilights list */
+ hilights = g_list_append(hilights, rec);
+ /* add config */
hilight_add_config(rec);
-
+ /* compile regexp if neccisary */
hilight_init_rec(rec);
signal_emit("hilight created", 1, rec);
}
+
+/* delete a hilight record and associated config data */
void hilight_remove(HILIGHT_REC *rec)
{
g_return_if_fail(rec != NULL);
hilight_remove_config(rec);
- hilights = g_slist_remove(hilights, rec);
+ hilights = g_list_remove(hilights, rec);
signal_emit("hilight destroyed", 1, rec);
hilight_destroy(rec);
}
-static HILIGHT_REC *hilight_find(const char *text, char **channels)
-{
- GSList *tmp;
- char **chan;
-
- g_return_val_if_fail(text != NULL, NULL);
-
- for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
- HILIGHT_REC *rec = tmp->data;
-
- if (g_strcasecmp(rec->text, text) != 0)
- continue;
-
- if ((channels == NULL && rec->channels == NULL))
- return rec; /* no channels - ok */
-
- if (channels != NULL && strcmp(*channels, "*") == 0)
- return rec; /* ignore channels */
-
- if (channels == NULL || rec->channels == NULL)
- continue; /* other doesn't have channels */
-
- if (strarray_length(channels) != strarray_length(rec->channels))
- continue; /* different amount of channels */
-
- /* check that channels match */
- for (chan = channels; *chan != NULL; chan++) {
- if (strarray_find(rec->channels, *chan) == -1)
- break;
- }
-
- if (*chan == NULL)
- return rec; /* channels ok */
- }
-
- return NULL;
-}
-
+/* take an input TEXT and try to match the hilight REC to it and
+ * locate a substring that needs to be hilighted.
+ * The substring boundary is returned by a start/end index into
+ * the TEXT
+ * false is returned if no match found else true.
+ */
static int hilight_match_text(HILIGHT_REC *rec, const char *text,
int *match_beg, int *match_end)
{
char *match;
+ /* TODO if match_beg !- NULL then only search the text after that char
+ * this could allow hilighting of multiple match occurences within one message
+ */
+
+ /* if -regexp used */
if (rec->regexp) {
#ifdef HAVE_REGEX_H
regmatch_t rmatch[1];
@@ -204,6 +190,7 @@
return TRUE;
}
#endif
+ /* if -full used */
} else {
match = rec->fullword ?
stristr_full(text, rec->text) :
@@ -220,55 +207,13 @@
return FALSE;
}
-#define hilight_match_level(rec, level) \
- (level & (((rec)->level != 0 ? rec->level : default_hilight_level)))
+/* return true if record matches the specified level */
+#define hilight_match_level(rec, lev) \
+ (lev & (((rec)->level != 0 ? rec->level : default_hilight_level)))
+/* return true if record matches the specified channel */
#define hilight_match_channel(rec, channel) \
- ((rec)->channels == NULL || ((channel) != NULL && \
- strarray_find((rec)->channels, (channel)) != -1))
-
-HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel,
- const char *nick, const char *address,
- int level, const char *str,
- int *match_beg, int *match_end)
-{
- GSList *tmp;
- CHANNEL_REC *chanrec;
- NICK_REC *nickrec;
-
- g_return_val_if_fail(str != NULL, NULL);
-
- if ((never_hilight_level & level) == level)
- return NULL;
-
- if (nick != NULL) {
- /* check nick mask hilights */
- chanrec = channel_find(server, channel);
- nickrec = chanrec == NULL ? NULL :
- nicklist_find(chanrec, nick);
- if (nickrec != NULL) {
- HILIGHT_REC *rec;
-
- if (nickrec->host == NULL)
- nicklist_set_host(chanrec, nickrec, address);
-
- rec = nickmatch_find(nickmatch, nickrec);
- if (rec != NULL && hilight_match_level(rec, level))
- return rec;
- }
- }
-
- for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
- HILIGHT_REC *rec = tmp->data;
-
- if (!rec->nickmask && hilight_match_level(rec, level) &&
- hilight_match_channel(rec, channel) &&
- hilight_match_text(rec, str, match_beg, match_end))
- return rec;
- }
-
- return NULL;
-}
+ ((rec)->channels == NULL || ((channel) != NULL && strarray_find((rec)->channels,
(channel)) != -1))
static char *hilight_get_act_color(HILIGHT_REC *rec)
{
@@ -291,6 +236,9 @@
return format_string_expand(color, NULL);
}
+/* This alters the message level to include HILIGHT
+ * it also alters the priority?
+ */
static void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec)
{
dest->level |= MSGLEVEL_HILIGHT;
@@ -305,50 +253,74 @@
dest->hilight_color = hilight_get_act_color(rec);
}
-static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
+/* CHANGED!! will now apply _all_ hilight records that can be matched
+ * instead of only applying the first one
+ */
+static void sig_print_text(TEXT_DEST_REC *dest,
+ const char *text,
const char *stripped)
{
HILIGHT_REC *hilight;
- char *color, *newstr;
- int old_level, hilight_start, hilight_end, hilight_len;
- int nick_match;
+ char *color=NULL, *newstr=NULL;
+ int old_level, hilight_start=0, hilight_end, hilight_len;
+
+ int n=0;
+ GList *hlist;
+ newstr=g_strdup(text);
if (dest->level & MSGLEVEL_NOHILIGHT)
return;
- hilight_start = hilight_end = 0;
- hilight = hilight_match(dest->server, dest->target,
- NULL, NULL, dest->level, stripped,
- &hilight_start,
- &hilight_end);
- if (hilight == NULL)
+ /* CHECK
+ * not sure if I need this?
+ * it was used in the hilight_match() function which is no
+ * longer used here, so I thought I should replace it's
+ * functionality by moving it here?
+ */
+ if ((never_hilight_level & dest->level) == dest->level)
return;
- nick_match = hilight->nick && (dest->level &
(MSGLEVEL_PUBLIC|MSGLEVEL_ACTIONS)) == MSGLEVEL_PUBLIC;
-
old_level = dest->level;
- if (!nick_match || (dest->level & MSGLEVEL_HILIGHT)) {
- /* update the level / hilight info */
- hilight_update_text_dest(dest, hilight);
- }
- if (nick_match)
- return; /* fe-messages.c should have taken care of this */
+ hilight_start = hilight_end = 0;
- if (old_level & MSGLEVEL_HILIGHT) {
- /* nick is highlighted, just set priority */
- return;
+ n=0;/* reset hilight-rec-match counter */
+
+ for (hlist = hilights; hlist != NULL; hlist = hlist->next) {
+ hilight = hlist->data;
+
+ /* TODO could make hilight_start and hilight_end into lists
+ * incase there are multiple occurences within one message
+ */
+ /* NOTE that this code completly ignores -mask records since
+ * we cant determining where the nick is at this stage?
+ * -mask is handled by fe-messages, but that means you can't use -line
+ * or -word with -mask.
+ */
+ /* if this hilight record does _not_ match this message */
+ if ((hilight->nick && !hilight->word) ||/* (fe-messages hilights the -nick
rules) */
+ hilight->nickmask ||/* no way to determin where the nick is at this stage
*/
+ !hilight_match_level(hilight, dest->level) ||
+ !hilight_match_channel(hilight, dest->target) ||
+ !hilight_match_text(hilight, stripped, &hilight_start, &hilight_end))
+ {
+ continue;
}
+ n++;/* inc count of hilights matched for this message */
+
+ /* update message level (mark as hilighted + set priority.) */
+ hilight_update_text_dest(dest, hilight);
+
color = hilight_get_color(hilight);
hilight_len = hilight_end-hilight_start;
- if (!hilight->word) {
- /* hilight whole line */
- char *tmp = strip_codes(text);
- newstr = g_strconcat(color, tmp, NULL);
- g_free(tmp);
- } else {
+ /* if used -line */
+ if (!hilight->word && !hilight->nick) {
+ hilight_len = hilight_end = strlen(stripped);
+ hilight_start=0;
+ }
+
/* hilight part of the line */
GString *tmp;
char *middle, *lastcolor;
@@ -357,25 +329,25 @@
tmp = g_string_new(NULL);
/* start of the line */
- pos = strip_real_length(text, hilight_start, NULL, NULL);
- g_string_append(tmp, text);
+ pos = strip_real_length(newstr, hilight_start, NULL, NULL);
+ g_string_append(tmp, newstr);
g_string_truncate(tmp, pos);
/* color */
g_string_append(tmp, color);
/* middle of the line, stripped */
- middle = strip_codes(text+pos);
+ middle = strip_codes(newstr+pos);
pos = tmp->len;
g_string_append(tmp, middle);
g_string_truncate(tmp, pos+hilight_len);
g_free(middle);
/* end of the line */
- pos = strip_real_length(text, hilight_end,
+ pos = strip_real_length(newstr, hilight_end,
&color_pos, &color_len);
if (color_pos > 0)
- lastcolor = g_strndup(text+color_pos, color_len);
+ lastcolor = g_strndup(newstr+color_pos, color_len);
else {
/* no colors in line, change back to default */
lastcolor = g_malloc0(3);
@@ -383,11 +355,27 @@
lastcolor[1] = FORMAT_STYLE_DEFAULTS;
}
g_string_append(tmp, lastcolor);
- g_string_append(tmp, text+pos);
+ g_string_append(tmp, newstr+pos);
g_free(lastcolor);
newstr = tmp->str;
g_string_free(tmp, FALSE);
+
+ /* TODO repeat this but only search after the end of this current match
+ * to check for multiple occurences of the same record
+ * Note: only do this if -word is used!!
+ */
+ /* TODO another option is only matching against the last part of the string
after
+ * this match. (somthing recursive may be..?)
+ */
+ }
+
+ if(!n)/* if no hilight rules were matched */
+ return;
+
+ if (old_level & MSGLEVEL_HILIGHT) {
+ /* if this message is already hilighted? */
+ return;
}
signal_emit("print text", 3, dest, newstr, stripped);
@@ -398,19 +386,62 @@
signal_stop();
}
+
+/* if you used -nick then fe-messages consults here to
+ * see if a particular message should have the sender nick hilighted.
+ *
+ * look through all -nick hilight records and try to
+ * find if the specified nick should be colored?
+ *
+ * Note: this searches is reverse order so that records highest on
+ * the "stack"? i.e. most recent have a higher priority.
+ */
+
+/* CHECK!!
+ * I didn't really follow the way -mask was handled before and
+ * think I am missing out some of the checks you had before??
+ * this seems to work in the same was as far as I have been able to tell
+ * but suspect it doesn't really. :) ?
+ */
char *hilight_match_nick(SERVER_REC *server, const char *channel,
const char *nick, const char *address,
int level, const char *msg)
{
HILIGHT_REC *rec;
- char *color;
+ GList *tmp;
+ int match_beg, match_end;
- rec = hilight_match(server, channel, nick, address,
- level, msg, NULL, NULL);
- color = rec == NULL || !rec->nick ? NULL :
- hilight_get_color(rec);
+ g_return_val_if_fail(msg != NULL, NULL);
+
+ if ((never_hilight_level & level) == level)
+ return NULL;
+
+ /* loop through all hilight records */
+ for (tmp = g_list_last(hilights); tmp != NULL; tmp = tmp->prev) {
+ rec = tmp->data;
+
+ /* only interested in -nick records */
+ if(!rec->nick)continue;
+
+ if (hilight_match_level(rec, level) &&
+ hilight_match_channel(rec, channel))
+ {
+ /* if this record should only match against the nickname */
+ if(rec->nickmask){
+ if((rec->regexp || rec->fullword) ?
+ hilight_match_text(rec, nick, &match_beg, &match_end)
+ :
+ match_wildcards(rec->text, nick)
+ )
+ return hilight_get_color(rec);
+ }else{
+ if(hilight_match_text(rec, msg, &match_beg, &match_end))
+ return hilight_get_color(rec);
+ }
+ }
+ }
- return color;
+ return NULL;
}
static void read_hilight_config(void)
@@ -440,7 +471,7 @@
continue;
rec = g_new0(HILIGHT_REC, 1);
- hilights = g_slist_append(hilights, rec);
+ hilights = g_list_append(hilights, rec);
rec->text = g_strdup(text);
@@ -470,6 +501,8 @@
reset_cache();
}
+
+/* output current list of hilight records to user */
static void hilight_print(int index, HILIGHT_REC *rec)
{
char *chans, *levelstr;
@@ -516,7 +549,7 @@
static void cmd_hilight_show(void)
{
- GSList *tmp;
+ GList *tmp;
int index;
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_HEADER);
@@ -529,9 +562,13 @@
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_FOOTER);
}
-/* SYNTAX: HILIGHT [-nick | -word | -line] [-mask | -full | -regexp]
+/* SYNTAX: HILIGHT [-nick | -word | -line] [-full | -regexp]
[-color <color>] [-actcolor <color>] [-level <level>]
- [-channels <channels>] <text> */
+ [-channels <channels>] [-mask] <text> */
+
+/* if you use the /hilight cmd to enter a new rule,
+ * then the text you enter comes here...
+ */
static void cmd_hilight(const char *data)
{
GHashTable *optlist;
@@ -553,8 +590,16 @@
chanarg = g_hash_table_lookup(optlist, "channels");
levelarg = g_hash_table_lookup(optlist, "level");
- priorityarg = g_hash_table_lookup(optlist, "priority");
+ priorityarg = g_hash_table_lookup(optlist, "priority"); /* DEBUG ?? */
colorarg = g_hash_table_lookup(optlist, "color");
+ /* TODO it would be nice of the color parameter could accept
+ * somthing like %U,%u and %a
+ * to say 'choose a unique hilight color'
+ * %u = unique non bright color
+ * %U = unique bright color
+ * %a = any unique color
+ * if a unique color can't be found then choose a random one?
+ */
actcolorarg = g_hash_table_lookup(optlist, "actcolor");
if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@@ -562,24 +607,28 @@
channels = (chanarg == NULL || *chanarg == '\0') ? NULL :
g_strsplit(replace_chars(chanarg, ',', ' '), " ", -1);
- rec = hilight_find(text, channels);
- if (rec == NULL) {
+ /* CHANGED
+ * so multiple records can have the same match pattern
+ */
rec = g_new0(HILIGHT_REC, 1);
- /* default to nick/word hilighting */
- rec->nick = TRUE;
- rec->word = TRUE;
+ /* should matching be limmited to just nick names? */
+ rec->nickmask = g_hash_table_lookup(optlist, "mask") != NULL;
rec->text = g_strdup(text);
rec->channels = channels;
- } else {
- g_strfreev(channels);
- }
rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 :
level2bits(replace_chars(levelarg, ',', ' '));
rec->priority = priorityarg == NULL ? 0 : atoi(priorityarg);
+ /* default to nick/word hilighting
+ * unless -mask is used in which case default to -nick hilighting
+ */
+ rec->nick = TRUE;
+ rec->word = rec->nickmask ? FALSE : TRUE;
+
+ /* how should messages that match be hilighted? */
if (g_hash_table_lookup(optlist, "line") != NULL) {
rec->word = FALSE;
rec->nick = FALSE;
@@ -590,10 +639,12 @@
rec->nick = FALSE;
}
- if (g_hash_table_lookup(optlist, "nick") != NULL)
+ if (g_hash_table_lookup(optlist, "nick") != NULL) {
+ rec->word = FALSE;
rec->nick = TRUE;
+ }
- rec->nickmask = g_hash_table_lookup(optlist, "mask") != NULL;
+ /* how should matching be performed? */
rec->fullword = g_hash_table_lookup(optlist, "full") != NULL;
rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
@@ -608,23 +659,113 @@
rec->act_color = g_strdup(actcolorarg);
}
+ /* NOTE shouldn't check if this is a duplicate record!
+ * because its position in the list changes how it
+ * actually matches.
+ */
+
hilight_create(rec);
- hilight_print(g_slist_index(hilights, rec)+1, rec);
+ hilight_print(g_list_index(hilights, rec)+1, rec);
cmd_params_free(free_arg);
reset_cache();
}
-/* SYNTAX: DEHILIGHT <id>|<mask> */
+
+/* CHANGED!! this now only used by dehilight for trying to match records
+ * by their text mask
+ */
+static HILIGHT_REC *hilight_find(const char *text, char **channels)
+{
+ GList *tmp;
+ char **chan;
+
+ g_return_val_if_fail(text != NULL, NULL);
+
+ for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
+ HILIGHT_REC *rec = tmp->data;
+
+ if (g_strcasecmp(rec->text, text) != 0)
+ continue;
+
+ if ((channels == NULL && rec->channels == NULL))
+ return rec; /* no channels - ok */
+
+ if (channels != NULL && strcmp(*channels, "*") == 0)
+ return rec; /* ignore channels */
+
+ if (channels == NULL || rec->channels == NULL)
+ continue; /* other doesn't have channels */
+
+ if (strarray_length(channels) != strarray_length(rec->channels))
+ continue; /* different amount of channels */
+
+ /* check that channels match */
+ for (chan = channels; *chan != NULL; chan++) {
+ if (strarray_find(rec->channels, *chan) == -1)
+ break;
+ }
+
+ if (*chan == NULL)
+ return rec; /* channels ok */
+ }
+
+ return NULL;
+}
+
+
+/* CHANGE -pop option will simply remove the last hilight record you added */
+/* SYNTAX: DEHILIGHT [-pop <count>| -clear] <id>|<mask> */
static void cmd_dehilight(const char *data)
{
+ GHashTable *optlist;
HILIGHT_REC *rec;
- GSList *tmp;
+ GList *tmp;
+ void *free_arg;
+ char *text;
+ char *poparg;
+ int popcount=0;
- if (is_numeric(data, ' ')) {
+ if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
+ PARAM_FLAG_GETREST, "dehilight", &optlist, &text))
+ return;
+
+ /* if -pop used then remove the last <count> hilight records added */
+ if((poparg = g_hash_table_lookup(optlist, "pop")) != NULL){
+ popcount = *poparg == '\0' ? 1 : atoi(poparg);
+ popcount = popcount == 0 ? -1 : popcount;
+ }
+
+ /* if -clear used then remove all hilight records */
+ if(g_hash_table_lookup(optlist, "clear") != NULL){
+ popcount = g_list_length(hilights);
+ popcount = popcount == 0 ? -1 : popcount;
+ }
+
+ /* _The Popper!_ */
+ if(popcount){
+ while(popcount-->0)
+ {
+ tmp = g_list_last(hilights);
+ rec = tmp == NULL ? NULL : tmp->data;
+ if(rec != NULL){
+ printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_HILIGHT_REMOVED,
rec->text);
+ hilight_remove(rec);
+ reset_cache();
+ }
+ }
+ /* ignore any other options */
+ return;
+ }
+
+ /* if no parameters give then simple pop the last record */
+ if(*data == '\0'){
+ tmp = g_list_last(hilights);
+ rec = tmp == NULL ? NULL : tmp->data;
+ }else if (is_numeric(data, ' ')) {
/* with index number */
- tmp = g_slist_nth(hilights, atoi(data)-1);
+ tmp = g_list_nth(hilights, atoi(data)-1);
rec = tmp == NULL ? NULL : tmp->data;
} else {
/* with mask */
@@ -639,12 +780,14 @@
hilight_remove(rec);
reset_cache();
}
+
+ cmd_params_free(free_arg);
}
static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel,
NICK_REC *nick)
{
- GSList *tmp;
+ GList *tmp;
HILIGHT_REC *match;
char *nickmask;
int len, best_match;
@@ -696,6 +839,7 @@
command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight);
command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight);
+ command_set_options("dehilight", "-pop -clear");
command_set_options("hilight", "-color -actcolor -level -priority -channels
nick word line mask full regexp");
}
diff -bur irssi-0.8.6/src/fe-common/core/hilight-text.h
/var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/hilight-text.h
--- irssi-0.8.6/src/fe-common/core/hilight-text.h 2002-05-19 07:50:50.000000000
+0100
+++ /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/hilight-text.h
2003-04-05 22:15:48.000000000 +0100
@@ -7,6 +7,8 @@
typedef struct _HILIGHT_REC HILIGHT_REC;
+
+/* this structure desribes a hilight rule, made using the /hilight cmd */
struct _HILIGHT_REC {
char *text;
@@ -17,24 +19,37 @@
char *act_color; /* color for window activity */
int priority;
- unsigned int nick:1; /* hilight only nick if possible */
- unsigned int word:1; /* hilight only word, not full line */
-
- unsigned int nickmask:1; /* `text' is a nick mask */
+ /* how to hilight matches..
+ tt=nick and word(default)
+ tf=only nick
+ ft=only word
+ ff=whole line
+ */
+ unsigned int nick:1;
+ unsigned int word:1;
+
+ unsigned int nickmask:1; /* `text' is a nick mask (only matching against nicks
done)*/
+
+ /* how to match
+ * tt=nothing
+ * tf=fullword
+ * ft=regexp
+ * ff=wild
+ */
unsigned int fullword:1; /* match `text' only for full words */
unsigned int regexp:1; /* `text' is a regular expression */
+
#ifdef HAVE_REGEX_H
unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is
invalid */
regex_t preg;
#endif
};
-extern GSList *hilights;
+extern GList *hilights;
HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel,
const char *nick, const char *address,
- int level, const char *str,
- int *match_beg, int *match_end);
+ int level, const char *str);
char *hilight_match_nick(SERVER_REC *server, const char *channel,
const char *nick, const char *address,
Only in /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/src/fe-common/core/: tags
Only in /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/docs/help/: Makefile
diff -bur irssi-0.8.6/docs/help/dehilight
/var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/docs/help/dehilight
--- irssi-0.8.6/docs/help/dehilight 2002-11-19 10:13:57.000000000 +0000
+++ /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/docs/help/dehilight
2003-04-06 00:24:01.000000000 +0100
@@ -1,5 +1,11 @@
-DEHILIGHT %|<id>|<mask>
+DEHILIGHT %|-pop <count> | -clear | <id> | <mask>
+
+ -pop: remove the last <count> hilight rules that you added.
+ -clear: remove all hilight rules.
+ <id>: remove a rule using it's unique id.
+ (/hilight gives you a list)
+ <mask>: remove a rule that uses this mask.
Removes the specified item from highlight list.
diff -bur irssi-0.8.6/docs/help/hilight
/var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/docs/help/hilight
--- irssi-0.8.6/docs/help/hilight 2002-11-19 10:13:57.000000000 +0000
+++ /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/docs/help/hilight 2003-04-06
00:52:26.000000000 +0100
@@ -1,23 +1,35 @@
HILIGHT %|[-nick | -word | -line] [-mask | -full | -regexp] [-color <color>]
[-actcolor <color>] [-level <level>] [-channels <channels>] <text>
- -mask: Match only for nick, <text> is a nick mask
+How to match:
-regexp: <text> is a regular expression
-full: <text> must match to full words
- -nick: Hilight only the nick, not the whole line (default)
+ (default is simple substring matching, except
+ when using -mask, wildcard matching is used)
+
+Limits on matching:
+ -mask: Match only for nick, <text> is a nick mask
+ (if you use this it will always hilight -nick
+ i.e you can't use -line or -word with it)
+ -level: Match only for <level> messages, default is
+ publics,msgs,notices,actions
+ -channels: Match only in <channels>
+
+How to hilight matches:
+ -nick: Hilight only the nick, not the whole line
-word: Hilight only the word (default with non-public messages)
-line: Hilight the whole line with the hilight color.
- -color: Print the message with <color>. color is in %%code format
+ (default is -nick and -word)
+
+ -color: Hilight with <color>. color is in %%code format
(see docs/formats.txt)
-actcolor: Color to show in statusbar activity, or don't change if %%n.
- -level: Match only for <level> messages, default is
- publics,msgs,notices,actions
- -channels: Match only in <channels>
Examples:
-Hilight lines that have "mynick" word:
- /HILIGHT mynick
+Hilight lines that contain "word"
+ /HILIGHT word
+ (will hilight nick and "word")
Hilight lines that were written by nicks from *.fi with bold green
/HILIGHT -color %%G -mask [EMAIL PROTECTED]
Only in /var/tmp/portage/irssi-0.8.6-r2/work/irssi-0.8.6/docs/help/in: Makefile