]> Pileus Git - ~andy/gtk/blob - gtk/gtktextsegment.h
Include files outside of the extern "C" block. Makes some C++ compiler
[~andy/gtk] / gtk / gtktextsegment.h
1 #ifndef GTK_TEXT_SEGMENT_H
2 #define GTK_TEXT_SEGMENT_H
3
4 #include <gtk/gtktexttag.h>
5 #include <gtk/gtktextiter.h>
6 #include <gtk/gtktextmarkprivate.h>
7 #include <gtk/gtktextchild.h>
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif /* __cplusplus */
12
13 /*
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.
18  */
19
20 /* This header has the segment type, and two specific segments
21    (character and toggle segments) */
22
23 /* Information a BTree stores about a tag. */
24 typedef struct _GtkTextTagInfo GtkTextTagInfo;
25 struct _GtkTextTagInfo {
26   GtkTextTag *tag;
27   GtkTextBTreeNode *tag_root; /* highest-level node containing the tag */
28   gint toggle_count;      /* total toggles of this tag below tag_root */
29 };
30
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. */
37 };
38
39
40 /* Class struct for segments */
41
42 typedef GtkTextLineSegment *(* GtkTextLineSegmentSplitFunc)      (GtkTextLineSegment *segPtr,
43                                                         int index);
44 typedef gboolean         (* GtkTextViewSegDeleteFunc)     (GtkTextLineSegment *segPtr,
45                                                         GtkTextLine *line,
46                                                         gboolean treeGone);
47 typedef GtkTextLineSegment *(* GtkTextViewSegCleanupFunc)    (GtkTextLineSegment *segPtr,
48                                                         GtkTextLine *line);
49 typedef void             (* GtkTextLineSegmentLineChangeFunc) (GtkTextLineSegment *segPtr,
50                                                         GtkTextLine *line);
51 typedef void             (* GtkTextViewSegCheckFunc)      (GtkTextLineSegment *segPtr,
52                                                         GtkTextLine *line);
53
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
60                                          * right. */
61   GtkTextLineSegmentSplitFunc splitFunc;       /* Procedure to split large segment
62                                          * into two smaller ones. */
63   GtkTextViewSegDeleteFunc deleteFunc;     /* Procedure to call to delete
64                                          * segment. */
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
70                                          * segments). */
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. */
79
80   GtkTextViewSegCheckFunc checkFunc;       /* Called during consistency checks
81                                          * to check internal consistency of
82                                          * segment. */
83 };
84
85 /*
86  * The data structure below defines line segments.
87  */
88
89 struct _GtkTextLineSegment {
90   GtkTextLineSegmentClass *type;                /* Pointer to record describing
91                                          * segment's type. */
92   GtkTextLineSegment *next;                /* Next in list of segments for this
93                                          * line, or NULL for end of list. */
94
95   int char_count;                       /* # of chars of index space occupied */
96   
97   int byte_count;                       /* Size of this segment (# of bytes
98                                          * of index space it occupies). */
99   union {
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 */
106 #if 0
107     GtkTextChild child;                /* child widget */
108 #endif
109   } body;
110 };
111
112
113 GtkTextLineSegment  *gtk_text_line_segment_split(const GtkTextIter *iter);
114
115 GtkTextLineSegment *char_segment_new(const gchar *text, guint len);
116
117 GtkTextLineSegment *char_segment_new_from_two_strings(const gchar *text1, guint len1,
118                                                    const gchar *text2, guint len2);
119
120 GtkTextLineSegment *toggle_segment_new(GtkTextTagInfo *info, gboolean on);
121
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125
126 #endif
127
128