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>
8 #include <gtk/gtktextchildprivate.h>
12 #endif /* __cplusplus */
15 * Segments: each line is divided into one or more segments, where each
16 * segment is one of several things, such as a group of characters, a
17 * tag toggle, a mark, or an embedded widget. Each segment starts with
18 * a standard header followed by a body that varies from type to type.
21 /* This header has the segment type, and two specific segments
22 (character and toggle segments) */
24 /* Information a BTree stores about a tag. */
25 typedef struct _GtkTextTagInfo GtkTextTagInfo;
26 struct _GtkTextTagInfo {
28 GtkTextBTreeNode *tag_root; /* highest-level node containing the tag */
29 gint toggle_count; /* total toggles of this tag below tag_root */
32 /* Body of a segment that toggles a tag on or off */
33 struct _GtkTextToggleBody {
34 GtkTextTagInfo *info; /* Tag that starts or ends here. */
35 gboolean inNodeCounts; /* TRUE means this toggle has been
36 * accounted for in node toggle
37 * counts; FALSE means it hasn't, yet. */
41 /* Class struct for segments */
43 /* Split seg at index, returning list of two new segments, and freeing seg */
44 typedef GtkTextLineSegment* (*GtkTextSegSplitFunc) (GtkTextLineSegment *seg,
47 /* Delete seg which is contained in line; if tree_gone, the tree is being
48 * freed in its entirety, which may matter for some reason (?)
49 * Return TRUE if the segment is not deleteable, e.g. a mark.
51 typedef gboolean (*GtkTextSegDeleteFunc) (GtkTextLineSegment *seg,
55 /* Called after segment structure of line changes, so segments can
56 * cleanup (e.g. merge with adjacent segments). Returns a segment list
57 * to replace the original segment list with. The line argument is
60 typedef GtkTextLineSegment* (*GtkTextSegCleanupFunc) (GtkTextLineSegment *seg,
63 /* Called when a segment moves from one line to another. CleanupFunc is also
64 * called in that case, so many segments just use CleanupFunc, I'm not sure
65 * what's up with that (this function may not be needed...)
67 typedef void (*GtkTextSegLineChangeFunc) (GtkTextLineSegment *seg,
70 /* Called to do debug checks on the segment. */
71 typedef void (*GtkTextSegCheckFunc) (GtkTextLineSegment *seg,
74 struct _GtkTextLineSegmentClass {
75 char *name; /* Name of this kind of segment. */
76 gboolean leftGravity; /* If a segment has zero size (e.g. a
77 * mark or tag toggle), does it
78 * attach to character to its left
79 * or right? 1 means left, 0 means
81 GtkTextSegSplitFunc splitFunc; /* Procedure to split large segment
82 * into two smaller ones. */
83 GtkTextSegDeleteFunc deleteFunc; /* Procedure to call to delete
85 GtkTextSegCleanupFunc cleanupFunc; /* After any change to a line, this
86 * procedure is invoked for all
87 * segments left in the line to
88 * perform any cleanup they wish
89 * (e.g. joining neighboring
91 GtkTextSegLineChangeFunc lineChangeFunc;
92 /* Invoked when a segment is about
93 * to be moved from its current line
94 * to an earlier line because of
95 * a deletion. The line is that
96 * for the segment's old line.
97 * CleanupFunc will be invoked after
98 * the deletion is finished. */
100 GtkTextSegCheckFunc checkFunc; /* Called during consistency checks
101 * to check internal consistency of
106 * The data structure below defines line segments.
109 struct _GtkTextLineSegment {
110 GtkTextLineSegmentClass *type; /* Pointer to record describing
112 GtkTextLineSegment *next; /* Next in list of segments for this
113 * line, or NULL for end of list. */
115 int char_count; /* # of chars of index space occupied */
117 int byte_count; /* Size of this segment (# of bytes
118 * of index space it occupies). */
120 char chars[4]; /* Characters that make up character
121 * info. Actual length varies to
122 * hold as many characters as needed.*/
123 GtkTextToggleBody toggle; /* Information about tag toggle. */
124 GtkTextMarkBody mark; /* Information about mark. */
125 GtkTextPixbuf pixbuf; /* Child pixbuf */
126 GtkTextChildBody child; /* Child widget */
131 GtkTextLineSegment *gtk_text_line_segment_split (const GtkTextIter *iter);
133 GtkTextLineSegment *_gtk_char_segment_new (const gchar *text,
135 GtkTextLineSegment *_gtk_char_segment_new_from_two_strings (const gchar *text1,
139 GtkTextLineSegment *_gtk_toggle_segment_new (GtkTextTagInfo *info,
145 #endif /* __cplusplus */