Treat '_' as a word character too

master
Yevgen Muntyan 2006-07-06 00:12:59 -05:00
parent b773ebb39c
commit 7ecabdad0b
1 changed files with 11 additions and 9 deletions

View File

@ -243,6 +243,14 @@ get_regex (const char *pattern,
} }
inline static gboolean
is_word_char (const GtkTextIter *iter)
{
gunichar c = gtk_text_iter_get_char (iter);
return c == '_' || g_unichar_isalnum (c);
}
static gboolean static gboolean
is_whole_word (const GtkTextIter *start, is_whole_word (const GtkTextIter *start,
const GtkTextIter *end) const GtkTextIter *end)
@ -254,19 +262,13 @@ is_whole_word (const GtkTextIter *start,
if (!gtk_text_iter_starts_line (&s)) if (!gtk_text_iter_starts_line (&s))
{ {
gunichar c;
gtk_text_iter_backward_char (&s); gtk_text_iter_backward_char (&s);
c = gtk_text_iter_get_char (&s); if (is_word_char (&s))
if (g_unichar_isalnum (c))
return FALSE; return FALSE;
} }
if (!gtk_text_iter_ends_line (&e)) if (!gtk_text_iter_ends_line (&e) && is_word_char (&e))
{
gunichar c = gtk_text_iter_get_char (&e);
if (g_unichar_isalnum (c))
return FALSE; return FALSE;
}
return TRUE; return TRUE;
} }