From 078a10900f31ec23a10a0e4a589760fb51ccf1cb Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 1 Jan 2001 04:22:31 +0000 Subject: don't do emphasis on nicks in channel ( _nick2_: hello won't underline) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1032 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/fe-messages.c | 22 ++++++++++++++++++---- src/fe-common/core/fe-messages.h | 2 +- src/fe-common/irc/dcc/fe-dcc.c | 11 +++++++---- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c index 86417c64..b994fe5c 100644 --- a/src/fe-common/core/fe-messages.c +++ b/src/fe-common/core/fe-messages.c @@ -39,7 +39,7 @@ /* convert _underlined_ and *bold* words (and phrases) to use real underlining or bolding */ -char *expand_emphasis(const char *text) +char *expand_emphasis(WI_ITEM_REC *item, const char *text) { GString *str; char *ret; @@ -71,6 +71,19 @@ char *expand_emphasis(const char *text) isalnum(end[1]) || end[1] == type) continue; + if (IS_CHANNEL(item)) { + /* check that this isn't a _nick_, we don't want to + use emphasis on them. */ + int found; + char c; + + c = end[1]; + end[1] = '\0'; + found = nicklist_find(CHANNEL(item), bgn) != NULL; + end[1] = c; + if (found) continue; + } + /* allow only *word* emphasis, not *multiple words* */ if (!settings_get_bool("emphasis_multiword")) { char *c; @@ -141,7 +154,7 @@ static void sig_message_public(SERVER_REC *server, const char *msg, MSGLEVEL_HILIGHT : MSGLEVEL_NOHILIGHT); if (settings_get_bool("emphasis")) - msg = freemsg = expand_emphasis(msg); + msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg); else freemsg = NULL; @@ -183,12 +196,13 @@ static void sig_message_private(SERVER_REC *server, const char *msg, QUERY_REC *query; char *freemsg; + query = query_find(server, nick); + if (settings_get_bool("emphasis")) - msg = freemsg = expand_emphasis(msg); + msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg); else freemsg = NULL; - query = query_find(server, nick); printformat(server, nick, MSGLEVEL_MSGS, query == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, address, msg); diff --git a/src/fe-common/core/fe-messages.h b/src/fe-common/core/fe-messages.h index c277840f..16b0b73d 100644 --- a/src/fe-common/core/fe-messages.h +++ b/src/fe-common/core/fe-messages.h @@ -3,6 +3,6 @@ /* convert _underlined_ and *bold* words (and phrases) to use real underlining or bolding */ -char *expand_emphasis(const char *text); +char *expand_emphasis(WI_ITEM_REC *item, const char *text); #endif diff --git a/src/fe-common/irc/dcc/fe-dcc.c b/src/fe-common/irc/dcc/fe-dcc.c index 0bdfd909..6d3eef73 100644 --- a/src/fe-common/irc/dcc/fe-dcc.c +++ b/src/fe-common/irc/dcc/fe-dcc.c @@ -143,22 +143,25 @@ static void dcc_chat_ctcp(const char *msg, DCC_REC *dcc) static void dcc_chat_msg(DCC_REC *dcc, const char *msg) { + QUERY_REC *query; char *sender, *freemsg; g_return_if_fail(dcc != NULL); g_return_if_fail(msg != NULL); + sender = g_strconcat("=", dcc->nick, NULL); + query = query_find(NULL, sender); + if (settings_get_bool("emphasis")) - msg = freemsg = expand_emphasis(msg); + msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg); else freemsg = NULL; - sender = g_strconcat("=", dcc->nick, NULL); printformat(NULL, sender, MSGLEVEL_DCCMSGS, - query_find(NULL, sender) ? IRCTXT_DCC_MSG_QUERY : + query != NULL ? IRCTXT_DCC_MSG_QUERY : IRCTXT_DCC_MSG, dcc->nick, msg); - g_free(sender); g_free_not_null(freemsg); + g_free(sender); } static void dcc_request(DCC_REC *dcc) -- cgit v1.2.3