mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Merge pull request #79 from ZoiteChat/highlight-word-parsing
Fixed highlight word parsing so Unicode symbols (including emoji like… also fixed user info right click menu refreshing.
This commit is contained in:
@@ -258,6 +258,7 @@ alert_match_text (char *text, char *masks)
|
||||
{
|
||||
unsigned char *p = text;
|
||||
unsigned char endchar;
|
||||
gunichar ch;
|
||||
int res;
|
||||
|
||||
if (masks[0] == 0)
|
||||
@@ -265,26 +266,36 @@ alert_match_text (char *text, char *masks)
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (*p >= '0' && *p <= '9')
|
||||
ch = g_utf8_get_char (p);
|
||||
|
||||
if (g_unichar_isdigit (ch) || g_unichar_isalpha (ch))
|
||||
{
|
||||
p++;
|
||||
p += g_utf8_skip [p[0]];
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if it's RFC1459 <special>, it can be inside a word */
|
||||
switch (*p)
|
||||
switch (ch)
|
||||
{
|
||||
case '-': case '[': case ']': case '\\':
|
||||
case '`': case '^': case '{': case '}':
|
||||
case '_': case '|':
|
||||
p++;
|
||||
p += g_utf8_skip [p[0]];
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Symbols (including emoji) can be part of highlighted words. */
|
||||
if (!g_unichar_isspace (ch) && !g_unichar_ispunct (ch) &&
|
||||
!g_unichar_iscntrl (ch))
|
||||
{
|
||||
p += g_utf8_skip [p[0]];
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if it's a 0, space or comma, the word has ended. */
|
||||
if (*p == 0 || *p == ' ' || *p == ',' ||
|
||||
/* if it's anything BUT a letter, the word has ended. */
|
||||
(!g_unichar_isalpha (g_utf8_get_char (p))))
|
||||
(!g_unichar_isalpha (ch)))
|
||||
{
|
||||
endchar = *p;
|
||||
*p = 0;
|
||||
|
||||
@@ -778,6 +778,7 @@ fe_userlist_update (session *sess, struct User *user)
|
||||
{
|
||||
GList *items, *next;
|
||||
GList *iter;
|
||||
gboolean needs_refresh;
|
||||
|
||||
if (!nick_submenu || !str_copy)
|
||||
return;
|
||||
@@ -801,7 +802,14 @@ fe_userlist_update (session *sess, struct User *user)
|
||||
g_list_free (items);
|
||||
|
||||
/* and re-create them with new info */
|
||||
menu_create_nickinfo_menu (user, nick_submenu);
|
||||
needs_refresh = menu_create_nickinfo_menu (user, nick_submenu) ||
|
||||
!user->hostname || !user->realname || !user->servername;
|
||||
|
||||
if (needs_refresh)
|
||||
{
|
||||
g_signal_connect (G_OBJECT (nick_submenu), "show",
|
||||
G_CALLBACK (menu_nickinfo_cb), sess);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user