summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-15 19:03:27 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-15 19:03:27 +0000
commit118b5f48a298b0c32d3c1f8bc7a7b48f6436f9d7 (patch)
tree250962a47c3eaffef9eaa3754319586ef4edbe48
parent27fcabbc1965e9d7836f6e196ed2019a215bbe91 (diff)
downloadirssi-118b5f48a298b0c32d3c1f8bc7a7b48f6436f9d7.zip
Hilight fixes - mode lines shouldn't be hilighted accidentally anymore.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1633 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/fe-common/core/fe-messages.c5
-rw-r--r--src/fe-common/core/hilight-text.c52
-rw-r--r--src/fe-common/core/printtext.c8
3 files changed, 20 insertions, 45 deletions
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index 0bf33700..5f342b46 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -167,8 +167,9 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
window_item_window((WI_ITEM_REC *) chanrec)->items->next != NULL)
print_channel = TRUE;
- level = MSGLEVEL_PUBLIC | (for_me || color != NULL ?
- MSGLEVEL_HILIGHT : MSGLEVEL_NOHILIGHT);
+ level = MSGLEVEL_PUBLIC;
+ if (for_me || color != NULL)
+ level |= MSGLEVEL_HILIGHT;
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg);
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c
index 25dbcd67..0be646df 100644
--- a/src/fe-common/core/hilight-text.c
+++ b/src/fe-common/core/hilight-text.c
@@ -37,7 +37,6 @@
#include "formats.h"
static NICKMATCH_REC *nickmatch;
-static HILIGHT_REC *next_nick_hilight;
static int never_hilight_level, default_hilight_level;
GSList *hilights;
@@ -281,42 +280,28 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
{
HILIGHT_REC *hilight;
char *color, *newstr;
- int hilight_start, hilight_end, hilight_len;
+ int old_level, hilight_start, hilight_end, hilight_len;
- hilight_start = hilight_end = 0;
- if (next_nick_hilight != NULL) {
- if (!next_nick_hilight->nick) {
- /* non-nick hilight wanted */
- hilight = next_nick_hilight;
- next_nick_hilight = NULL;
- if (!hilight_match_text(hilight, stripped,
- &hilight_start,
- &hilight_end)) {
- hilight_start = 0;
- hilight_end = strlen(stripped);
- }
- } else {
- /* nick is highlighted, just set priority */
- hilight_update_text_dest(dest, next_nick_hilight);
- next_nick_hilight = NULL;
- return;
- }
- } else {
- if (dest->level & (MSGLEVEL_NOHILIGHT|MSGLEVEL_HILIGHT))
- return;
-
- hilight = hilight_match(dest->server, dest->target,
- NULL, NULL, dest->level, stripped,
- &hilight_start,
- &hilight_end);
- }
+ 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)
return;
/* update the level / hilight info */
+ old_level = dest->level;
hilight_update_text_dest(dest, hilight);
+ if (old_level & MSGLEVEL_HILIGHT) {
+ /* nick is highlighted, just set priority */
+ return;
+ }
+
color = hilight_get_color(hilight);
hilight_len = hilight_end-hilight_start;
@@ -387,7 +372,6 @@ char *hilight_match_nick(SERVER_REC *server, const char *channel,
color = rec == NULL || !rec->nick ? NULL :
hilight_get_color(rec);
- next_nick_hilight = rec;
return color;
}
@@ -557,16 +541,14 @@ static void cmd_hilight(const char *data)
rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
if (colorarg != NULL) {
+ g_free_and_null(rec->color);
if (*colorarg != '\0')
rec->color = g_strdup(colorarg);
- else
- g_free_and_null(rec->color);
}
if (actcolorarg != NULL) {
+ g_free_and_null(rec->act_color);
if (*actcolorarg != '\0')
rec->act_color = g_strdup(actcolorarg);
- else
- g_free_and_null(rec->act_color);
}
#ifdef HAVE_REGEX_H
@@ -654,8 +636,6 @@ void hilight_text_init(void)
settings_add_str("lookandfeel", "hilight_act_color", "%M");
settings_add_str("lookandfeel", "hilight_level", "PUBLIC DCCMSGS");
- next_nick_hilight = NULL;
-
read_settings();
nickmatch = nickmatch_init(hilight_nick_cache);
diff --git a/src/fe-common/core/printtext.c b/src/fe-common/core/printtext.c
index 29611a13..93a688f1 100644
--- a/src/fe-common/core/printtext.c
+++ b/src/fe-common/core/printtext.c
@@ -160,6 +160,7 @@ static void print_line(TEXT_DEST_REC *dest, const char *text)
/* send both the formatted + stripped (for logging etc.) */
stripped = strip_codes(str);
signal_emit_id(signal_print_text, 3, dest, str, stripped);
+ g_free_and_null(dest->hilight_color);
g_free(str);
g_free(stripped);
@@ -388,11 +389,6 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text)
signal_emit_id(signal_gui_print_text_finished, 1, dest->window);
}
-static void sig_print_text_free(TEXT_DEST_REC *dest, const char *text)
-{
- g_free_and_null(dest->hilight_color);
-}
-
void printtext_multiline(void *server, const char *target, int level,
const char *format, const char *text)
{
@@ -439,7 +435,6 @@ void printtext_init(void)
read_settings();
signal_add("print text", (SIGNAL_FUNC) sig_print_text);
- signal_add_last("print text", (SIGNAL_FUNC) sig_print_text_free);
signal_add("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
}
@@ -447,7 +442,6 @@ void printtext_init(void)
void printtext_deinit(void)
{
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
- signal_remove("print text", (SIGNAL_FUNC) sig_print_text_free);
signal_remove("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
}