1 #ifndef GTK_TEXT_SEGMENT_H
2 #define GTK_TEXT_SEGMENT_H
4 #include <gtk/gtktexttag.h>
5 #include <gtk/gtktextiter.h>
6 #include <gtk/gtktextmarkprivate.h>
7 #include <gtk/gtktextchild.h>
11 #endif /* __cplusplus */
14 * Segments: each line is divided into one or more segments, where each
15 * segment is one of several things, such as a group of characters, a
16 * tag toggle, a mark, or an embedded widget. Each segment starts with
17 * a standard header followed by a body that varies from type to type.
20 /* This header has the segment type, and two specific segments
21 (character and toggle segments) */
23 /* Information a BTree stores about a tag. */
24 typedef struct _GtkTextTagInfo GtkTextTagInfo;
25 struct _GtkTextTagInfo {
27 GtkTextBTreeNode *tag_root; /* highest-level node containing the tag */
28 gint toggle_count; /* total toggles of this tag below tag_root */
31 /* Body of a segment that toggles a tag on or off */
32 struct _GtkTextToggleBody {
33 GtkTextTagInfo *info; /* Tag that starts or ends here. */
34 gboolean inNodeCounts; /* TRUE means this toggle has been
35 * accounted for in node toggle
36 * counts; FALSE means it hasn't, yet. */
40 /* Class struct for segments */
42 typedef GtkTextLineSegment *(* GtkTextLineSegmentSplitFunc) (GtkTextLineSegment *segPtr,
44 typedef gboolean (* GtkTextViewSegDeleteFunc) (GtkTextLineSegment *segPtr,
47 typedef GtkTextLineSegment *(* GtkTextViewSegCleanupFunc) (GtkTextLineSegment *segPtr,
49 typedef void (* GtkTextLineSegmentLineChangeFunc) (GtkTextLineSegment *segPtr,
51 typedef void (* GtkTextViewSegCheckFunc) (GtkTextLineSegment *segPtr,
54 struct _GtkTextLineSegmentClass {
55 char *name; /* Name of this kind of segment. */
56 gboolean leftGravity; /* If a segment has zero size (e.g. a
57 * mark or tag toggle), does it
58 * attach to character to its left
59 * or right? 1 means left, 0 means
61 GtkTextLineSegmentSplitFunc splitFunc; /* Procedure to split large segment
62 * into two smaller ones. */
63 GtkTextViewSegDeleteFunc deleteFunc; /* Procedure to call to delete
65 GtkTextViewSegCleanupFunc cleanupFunc; /* After any change to a line, this
66 * procedure is invoked for all
67 * segments left in the line to
68 * perform any cleanup they wish
69 * (e.g. joining neighboring
71 GtkTextLineSegmentLineChangeFunc lineChangeFunc;
72 /* Invoked when a segment is about
73 * to be moved from its current line
74 * to an earlier line because of
75 * a deletion. The line is that
76 * for the segment's old line.
77 * CleanupFunc will be invoked after
78 * the deletion is finished. */
80 GtkTextViewSegCheckFunc checkFunc; /* Called during consistency checks
81 * to check internal consistency of
86 * The data structure below defines line segments.
89 struct _GtkTextLineSegment {
90 GtkTextLineSegmentClass *type; /* Pointer to record describing
92 GtkTextLineSegment *next; /* Next in list of segments for this
93 * line, or NULL for end of list. */
95 int char_count; /* # of chars of index space occupied */
97 int byte_count; /* Size of this segment (# of bytes
98 * of index space it occupies). */
100 char chars[4]; /* Characters that make up character
101 * info. Actual length varies to
102 * hold as many characters as needed.*/
103 GtkTextToggleBody toggle; /* Information about tag toggle. */
104 GtkTextMarkBody mark; /* Information about mark. */
105 GtkTextPixmap pixmap; /* Child pixmap */
107 GtkTextChild child; /* child widget */
113 GtkTextLineSegment *gtk_text_line_segment_split(const GtkTextIter *iter);
115 GtkTextLineSegment *char_segment_new(const gchar *text, guint len);
117 GtkTextLineSegment *char_segment_new_from_two_strings(const gchar *text1, guint len1,
118 const gchar *text2, guint len2);
120 GtkTextLineSegment *toggle_segment_new(GtkTextTagInfo *info, gboolean on);
124 #endif /* __cplusplus */