Merge pull request #373 from RichardHitt/issue372

closes Issue372 -- Fix nickname-mouseover recognition
This commit is contained in:
TingPing 2013-01-11 16:16:39 -08:00
commit bba00f2b66
2 changed files with 20 additions and 4 deletions

View File

@ -188,6 +188,16 @@ static int laststart = 0;
static int lastend = 0;
static int lasttype = 0;
static int
strchrs (char c, char *s)
{
while (*s)
if (c == *s++)
return TRUE;
return FALSE;
}
#define NICKPRE "~+!@%%&"
int
url_check_word (const char *word)
{
@ -196,11 +206,15 @@ url_check_word (const char *word)
{
switch (lasttype)
{
char *str;
case WORD_NICK:
if (!isalnum (word[laststart]))
if (strchrs (word[laststart], NICKPRE))
laststart++;
if (!userlist_find (current_sess, &word[laststart]))
str = g_strndup (&word[laststart], lastend - laststart);
if (!userlist_find (current_sess, str))
lasttype = 0;
g_free (str);
return lasttype;
case WORD_EMAIL:
if (!isalnum (word[laststart]))
@ -448,7 +462,7 @@ re_email (void)
}
/* NICK description --- */
#define NICKPRE "~+!@%%&"
/* For NICKPRE see before url_check_word() */
#define NICKHYP "-"
#define NICKLET "a-z"
#define NICKDIG "0-9"

View File

@ -2311,7 +2311,9 @@ mg_word_clicked (GtkWidget *xtext, char *word, GdkEventButton *even)
menu_urlmenu (even, word);
break;
case WORD_NICK:
menu_nickmenu (sess, even, word + (ispunct (*word)? 1: 0), FALSE);
word[end] = 0;
word += start;
menu_nickmenu (sess, even, word, FALSE);
break;
case WORD_CHANNEL:
menu_chanmenu (sess, even, word);