aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorLauris Kaplinski <lauris@src.gnome.org>2000-08-24 11:25:53 +0800
committerLauris Kaplinski <lauris@src.gnome.org>2000-08-24 11:25:53 +0800
commit8d63772a7dffe54c6320a70021110e33dfe7c1ba (patch)
tree8414f5588b54d8df4b006b4effd8e6cc740f70a6 /widgets
parent9e945f485b3dd9456db54f1004eb37b31acbe412 (diff)
downloadgsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.gz
gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.zst
gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.zip
Unicode in addressbook basically works, including simple searching
svn path=/trunk/; revision=4997
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-text/e-text.c2
-rw-r--r--widgets/misc/e-unicode.c42
-rw-r--r--widgets/misc/e-unicode.h6
-rw-r--r--widgets/text/e-text.c2
4 files changed, 50 insertions, 2 deletions
diff --git a/widgets/e-text/e-text.c b/widgets/e-text/e-text.c
index ea2a655932..ed87f21c95 100644
--- a/widgets/e-text/e-text.c
+++ b/widgets/e-text/e-text.c
@@ -851,7 +851,7 @@ split_into_lines (EText *text)
laststart = text->text;
cp = text->text;
- for (p = unicode_get_utf8 (cp, &unival); line_num < text->num_lines && unival; cp = p, p = unicode_get_utf8 (p, &unival)) {
+ for (p = unicode_get_utf8 (cp, &unival); p && unival && line_num < text->num_lines; cp = p, p = unicode_get_utf8 (p, &unival)) {
gboolean handled = FALSE;
if (len == 0)
lines->text = cp;
diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c
index a865a7d0fa..8612048e21 100644
--- a/widgets/misc/e-unicode.c
+++ b/widgets/misc/e-unicode.c
@@ -10,6 +10,48 @@
#include <unicode.h>
#include "e-unicode.h"
+const gchar *
+e_utf8_strstrcase (const gchar *haystack, const gchar *needle)
+{
+ gchar *p;
+ unicode_char_t *huni, *nuni;
+ unicode_char_t unival;
+ gint hlen, nlen, hp, np;
+
+ if (haystack == NULL) return NULL;
+ if (needle == NULL) return NULL;
+ if (strlen (needle) == 0) return haystack;
+
+ huni = alloca (sizeof (unicode_char_t) * strlen (haystack));
+
+ for (hlen = 0, p = unicode_get_utf8 (haystack, &unival); p && unival; hlen++, p = unicode_get_utf8 (p, &unival)) {
+ huni[hlen] = unicode_tolower (unival);
+ }
+
+ if (!p) return NULL;
+ if (hlen == 0) return NULL;
+
+ nuni = alloca (sizeof (unicode_char_t) * strlen (needle));
+
+ for (nlen = 0, p = unicode_get_utf8 (needle, &unival); p && unival; nlen++, p = unicode_get_utf8 (p, &unival)) {
+ nuni[nlen] = unicode_tolower (unival);
+ }
+
+ if (!p) return NULL;
+ if (nlen == 0) return NULL;
+
+ if (hlen < nlen) return NULL;
+
+ for (hp = 0; hp <= hlen - nlen; hp++) {
+ for (np = 0; np < nlen; np++) {
+ if (huni[hp + np] != nuni[np]) break;
+ }
+ if (np == nlen) return haystack + unicode_offset_to_index (haystack, hp);
+ }
+
+ return NULL;
+}
+
gchar *
e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string)
{
diff --git a/widgets/misc/e-unicode.h b/widgets/misc/e-unicode.h
index 7bfba7e532..7bd46397e4 100644
--- a/widgets/misc/e-unicode.h
+++ b/widgets/misc/e-unicode.h
@@ -5,6 +5,12 @@
#include <glib.h>
#include <gtk/gtk.h>
+/*
+ * e_utf8_strstrcase
+ */
+
+const gchar *e_utf8_strstrcase (const gchar *haystack, const gchar *needle);
+
gchar *e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string);
gchar *e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string);
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index ea2a655932..ed87f21c95 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -851,7 +851,7 @@ split_into_lines (EText *text)
laststart = text->text;
cp = text->text;
- for (p = unicode_get_utf8 (cp, &unival); line_num < text->num_lines && unival; cp = p, p = unicode_get_utf8 (p, &unival)) {
+ for (p = unicode_get_utf8 (cp, &unival); p && unival && line_num < text->num_lines; cp = p, p = unicode_get_utf8 (p, &unival)) {
gboolean handled = FALSE;
if (len == 0)
lines->text = cp;