1 /* GTK - The GIMP Toolkit
2 * gtktextbtree.h Copyright (C) 2000 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 #ifndef __GTK_TEXT_BTREE_H__
26 #define __GTK_TEXT_BTREE_H__
29 #define DEBUG_VALIDATION_AND_SCROLLING
32 #ifdef DEBUG_VALIDATION_AND_SCROLLING
38 #include <gtk/gtktextbuffer.h>
39 #include <gtk/gtktexttag.h>
40 #include <gtk/gtktextmark.h>
41 #include <gtk/gtktextchild.h>
42 #include <gtk/gtktextsegment.h>
43 #include <gtk/gtktextiter.h>
47 GtkTextBTree *_gtk_text_btree_new (GtkTextTagTable *table,
48 GtkTextBuffer *buffer);
49 void _gtk_text_btree_ref (GtkTextBTree *tree);
50 void _gtk_text_btree_unref (GtkTextBTree *tree);
51 GtkTextBuffer *_gtk_text_btree_get_buffer (GtkTextBTree *tree);
54 guint _gtk_text_btree_get_chars_changed_stamp (GtkTextBTree *tree);
55 guint _gtk_text_btree_get_segments_changed_stamp (GtkTextBTree *tree);
56 void _gtk_text_btree_segments_changed (GtkTextBTree *tree);
58 gboolean _gtk_text_btree_is_end (GtkTextBTree *tree,
60 GtkTextLineSegment *seg,
64 /* Indexable segment mutation */
66 void _gtk_text_btree_delete (GtkTextIter *start,
68 void _gtk_text_btree_insert (GtkTextIter *iter,
71 void _gtk_text_btree_insert_pixbuf (GtkTextIter *iter,
74 void _gtk_text_btree_insert_child_anchor (GtkTextIter *iter,
75 GtkTextChildAnchor *anchor);
77 void _gtk_text_btree_unregister_child_anchor (GtkTextChildAnchor *anchor);
80 GtkTextLine *_gtk_text_btree_find_line_by_y (GtkTextBTree *tree,
84 gint _gtk_text_btree_find_line_top (GtkTextBTree *tree,
87 void _gtk_text_btree_add_view (GtkTextBTree *tree,
88 GtkTextLayout *layout);
89 void _gtk_text_btree_remove_view (GtkTextBTree *tree,
91 void _gtk_text_btree_invalidate_region (GtkTextBTree *tree,
92 const GtkTextIter *start,
93 const GtkTextIter *end,
94 gboolean cursors_only);
95 void _gtk_text_btree_get_view_size (GtkTextBTree *tree,
99 gboolean _gtk_text_btree_is_valid (GtkTextBTree *tree,
101 gboolean _gtk_text_btree_validate (GtkTextBTree *tree,
107 void _gtk_text_btree_validate_line (GtkTextBTree *tree,
113 void _gtk_text_btree_tag (const GtkTextIter *start,
114 const GtkTextIter *end,
120 GtkTextLine * _gtk_text_btree_get_line (GtkTextBTree *tree,
122 gint *real_line_number);
123 GtkTextLine * _gtk_text_btree_get_line_no_last (GtkTextBTree *tree,
125 gint *real_line_number);
126 GtkTextLine * _gtk_text_btree_get_end_iter_line (GtkTextBTree *tree);
127 GtkTextLine * _gtk_text_btree_get_line_at_char (GtkTextBTree *tree,
129 gint *line_start_index,
130 gint *real_char_index);
131 GtkTextTag** _gtk_text_btree_get_tags (const GtkTextIter *iter,
133 gchar *_gtk_text_btree_get_text (const GtkTextIter *start,
134 const GtkTextIter *end,
135 gboolean include_hidden,
136 gboolean include_nonchars);
137 gint _gtk_text_btree_line_count (GtkTextBTree *tree);
138 gint _gtk_text_btree_char_count (GtkTextBTree *tree);
139 gboolean _gtk_text_btree_char_is_invisible (const GtkTextIter *iter);
143 /* Get iterators (these are implemented in gtktextiter.c) */
144 void _gtk_text_btree_get_iter_at_char (GtkTextBTree *tree,
147 void _gtk_text_btree_get_iter_at_line_char (GtkTextBTree *tree,
151 void _gtk_text_btree_get_iter_at_line_byte (GtkTextBTree *tree,
155 gboolean _gtk_text_btree_get_iter_from_string (GtkTextBTree *tree,
157 const gchar *string);
158 gboolean _gtk_text_btree_get_iter_at_mark_name (GtkTextBTree *tree,
160 const gchar *mark_name);
161 void _gtk_text_btree_get_iter_at_mark (GtkTextBTree *tree,
164 void _gtk_text_btree_get_end_iter (GtkTextBTree *tree,
166 void _gtk_text_btree_get_iter_at_line (GtkTextBTree *tree,
170 gboolean _gtk_text_btree_get_iter_at_first_toggle (GtkTextBTree *tree,
173 gboolean _gtk_text_btree_get_iter_at_last_toggle (GtkTextBTree *tree,
177 void _gtk_text_btree_get_iter_at_child_anchor (GtkTextBTree *tree,
179 GtkTextChildAnchor *anchor);
183 /* Manipulate marks */
184 GtkTextMark *_gtk_text_btree_set_mark (GtkTextBTree *tree,
185 GtkTextMark *existing_mark,
187 gboolean left_gravity,
188 const GtkTextIter *index,
189 gboolean should_exist);
190 void _gtk_text_btree_remove_mark_by_name (GtkTextBTree *tree,
192 void _gtk_text_btree_remove_mark (GtkTextBTree *tree,
193 GtkTextMark *segment);
194 gboolean _gtk_text_btree_get_selection_bounds (GtkTextBTree *tree,
197 void _gtk_text_btree_place_cursor (GtkTextBTree *tree,
198 const GtkTextIter *where);
199 void _gtk_text_btree_select_range (GtkTextBTree *tree,
200 const GtkTextIter *ins,
201 const GtkTextIter *bound);
202 gboolean _gtk_text_btree_mark_is_insert (GtkTextBTree *tree,
203 GtkTextMark *segment);
204 gboolean _gtk_text_btree_mark_is_selection_bound (GtkTextBTree *tree,
205 GtkTextMark *segment);
206 GtkTextMark *_gtk_text_btree_get_insert (GtkTextBTree *tree);
207 GtkTextMark *_gtk_text_btree_get_selection_bound (GtkTextBTree *tree);
208 GtkTextMark *_gtk_text_btree_get_mark_by_name (GtkTextBTree *tree,
210 GtkTextLine * _gtk_text_btree_first_could_contain_tag (GtkTextBTree *tree,
212 GtkTextLine * _gtk_text_btree_last_could_contain_tag (GtkTextBTree *tree,
217 /* Chunk of data associated with a line; views can use this to store
218 info at the line. They should "subclass" the header struct here. */
219 struct _GtkTextLineData {
221 GtkTextLineData *next;
223 signed int width : 24;
224 guint valid : 8; /* Actually a boolean */
228 * The data structure below defines a single line of text (from newline
229 * to newline, not necessarily what appears on one line of the screen).
231 * You can consider this line a "paragraph" also
234 struct _GtkTextLine {
235 GtkTextBTreeNode *parent; /* Pointer to parent node containing
237 GtkTextLine *next; /* Next in linked list of lines with
238 * same parent node in B-tree. NULL
239 * means end of list. */
240 GtkTextLineSegment *segments; /* First in ordered list of segments
241 * that make up the line. */
242 GtkTextLineData *views; /* data stored here by views */
243 guchar dir_strong; /* BiDi algo dir of line */
244 guchar dir_propagated_back; /* BiDi algo dir of next line */
245 guchar dir_propagated_forward; /* BiDi algo dir of prev line */
249 gint _gtk_text_line_get_number (GtkTextLine *line);
250 gboolean _gtk_text_line_char_has_tag (GtkTextLine *line,
254 gboolean _gtk_text_line_byte_has_tag (GtkTextLine *line,
258 gboolean _gtk_text_line_is_last (GtkTextLine *line,
260 gboolean _gtk_text_line_contains_end_iter (GtkTextLine *line,
262 GtkTextLine * _gtk_text_line_next (GtkTextLine *line);
263 GtkTextLine * _gtk_text_line_next_excluding_last (GtkTextLine *line);
264 GtkTextLine * _gtk_text_line_previous (GtkTextLine *line);
265 void _gtk_text_line_add_data (GtkTextLine *line,
266 GtkTextLineData *data);
267 gpointer _gtk_text_line_remove_data (GtkTextLine *line,
269 gpointer _gtk_text_line_get_data (GtkTextLine *line,
271 void _gtk_text_line_invalidate_wrap (GtkTextLine *line,
272 GtkTextLineData *ld);
273 gint _gtk_text_line_char_count (GtkTextLine *line);
274 gint _gtk_text_line_byte_count (GtkTextLine *line);
275 gint _gtk_text_line_char_index (GtkTextLine *line);
276 GtkTextLineSegment *_gtk_text_line_byte_to_segment (GtkTextLine *line,
279 GtkTextLineSegment *_gtk_text_line_char_to_segment (GtkTextLine *line,
282 gboolean _gtk_text_line_byte_locate (GtkTextLine *line,
284 GtkTextLineSegment **segment,
285 GtkTextLineSegment **any_segment,
286 gint *seg_byte_offset,
287 gint *line_byte_offset);
288 gboolean _gtk_text_line_char_locate (GtkTextLine *line,
290 GtkTextLineSegment **segment,
291 GtkTextLineSegment **any_segment,
292 gint *seg_char_offset,
293 gint *line_char_offset);
294 void _gtk_text_line_byte_to_char_offsets (GtkTextLine *line,
296 gint *line_char_offset,
297 gint *seg_char_offset);
298 void _gtk_text_line_char_to_byte_offsets (GtkTextLine *line,
300 gint *line_byte_offset,
301 gint *seg_byte_offset);
302 GtkTextLineSegment *_gtk_text_line_byte_to_any_segment (GtkTextLine *line,
305 GtkTextLineSegment *_gtk_text_line_char_to_any_segment (GtkTextLine *line,
308 gint _gtk_text_line_byte_to_char (GtkTextLine *line,
310 gint _gtk_text_line_char_to_byte (GtkTextLine *line,
312 GtkTextLine * _gtk_text_line_next_could_contain_tag (GtkTextLine *line,
315 GtkTextLine * _gtk_text_line_previous_could_contain_tag (GtkTextLine *line,
319 GtkTextLineData *_gtk_text_line_data_new (GtkTextLayout *layout,
323 void _gtk_text_btree_check (GtkTextBTree *tree);
324 void _gtk_text_btree_spew (GtkTextBTree *tree);
325 extern gboolean _gtk_text_view_debug_btree;
327 /* ignore, exported only for gtktextsegment.c */
328 void _gtk_toggle_segment_check_func (GtkTextLineSegment *segPtr,
330 void _gtk_change_node_toggle_count (GtkTextBTreeNode *node,
331 GtkTextTagInfo *info,
334 /* for gtktextmark.c */
335 void _gtk_text_btree_release_mark_segment (GtkTextBTree *tree,
336 GtkTextLineSegment *segment);
338 /* for coordination with the tag table */
339 void _gtk_text_btree_notify_will_remove_tag (GtkTextBTree *tree,