diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 13 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 13 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 13 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 13 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 13 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 13 | ||||
-rw-r--r-- | gtk/gtktextbtree.c | 10 | ||||
-rw-r--r-- | gtk/gtktextiter.c | 40 | ||||
-rw-r--r-- | gtk/gtktextiter.h | 4 | ||||
-rw-r--r-- | gtk/gtktextsegment.c | 6 | ||||
-rw-r--r-- | gtk/gtktexttypes.c | 125 | ||||
-rw-r--r-- | gtk/gtktexttypes.h | 34 | ||||
-rw-r--r-- | gtk/gtktextview.c | 4 | ||||
-rw-r--r-- | gtk/testtextbuffer.c | 6 | ||||
-rw-r--r-- | tests/testtextbuffer.c | 6 |
16 files changed, 142 insertions, 184 deletions
@@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index cf9d3d166d..f33f1c3e38 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index cf9d3d166d..f33f1c3e38 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index cf9d3d166d..f33f1c3e38 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index cf9d3d166d..f33f1c3e38 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index cf9d3d166d..f33f1c3e38 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index cf9d3d166d..f33f1c3e38 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +2000-06-21 Havoc Pennington <hp@redhat.com> + + * gtk/gtktextiter.h: Use gunichar instead of gint when appropriate + in the interfaces + + * gtk/gtktexttypes.c: Remove UTF functions, use glib + stuff instead when possible. + + * gtk/gtktexttypes.h: Delete some unused constants + + * gtktextbtree.c, gtktextiter.c, gtktextsegment.c, gtktextview.c, + testtextbuffer.c: use glib instead of custom unicode routines + Wed Jun 21 12:50:58 2000 Owen Taylor <otaylor@redhat.com> * docs/es/: Removed mistakenly added generated sgml diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index ebbe0d92e8..ee2afb1c31 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -3369,7 +3369,7 @@ gtk_text_line_byte_to_char (GtkTextLine *line, else { if (seg->type == >k_text_char_type) - return char_offset + gtk_text_view_num_utf_chars(seg->body.chars, byte_offset); + return char_offset + g_utf8_strlen (seg->body.chars, byte_offset); else { g_assert(seg->char_count == 1); @@ -3594,8 +3594,7 @@ gtk_text_line_byte_to_char_offsets(GtkTextLine *line, if (seg->type == >k_text_char_type) { - *seg_char_offset = gtk_text_view_num_utf_chars(seg->body.chars, - offset); + *seg_char_offset = g_utf8_strlen(seg->body.chars, offset); g_assert(*seg_char_offset < seg->char_count); @@ -3643,11 +3642,10 @@ gtk_text_line_char_to_byte_offsets(GtkTextLine *line, *seg_byte_offset = 0; while (offset > 0) { - GtkTextUniChar ch; gint bytes; + const char * start = seg->body.chars + *seg_byte_offset; - bytes = gtk_text_utf_to_unichar(seg->body.chars + *seg_byte_offset, - &ch); + bytes = g_utf8_next_char (start) - start; *seg_byte_offset += bytes; offset -= 1; } diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index 8cc5f783e2..953045e0b4 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -575,7 +575,7 @@ gtk_text_iter_get_line_byte(const GtkTextIter *iter) * Dereferencing */ -gint +gunichar gtk_text_iter_get_char(const GtkTextIter *iter) { GtkTextRealIter *real; @@ -594,15 +594,10 @@ gtk_text_iter_get_char(const GtkTextIter *iter) if (real->segment->type == >k_text_char_type) { - GtkTextUniChar ch; - ensure_byte_offsets(real); - gtk_text_utf_to_unichar(real->segment->body.chars + - real->segment_byte_offset, - &ch); - - return ch; + return g_utf8_get_char (real->segment->body.chars + + real->segment_byte_offset); } else { @@ -1018,11 +1013,10 @@ forward_char(GtkTextRealIter *real) if (real->line_byte_offset >= 0) { gint bytes; - GtkTextUniChar ch; - - bytes = gtk_text_utf_to_unichar(real->segment->body.chars + - real->segment_byte_offset, - &ch); + const char * start = + real->segment->body.chars + real->segment_byte_offset; + + bytes = g_utf8_next_char (start) - start; real->line_byte_offset += bytes; real->segment_byte_offset += bytes; @@ -1281,10 +1275,9 @@ gtk_text_iter_backward_chars(GtkTextIter *iter, gint count) i = 0; while (i < real->segment_char_offset) { - GtkTextUniChar ch; - new_byte_offset += - gtk_text_utf_to_unichar(real->segment->body.chars + new_byte_offset, - &ch); + const char * start = real->segment->body.chars + new_byte_offset; + new_byte_offset += g_utf8_next_char (start) - start; + ++i; } @@ -1464,14 +1457,14 @@ gtk_text_iter_backward_lines(GtkTextIter *iter, gint count) } static gboolean -is_word_char(GtkTextUniChar ch, gpointer user_data) +is_word_char(gunichar ch, gpointer user_data) { /* will likely need some i18n help FIXME */ return isalpha(ch); } static gboolean -is_not_word_char(GtkTextUniChar ch, gpointer user_data) +is_not_word_char(gunichar ch, gpointer user_data) { return !is_word_char(ch, user_data); } @@ -2339,10 +2332,8 @@ gtk_text_iter_check(const GtkTextIter *iter) gint char_offset = 0; while (char_offset < seg_char_offset) { - GtkTextUniChar ch; - byte_offset += - gtk_text_utf_to_unichar(char_segment->body.chars + byte_offset, - &ch); + const char * start = char_segment->body.chars + byte_offset; + byte_offset += g_utf8_next_char (start) - start; char_offset += 1; } @@ -2350,8 +2341,7 @@ gtk_text_iter_check(const GtkTextIter *iter) g_error("byte offset did not correspond to char offset"); char_offset = - gtk_text_view_num_utf_chars(char_segment->body.chars, - seg_byte_offset); + g_utf8_strlen (char_segment->body.chars, seg_byte_offset); if (char_offset != seg_char_offset) g_error("char offset did not correspond to byte offset"); diff --git a/gtk/gtktextiter.h b/gtk/gtktextiter.h index 579fe859bc..1b93220263 100644 --- a/gtk/gtktextiter.h +++ b/gtk/gtktextiter.h @@ -54,7 +54,7 @@ gint gtk_text_iter_get_line_byte (const GtkTextIter *iter); /* * "Dereference" operators */ -gint gtk_text_iter_get_char (const GtkTextIter *iter); +gunichar gtk_text_iter_get_char (const GtkTextIter *iter); /* includes the 0xFFFD char for pixmaps/widgets, so char offsets into the returned string map properly into buffer char offsets */ @@ -144,7 +144,7 @@ gboolean gtk_text_iter_forward_find_tag_toggle (GtkTextIter *iter, gboolean gtk_text_iter_backward_find_tag_toggle (GtkTextIter *iter, GtkTextTag *tag); -typedef gboolean (* GtkTextViewCharPredicate) (guint16 ch, gpointer user_data); +typedef gboolean (* GtkTextViewCharPredicate) (gunichar ch, gpointer user_data); gboolean gtk_text_iter_forward_find_char (GtkTextIter *iter, GtkTextViewCharPredicate pred, diff --git a/gtk/gtktextsegment.c b/gtk/gtktextsegment.c index e4effa1b5c..38e905865b 100644 --- a/gtk/gtktextsegment.c +++ b/gtk/gtktextsegment.c @@ -177,7 +177,7 @@ char_segment_self_check(GtkTextLineSegment *seg) g_error("char_segment_check_func: segment has wrong size"); } - if (gtk_text_view_num_utf_chars(seg->body.chars, seg->byte_count) != seg->char_count) + if (g_utf8_strlen (seg->body.chars, seg->byte_count) != seg->char_count) { g_error("char segment has wrong character count"); } @@ -197,7 +197,7 @@ char_segment_new(const gchar *text, guint len) memcpy(seg->body.chars, text, len); seg->body.chars[len] = '\0'; - seg->char_count = gtk_text_view_num_utf_chars(seg->body.chars, seg->byte_count); + seg->char_count = g_utf8_strlen (seg->body.chars, seg->byte_count); if (gtk_debug_flags & GTK_DEBUG_TEXT) char_segment_self_check(seg); @@ -224,7 +224,7 @@ char_segment_new_from_two_strings(const gchar *text1, guint len1, /* In principle this function could probably take chars1 and chars2 as args, since it's typically used to merge two char segments */ - seg->char_count = gtk_text_view_num_utf_chars(seg->body.chars, seg->byte_count); + seg->char_count = g_utf8_strlen (seg->body.chars, seg->byte_count); if (gtk_debug_flags & GTK_DEBUG_TEXT) char_segment_self_check(seg); diff --git a/gtk/gtktexttypes.c b/gtk/gtktexttypes.c index 1dfa16bfc4..c9ba97df6b 100644 --- a/gtk/gtktexttypes.c +++ b/gtk/gtktexttypes.c @@ -42,70 +42,12 @@ gtk_text_view_tab_array_unref(GtkTextTabArray *tab_array) } } -/* - * Unicode stubs (these are wrappers to make libunicode match the Tcl/Tk - * API, eventually should just use libunicode/Pango directly) +/* These are used to represent embedded non-character objects + * if you return a string representation of a text buffer */ - -#if 0 -static void -trigger_efence(const gchar *str, gint len) -{ - gchar ch; - gint i = 0; - while (i < len) - { - ch = str[i]; - ((gchar*)str)[i] = ch; - ++i; - } -} -#else -#define trigger_efence(foo,bar) -#endif - -const GtkTextUniChar gtk_text_unknown_char = 0xFFFD; +const gunichar gtk_text_unknown_char = 0xFFFD; const gchar gtk_text_unknown_char_utf8[] = { 0xEF, 0xBF, 0xBD, '\0' }; -gint -gtk_text_view_num_utf_chars(const gchar *str, gint len) -{ - trigger_efence(str, len); - return g_utf8_strlen(str, len); -} - -/* FIXME we need a version of this function with error handling, so we - can screen incoming UTF8 for validity. */ - -gint -gtk_text_utf_to_unichar(const gchar *str, GtkTextUniChar *chPtr) -{ - gunichar ch; - - ch = g_utf8_get_char (str); - - if (ch == (gunichar)-1) - g_error("Bad UTF8, need to add some error checking so this doesn't crash the program"); - - *chPtr = ch; - - trigger_efence(str, end - str); - - return g_utf8_next_char (str) - str; -} - -gchar* -gtk_text_utf_prev(const gchar *str, const gchar *start) -{ - gchar *retval; - - trigger_efence(start, str - start); - - retval = g_utf8_find_prev_char (start, str); - - return retval; -} - static inline gboolean inline_byte_begins_utf8_char(const gchar *byte) { @@ -115,7 +57,6 @@ inline_byte_begins_utf8_char(const gchar *byte) gboolean gtk_text_byte_begins_utf8_char(const gchar *byte) { - trigger_efence(byte, 1); return inline_byte_begins_utf8_char(byte); } @@ -123,11 +64,12 @@ guint gtk_text_utf_to_latin1_char(const gchar *p, guchar *l1_ch) { guint charlen; - GtkTextUniChar ch; + gunichar ch; g_assert(inline_byte_begins_utf8_char(p)); - charlen = gtk_text_utf_to_unichar(p, &ch); + charlen = g_utf8_next_char (p) - p; + ch = g_utf8_get_char (p); g_assert(ch != '\0'); @@ -145,8 +87,6 @@ gtk_text_utf_to_latin1(const gchar *p, gint len) GString *str; guint i; gchar *retval; - - trigger_efence(p, len); str = g_string_new(""); @@ -169,54 +109,6 @@ gtk_text_utf_to_latin1(const gchar *p, gint len) return retval; } -static int -gtk_text_view_unichar_to_utf(GtkTextUniChar c, char *outbuf) -{ - size_t len = 0; - int first; - int i; - - if (c < 0x80) - { - first = 0; - len = 1; - } - else if (c < 0x800) - { - first = 0xc0; - len = 2; - } - else if (c < 0x10000) - { - first = 0xe0; - len = 3; - } - else if (c < 0x200000) - { - first = 0xf0; - len = 4; - } - else if (c < 0x4000000) - { - first = 0xf8; - len = 5; - } - else - { - first = 0xfc; - len = 6; - } - - for (i = len - 1; i > 0; --i) - { - outbuf[i] = (c & 0x3f) | 0x80; - c >>= 6; - } - outbuf[0] = c | first; - - return len; -} - gchar* gtk_text_latin1_to_utf (const gchar *latin1, gint len) { @@ -232,7 +124,7 @@ gtk_text_latin1_to_utf (const gchar *latin1, gint len) gchar utf[7]; gint count; - count = gtk_text_view_unichar_to_utf((guchar)latin1[i], utf); + count = g_unichar_to_utf8 ((guchar)latin1[i], utf); utf[count] = '\0'; @@ -245,3 +137,6 @@ gtk_text_latin1_to_utf (const gchar *latin1, gint len) g_string_free(retval, FALSE); return str; } + + + diff --git a/gtk/gtktexttypes.h b/gtk/gtktexttypes.h index d8c284a38a..65c3cf0653 100644 --- a/gtk/gtktexttypes.h +++ b/gtk/gtktexttypes.h @@ -8,9 +8,6 @@ extern "C" { #include <glib.h> #include <gtk/gtktextbuffer.h> - -typedef unsigned short GtkTextUniChar; /* Unicode character */ - #include <gtk/gtktexttagprivate.h> typedef struct _GtkTextLine GtkTextLine; @@ -97,20 +94,6 @@ void gtk_text_view_tab_array_ref (GtkTextTabArray *tab_array); void gtk_text_view_tab_array_unref (GtkTextTabArray *tab_array); /* - * The constant below is used to specify a line when what is really - * wanted is the entire text. For now, just use a very big number. - */ - -#define GTK_TEXT_END_OF_TEXT 1000000 - -/* - * The following definition specifies the maximum number of characters - * needed in a string to hold a position specifier. - */ - -#define GTK_TEXT_POS_CHARS 30 - -/* * Declarations for variables shared among the text-related files: */ @@ -131,16 +114,17 @@ extern GtkTextLineSegmentClass gtk_text_view_child_type; * UTF 8 Stubs */ -extern const GtkTextUniChar gtk_text_unknown_char; +extern const gunichar gtk_text_unknown_char; extern const gchar gtk_text_unknown_char_utf8[]; -gint gtk_text_view_num_utf_chars(const gchar *chars, gint len); -gint gtk_text_utf_to_unichar(const gchar *p, GtkTextUniChar *ch); -gchar *gtk_text_utf_prev(const gchar *p, const gchar *p2); -gchar *gtk_text_utf_to_latin1(const gchar *p, gint len); -gboolean gtk_text_byte_begins_utf8_char(const gchar *byte); -guint gtk_text_utf_to_latin1_char(const gchar *p, guchar *ch); -gchar *gtk_text_latin1_to_utf (const gchar *latin1, gint len); +gboolean gtk_text_byte_begins_utf8_char (const gchar *byte); +guint gtk_text_utf_to_latin1_char (const gchar *p, + guchar *l1_ch); +gchar* gtk_text_utf_to_latin1 (const gchar *p, + gint len); +gchar* gtk_text_latin1_to_utf (const gchar *latin1, + gint len); + #ifdef __cplusplus } diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 778442538a..124f16dbfb 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -1932,13 +1932,13 @@ gtk_text_view_scroll_text (GtkTextView *text_view, } static gboolean -whitespace (GtkTextUniChar ch, gpointer user_data) +whitespace (gunichar ch, gpointer user_data) { return (ch == ' ' || ch == '\t'); } static gboolean -not_whitespace (GtkTextUniChar ch, gpointer user_data) +not_whitespace (gunichar ch, gpointer user_data) { return !whitespace (ch, user_data); } diff --git a/gtk/testtextbuffer.c b/gtk/testtextbuffer.c index dfd95bf0a4..884ed0f887 100644 --- a/gtk/testtextbuffer.c +++ b/gtk/testtextbuffer.c @@ -14,14 +14,14 @@ main(int argc, char** argv) { GtkTextBuffer *buffer; int n; - GtkTextUniChar ch; + gunichar ch; GtkTextIter start, end; gtk_init(&argc, &argv); /* Check UTF8 unknown char thing */ - g_assert(gtk_text_view_num_utf_chars(gtk_text_unknown_char_utf8, 3) == 1); - gtk_text_utf_to_unichar(gtk_text_unknown_char_utf8, &ch); + g_assert(g_utf8_strlen (gtk_text_unknown_char_utf8, 3) == 1); + ch = g_utf8_get_char (gtk_text_unknown_char_utf8); g_assert(ch == gtk_text_unknown_char); /* First, we turn on btree debugging. */ diff --git a/tests/testtextbuffer.c b/tests/testtextbuffer.c index dfd95bf0a4..884ed0f887 100644 --- a/tests/testtextbuffer.c +++ b/tests/testtextbuffer.c @@ -14,14 +14,14 @@ main(int argc, char** argv) { GtkTextBuffer *buffer; int n; - GtkTextUniChar ch; + gunichar ch; GtkTextIter start, end; gtk_init(&argc, &argv); /* Check UTF8 unknown char thing */ - g_assert(gtk_text_view_num_utf_chars(gtk_text_unknown_char_utf8, 3) == 1); - gtk_text_utf_to_unichar(gtk_text_unknown_char_utf8, &ch); + g_assert(g_utf8_strlen (gtk_text_unknown_char_utf8, 3) == 1); + ch = g_utf8_get_char (gtk_text_unknown_char_utf8); g_assert(ch == gtk_text_unknown_char); /* First, we turn on btree debugging. */ |