*/
#define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
+#include "config.h"
#include "gtktextbtree.h"
#include <string.h>
-#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include "gtktexttag.h"
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;
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)
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);
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;
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;
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);
}
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);
* 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.
/* 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;
}
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);
*
* 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.
*
/* 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;
* This procedure is invoked to perform consistency checks
* on character segments.
*
+ * Arguments:
+ * segPtr : Segment to check
+ * line : Line containing segment
+ *
* Results:
* None.
*
/* 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);
{
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");
}
}
}
*
* 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.
*/
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)
{
* 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
*/
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;
* 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.
*
*/
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)
{
*/
-GtkTextLineSegmentClass gtk_text_char_type = {
+const GtkTextLineSegmentClass gtk_text_char_type = {
"character", /* name */
0, /* leftGravity */
char_segment_split_func, /* splitFunc */
* range:
*/
-GtkTextLineSegmentClass gtk_text_toggle_on_type = {
+const GtkTextLineSegmentClass gtk_text_toggle_on_type = {
"toggleOn", /* name */
0, /* leftGravity */
NULL, /* splitFunc */
* range:
*/
-GtkTextLineSegmentClass gtk_text_toggle_off_type = {
+const GtkTextLineSegmentClass gtk_text_toggle_off_type = {
"toggleOff", /* name */
1, /* leftGravity */
NULL, /* splitFunc */