X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtktextsegment.c;h=d1493d69a41459207f954e7f84a27acfe2740747;hb=02e915273845b21af223e7e5e2425569afcf1b83;hp=5660b628d7d7812529b7800f1cc252cd4e0f9951;hpb=6ec06edbbfeed89767a720694ca7e7a091e18e66;p=~andy%2Fgtk diff --git a/gtk/gtktextsegment.c b/gtk/gtktextsegment.c index 5660b628d..d1493d69a 100644 --- a/gtk/gtktextsegment.c +++ b/gtk/gtktextsegment.c @@ -51,6 +51,7 @@ */ #define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API +#include "config.h" #include "gtktextbtree.h" #include #include @@ -102,7 +103,7 @@ gtk_text_line_segment_split (const GtkTextIter *iter) count = gtk_text_iter_get_line_index (iter); - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) _gtk_text_iter_check (iter); prev = NULL; @@ -172,12 +173,12 @@ char_segment_self_check (GtkTextLineSegment *seg) if (seg->byte_count <= 0) { - g_error ("char_segment_check_func: segment has size <= 0"); + g_error ("segment has size <= 0"); } if (strlen (seg->body.chars) != seg->byte_count) { - g_error ("char_segment_check_func: segment has wrong size"); + g_error ("segment has wrong size"); } if (g_utf8_strlen (seg->body.chars, seg->byte_count) != seg->char_count) @@ -194,7 +195,7 @@ _gtk_char_segment_new (const gchar *text, guint len) g_assert (gtk_text_byte_begins_utf8_char (text)); seg = g_malloc (CSEG_SIZE (len)); - seg->type = >k_text_char_type; + seg->type = (GtkTextLineSegmentClass *)>k_text_char_type; seg->next = NULL; seg->byte_count = len; memcpy (seg->body.chars, text, len); @@ -202,15 +203,19 @@ _gtk_char_segment_new (const gchar *text, guint len) seg->char_count = g_utf8_strlen (seg->body.chars, seg->byte_count); - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) char_segment_self_check (seg); return seg; } GtkTextLineSegment* -_gtk_char_segment_new_from_two_strings (const gchar *text1, guint len1, - const gchar *text2, guint len2) +_gtk_char_segment_new_from_two_strings (const gchar *text1, + guint len1, + guint chars1, + const gchar *text2, + guint len2, + guint chars2) { GtkTextLineSegment *seg; @@ -225,11 +230,9 @@ _gtk_char_segment_new_from_two_strings (const gchar *text1, guint len1, memcpy (seg->body.chars + len1, text2, len2); seg->body.chars[len1+len2] = '\0'; - /* 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 = g_utf8_strlen (seg->body.chars, seg->byte_count); + seg->char_count = chars1 + chars2; - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) char_segment_self_check (seg); return seg; @@ -260,7 +263,7 @@ char_segment_split_func (GtkTextLineSegment *seg, int index) g_assert (index < seg->byte_count); - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) { char_segment_self_check (seg); } @@ -276,7 +279,7 @@ char_segment_split_func (GtkTextLineSegment *seg, int index) new1->next = new2; new2->next = seg->next; - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) { char_segment_self_check (new1); char_segment_self_check (new2); @@ -294,6 +297,11 @@ char_segment_split_func (GtkTextLineSegment *seg, int index) * This procedure merges adjacent character segments into * a single character segment, if possible. * + * Arguments: + * segPtr: Pointer to the first of two adjacent segments to + * join. + * line: Line containing segments (not used). + * * Results: * The return value is a pointer to the first segment in * the (new) list of segments that used to start with segPtr. @@ -306,15 +314,11 @@ char_segment_split_func (GtkTextLineSegment *seg, int index) /* ARGSUSED */ static GtkTextLineSegment * -char_segment_cleanup_func (segPtr, line) - GtkTextLineSegment *segPtr; /* Pointer to first of two adjacent - * segments to join. */ - GtkTextLine *line; /* Line containing segments (not - * used). */ +char_segment_cleanup_func (GtkTextLineSegment *segPtr, GtkTextLine *line) { GtkTextLineSegment *segPtr2, *newPtr; - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) char_segment_self_check (segPtr); segPtr2 = segPtr->next; @@ -324,12 +328,16 @@ char_segment_cleanup_func (segPtr, line) } newPtr = - _gtk_char_segment_new_from_two_strings (segPtr->body.chars, segPtr->byte_count, - segPtr2->body.chars, segPtr2->byte_count); + _gtk_char_segment_new_from_two_strings (segPtr->body.chars, + segPtr->byte_count, + segPtr->char_count, + segPtr2->body.chars, + segPtr2->byte_count, + segPtr2->char_count); newPtr->next = segPtr2->next; - if (gtk_debug_flags & GTK_DEBUG_TEXT) + if (gtk_get_debug_flags () & GTK_DEBUG_TEXT) char_segment_self_check (newPtr); g_free (segPtr); @@ -344,6 +352,12 @@ char_segment_cleanup_func (segPtr, line) * * This procedure is invoked to delete a character segment. * + * Arguments: + * segPtr : Segment to delete + * line : Line containing segment + * treeGone : Non-zero means the entire tree is being + * deleted, so everything must get cleaned up. + * * Results: * Always returns 0 to indicate that the segment was deleted. * @@ -355,12 +369,7 @@ char_segment_cleanup_func (segPtr, line) /* ARGSUSED */ static int -char_segment_delete_func (segPtr, line, treeGone) - GtkTextLineSegment *segPtr; /* Segment to delete. */ - GtkTextLine *line; /* Line containing segment. */ - int treeGone; /* Non-zero means the entire tree is - * being deleted, so everything must - * get cleaned up. */ +char_segment_delete_func (GtkTextLineSegment *segPtr, GtkTextLine *line, int treeGone) { g_free ((char*) segPtr); return 0; @@ -374,6 +383,10 @@ char_segment_delete_func (segPtr, line, treeGone) * This procedure is invoked to perform consistency checks * on character segments. * + * Arguments: + * segPtr : Segment to check + * line : Line containing segment + * * Results: * None. * @@ -386,9 +399,7 @@ char_segment_delete_func (segPtr, line, treeGone) /* ARGSUSED */ static void -char_segment_check_func (segPtr, line) - GtkTextLineSegment *segPtr; /* Segment to check. */ - GtkTextLine *line; /* Line containing segment. */ +char_segment_check_func (GtkTextLineSegment *segPtr, GtkTextLine *line) { char_segment_self_check (segPtr); @@ -396,7 +407,7 @@ char_segment_check_func (segPtr, line) { if (segPtr->next->type == >k_text_char_type) { - g_error ("char_segment_check_func: adjacent character segments weren't merged"); + g_error ("adjacent character segments weren't merged"); } } } @@ -428,6 +439,12 @@ _gtk_toggle_segment_new (GtkTextTagInfo *info, gboolean on) * * This procedure is invoked to delete toggle segments. * + * Arguments: + * segPtr : Segment to check + * line : Line containing segment + * treeGone : Non-zero means the entire tree is being + * deleted so everything must get cleaned up + * * Results: * Returns 1 to indicate that the segment may not be deleted, * unless the entire B-tree is going away. @@ -441,12 +458,7 @@ _gtk_toggle_segment_new (GtkTextTagInfo *info, gboolean on) */ static int -toggle_segment_delete_func (segPtr, line, treeGone) - GtkTextLineSegment *segPtr; /* Segment to check. */ - GtkTextLine *line; /* Line containing segment. */ - int treeGone; /* Non-zero means the entire tree is - * being deleted, so everything must - * get cleaned up. */ +toggle_segment_delete_func (GtkTextLineSegment *segPtr, GtkTextLine *line, int treeGone) { if (treeGone) { @@ -480,6 +492,10 @@ toggle_segment_delete_func (segPtr, line, treeGone) * been modified in some way. It's invoked after the * modifications are complete. * + * Arguments: + * segPtr : Segment to check + * line : Line that now contains segment + * * Results: * The return value is the head segment in a new list * that is to replace the tail of the line that used to @@ -495,9 +511,7 @@ toggle_segment_delete_func (segPtr, line, treeGone) */ static GtkTextLineSegment * -toggle_segment_cleanup_func (segPtr, line) - GtkTextLineSegment *segPtr; /* Segment to check. */ - GtkTextLine *line; /* Line that now contains segment. */ +toggle_segment_cleanup_func (GtkTextLineSegment *segPtr, GtkTextLine *line) { GtkTextLineSegment *segPtr2, *prevPtr; int counts; @@ -555,6 +569,10 @@ toggle_segment_cleanup_func (segPtr, line) * This procedure is invoked when a toggle segment is about * to move from one line to another. * + * Arguments: + * segPtr : Segment to check + * line : Line that used to contain segment + * * Results: * None. * @@ -565,9 +583,7 @@ toggle_segment_cleanup_func (segPtr, line) */ static void -toggle_segment_line_change_func (segPtr, line) - GtkTextLineSegment *segPtr; /* Segment to check. */ - GtkTextLine *line; /* Line that used to contain segment. */ +toggle_segment_line_change_func (GtkTextLineSegment *segPtr, GtkTextLine *line) { if (segPtr->body.toggle.inNodeCounts) { @@ -582,7 +598,7 @@ toggle_segment_line_change_func (segPtr, line) */ -GtkTextLineSegmentClass gtk_text_char_type = { +const GtkTextLineSegmentClass gtk_text_char_type = { "character", /* name */ 0, /* leftGravity */ char_segment_split_func, /* splitFunc */ @@ -597,7 +613,7 @@ GtkTextLineSegmentClass gtk_text_char_type = { * range: */ -GtkTextLineSegmentClass gtk_text_toggle_on_type = { +const GtkTextLineSegmentClass gtk_text_toggle_on_type = { "toggleOn", /* name */ 0, /* leftGravity */ NULL, /* splitFunc */ @@ -612,7 +628,7 @@ GtkTextLineSegmentClass gtk_text_toggle_on_type = { * range: */ -GtkTextLineSegmentClass gtk_text_toggle_off_type = { +const GtkTextLineSegmentClass gtk_text_toggle_off_type = { "toggleOff", /* name */ 1, /* leftGravity */ NULL, /* splitFunc */