1/* GTK - The GIMP Toolkit
2 * gtktextiter.h Copyright (C) 2000 Red Hat, Inc.
3 *
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.
8 *
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.
13 *
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/>.
16 */
17
18/*
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/.
23 */
24
25#ifndef __GTK_TEXT_ITER_H__
26#define __GTK_TEXT_ITER_H__
27
28#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29#error "Only <gtk/gtk.h> can be included directly."
30#endif
31
32#include <gtk/gtktextattributes.h>
33#include <gtk/gtktextchild.h>
34#include <gtk/gtktexttag.h>
35
36G_BEGIN_DECLS
37
38/**
39 * GtkTextSearchFlags:
40 * @GTK_TEXT_SEARCH_VISIBLE_ONLY: Search only visible data. A search match may
41 * have invisible text interspersed.
42 * @GTK_TEXT_SEARCH_TEXT_ONLY: Search only text. A match may have pixbufs or
43 * child widgets mixed inside the matched range.
44 * @GTK_TEXT_SEARCH_CASE_INSENSITIVE: The text will be matched regardless of
45 * what case it is in.
46 *
47 * Flags affecting how a search is done.
48 *
49 * If neither #GTK_TEXT_SEARCH_VISIBLE_ONLY nor #GTK_TEXT_SEARCH_TEXT_ONLY are
50 * enabled, the match must be exact; the special 0xFFFC character will match
51 * embedded pixbufs or child widgets.
52 */
53typedef enum {
54 GTK_TEXT_SEARCH_VISIBLE_ONLY = 1 << 0,
55 GTK_TEXT_SEARCH_TEXT_ONLY = 1 << 1,
56 GTK_TEXT_SEARCH_CASE_INSENSITIVE = 1 << 2
57 /* Possible future plans: SEARCH_REGEXP */
58} GtkTextSearchFlags;
59
60/*
61 * Iter: represents a location in the text. Becomes invalid if the
62 * characters/pixmaps/widgets (indexable objects) in the text buffer
63 * are changed.
64 */
65
66typedef struct _GtkTextBuffer GtkTextBuffer;
67
68#define GTK_TYPE_TEXT_ITER (gtk_text_iter_get_type ())
69
70struct _GtkTextIter {
71 /* GtkTextIter is an opaque datatype; ignore all these fields.
72 * Initialize the iter with gtk_text_buffer_get_iter_*
73 * functions
74 */
75 /*< private >*/
76 gpointer dummy1;
77 gpointer dummy2;
78 gint dummy3;
79 gint dummy4;
80 gint dummy5;
81 gint dummy6;
82 gint dummy7;
83 gint dummy8;
84 gpointer dummy9;
85 gpointer dummy10;
86 gint dummy11;
87 gint dummy12;
88 /* padding */
89 gint dummy13;
90 gpointer dummy14;
91};
92
93
94/* This is primarily intended for language bindings that want to avoid
95 a "buffer" argument to text insertions, deletions, etc. */
96GDK_AVAILABLE_IN_ALL
97GtkTextBuffer *gtk_text_iter_get_buffer (const GtkTextIter *iter);
98
99/*
100 * Life cycle
101 */
102
103GDK_AVAILABLE_IN_ALL
104GtkTextIter *gtk_text_iter_copy (const GtkTextIter *iter);
105GDK_AVAILABLE_IN_ALL
106void gtk_text_iter_free (GtkTextIter *iter);
107GDK_AVAILABLE_IN_3_2
108void gtk_text_iter_assign (GtkTextIter *iter,
109 const GtkTextIter *other);
110
111GDK_AVAILABLE_IN_ALL
112GType gtk_text_iter_get_type (void) G_GNUC_CONST;
113
114/*
115 * Convert to different kinds of index
116 */
117
118GDK_AVAILABLE_IN_ALL
119gint gtk_text_iter_get_offset (const GtkTextIter *iter);
120GDK_AVAILABLE_IN_ALL
121gint gtk_text_iter_get_line (const GtkTextIter *iter);
122GDK_AVAILABLE_IN_ALL
123gint gtk_text_iter_get_line_offset (const GtkTextIter *iter);
124GDK_AVAILABLE_IN_ALL
125gint gtk_text_iter_get_line_index (const GtkTextIter *iter);
126
127GDK_AVAILABLE_IN_ALL
128gint gtk_text_iter_get_visible_line_offset (const GtkTextIter *iter);
129GDK_AVAILABLE_IN_ALL
130gint gtk_text_iter_get_visible_line_index (const GtkTextIter *iter);
131
132
133/*
134 * “Dereference” operators
135 */
136GDK_AVAILABLE_IN_ALL
137gunichar gtk_text_iter_get_char (const GtkTextIter *iter);
138
139/* includes the 0xFFFC char for pixmaps/widgets, so char offsets
140 * into the returned string map properly into buffer char offsets
141 */
142GDK_AVAILABLE_IN_ALL
143gchar *gtk_text_iter_get_slice (const GtkTextIter *start,
144 const GtkTextIter *end);
145
146/* includes only text, no 0xFFFC */
147GDK_AVAILABLE_IN_ALL
148gchar *gtk_text_iter_get_text (const GtkTextIter *start,
149 const GtkTextIter *end);
150/* exclude invisible chars */
151GDK_AVAILABLE_IN_ALL
152gchar *gtk_text_iter_get_visible_slice (const GtkTextIter *start,
153 const GtkTextIter *end);
154GDK_AVAILABLE_IN_ALL
155gchar *gtk_text_iter_get_visible_text (const GtkTextIter *start,
156 const GtkTextIter *end);
157
158GDK_AVAILABLE_IN_ALL
159GdkPixbuf* gtk_text_iter_get_pixbuf (const GtkTextIter *iter);
160GDK_AVAILABLE_IN_ALL
161GSList * gtk_text_iter_get_marks (const GtkTextIter *iter);
162
163GDK_AVAILABLE_IN_ALL
164GtkTextChildAnchor* gtk_text_iter_get_child_anchor (const GtkTextIter *iter);
165
166/* Return list of tags toggled at this point (toggled_on determines
167 * whether the list is of on-toggles or off-toggles)
168 */
169GDK_AVAILABLE_IN_ALL
170GSList *gtk_text_iter_get_toggled_tags (const GtkTextIter *iter,
171 gboolean toggled_on);
172
173GDK_AVAILABLE_IN_3_20
174gboolean gtk_text_iter_starts_tag (const GtkTextIter *iter,
175 GtkTextTag *tag);
176
177GDK_DEPRECATED_IN_3_20_FOR(gtk_text_iter_starts_tag)
178gboolean gtk_text_iter_begins_tag (const GtkTextIter *iter,
179 GtkTextTag *tag);
180
181GDK_AVAILABLE_IN_ALL
182gboolean gtk_text_iter_ends_tag (const GtkTextIter *iter,
183 GtkTextTag *tag);
184
185GDK_AVAILABLE_IN_ALL
186gboolean gtk_text_iter_toggles_tag (const GtkTextIter *iter,
187 GtkTextTag *tag);
188
189GDK_AVAILABLE_IN_ALL
190gboolean gtk_text_iter_has_tag (const GtkTextIter *iter,
191 GtkTextTag *tag);
192GDK_AVAILABLE_IN_ALL
193GSList *gtk_text_iter_get_tags (const GtkTextIter *iter);
194
195GDK_AVAILABLE_IN_ALL
196gboolean gtk_text_iter_editable (const GtkTextIter *iter,
197 gboolean default_setting);
198GDK_AVAILABLE_IN_ALL
199gboolean gtk_text_iter_can_insert (const GtkTextIter *iter,
200 gboolean default_editability);
201
202GDK_AVAILABLE_IN_ALL
203gboolean gtk_text_iter_starts_word (const GtkTextIter *iter);
204GDK_AVAILABLE_IN_ALL
205gboolean gtk_text_iter_ends_word (const GtkTextIter *iter);
206GDK_AVAILABLE_IN_ALL
207gboolean gtk_text_iter_inside_word (const GtkTextIter *iter);
208GDK_AVAILABLE_IN_ALL
209gboolean gtk_text_iter_starts_sentence (const GtkTextIter *iter);
210GDK_AVAILABLE_IN_ALL
211gboolean gtk_text_iter_ends_sentence (const GtkTextIter *iter);
212GDK_AVAILABLE_IN_ALL
213gboolean gtk_text_iter_inside_sentence (const GtkTextIter *iter);
214GDK_AVAILABLE_IN_ALL
215gboolean gtk_text_iter_starts_line (const GtkTextIter *iter);
216GDK_AVAILABLE_IN_ALL
217gboolean gtk_text_iter_ends_line (const GtkTextIter *iter);
218GDK_AVAILABLE_IN_ALL
219gboolean gtk_text_iter_is_cursor_position (const GtkTextIter *iter);
220
221GDK_AVAILABLE_IN_ALL
222gint gtk_text_iter_get_chars_in_line (const GtkTextIter *iter);
223GDK_AVAILABLE_IN_ALL
224gint gtk_text_iter_get_bytes_in_line (const GtkTextIter *iter);
225
226GDK_AVAILABLE_IN_ALL
227gboolean gtk_text_iter_get_attributes (const GtkTextIter *iter,
228 GtkTextAttributes *values);
229GDK_AVAILABLE_IN_ALL
230PangoLanguage* gtk_text_iter_get_language (const GtkTextIter *iter);
231GDK_AVAILABLE_IN_ALL
232gboolean gtk_text_iter_is_end (const GtkTextIter *iter);
233GDK_AVAILABLE_IN_ALL
234gboolean gtk_text_iter_is_start (const GtkTextIter *iter);
235
236/*
237 * Moving around the buffer
238 */
239
240GDK_AVAILABLE_IN_ALL
241gboolean gtk_text_iter_forward_char (GtkTextIter *iter);
242GDK_AVAILABLE_IN_ALL
243gboolean gtk_text_iter_backward_char (GtkTextIter *iter);
244GDK_AVAILABLE_IN_ALL
245gboolean gtk_text_iter_forward_chars (GtkTextIter *iter,
246 gint count);
247GDK_AVAILABLE_IN_ALL
248gboolean gtk_text_iter_backward_chars (GtkTextIter *iter,
249 gint count);
250GDK_AVAILABLE_IN_ALL
251gboolean gtk_text_iter_forward_line (GtkTextIter *iter);
252GDK_AVAILABLE_IN_ALL
253gboolean gtk_text_iter_backward_line (GtkTextIter *iter);
254GDK_AVAILABLE_IN_ALL
255gboolean gtk_text_iter_forward_lines (GtkTextIter *iter,
256 gint count);
257GDK_AVAILABLE_IN_ALL
258gboolean gtk_text_iter_backward_lines (GtkTextIter *iter,
259 gint count);
260GDK_AVAILABLE_IN_ALL
261gboolean gtk_text_iter_forward_word_end (GtkTextIter *iter);
262GDK_AVAILABLE_IN_ALL
263gboolean gtk_text_iter_backward_word_start (GtkTextIter *iter);
264GDK_AVAILABLE_IN_ALL
265gboolean gtk_text_iter_forward_word_ends (GtkTextIter *iter,
266 gint count);
267GDK_AVAILABLE_IN_ALL
268gboolean gtk_text_iter_backward_word_starts (GtkTextIter *iter,
269 gint count);
270
271GDK_AVAILABLE_IN_ALL
272gboolean gtk_text_iter_forward_visible_line (GtkTextIter *iter);
273GDK_AVAILABLE_IN_ALL
274gboolean gtk_text_iter_backward_visible_line (GtkTextIter *iter);
275GDK_AVAILABLE_IN_ALL
276gboolean gtk_text_iter_forward_visible_lines (GtkTextIter *iter,
277 gint count);
278GDK_AVAILABLE_IN_ALL
279gboolean gtk_text_iter_backward_visible_lines (GtkTextIter *iter,
280 gint count);
281
282GDK_AVAILABLE_IN_ALL
283gboolean gtk_text_iter_forward_visible_word_end (GtkTextIter *iter);
284GDK_AVAILABLE_IN_ALL
285gboolean gtk_text_iter_backward_visible_word_start (GtkTextIter *iter);
286GDK_AVAILABLE_IN_ALL
287gboolean gtk_text_iter_forward_visible_word_ends (GtkTextIter *iter,
288 gint count);
289GDK_AVAILABLE_IN_ALL
290gboolean gtk_text_iter_backward_visible_word_starts (GtkTextIter *iter,
291 gint count);
292
293GDK_AVAILABLE_IN_ALL
294gboolean gtk_text_iter_forward_sentence_end (GtkTextIter *iter);
295GDK_AVAILABLE_IN_ALL
296gboolean gtk_text_iter_backward_sentence_start (GtkTextIter *iter);
297GDK_AVAILABLE_IN_ALL
298gboolean gtk_text_iter_forward_sentence_ends (GtkTextIter *iter,
299 gint count);
300GDK_AVAILABLE_IN_ALL
301gboolean gtk_text_iter_backward_sentence_starts (GtkTextIter *iter,
302 gint count);
303/* cursor positions are almost equivalent to chars, but not quite;
304 * in some languages, you can’t put the cursor between certain
305 * chars. Also, you can’t put the cursor between \r\n at the end
306 * of a line.
307 */
308GDK_AVAILABLE_IN_ALL
309gboolean gtk_text_iter_forward_cursor_position (GtkTextIter *iter);
310GDK_AVAILABLE_IN_ALL
311gboolean gtk_text_iter_backward_cursor_position (GtkTextIter *iter);
312GDK_AVAILABLE_IN_ALL
313gboolean gtk_text_iter_forward_cursor_positions (GtkTextIter *iter,
314 gint count);
315GDK_AVAILABLE_IN_ALL
316gboolean gtk_text_iter_backward_cursor_positions (GtkTextIter *iter,
317 gint count);
318
319GDK_AVAILABLE_IN_ALL
320gboolean gtk_text_iter_forward_visible_cursor_position (GtkTextIter *iter);
321GDK_AVAILABLE_IN_ALL
322gboolean gtk_text_iter_backward_visible_cursor_position (GtkTextIter *iter);
323GDK_AVAILABLE_IN_ALL
324gboolean gtk_text_iter_forward_visible_cursor_positions (GtkTextIter *iter,
325 gint count);
326GDK_AVAILABLE_IN_ALL
327gboolean gtk_text_iter_backward_visible_cursor_positions (GtkTextIter *iter,
328 gint count);
329
330GDK_AVAILABLE_IN_ALL
331void gtk_text_iter_set_offset (GtkTextIter *iter,
332 gint char_offset);
333GDK_AVAILABLE_IN_ALL
334void gtk_text_iter_set_line (GtkTextIter *iter,
335 gint line_number);
336GDK_AVAILABLE_IN_ALL
337void gtk_text_iter_set_line_offset (GtkTextIter *iter,
338 gint char_on_line);
339GDK_AVAILABLE_IN_ALL
340void gtk_text_iter_set_line_index (GtkTextIter *iter,
341 gint byte_on_line);
342GDK_AVAILABLE_IN_ALL
343void gtk_text_iter_forward_to_end (GtkTextIter *iter);
344GDK_AVAILABLE_IN_ALL
345gboolean gtk_text_iter_forward_to_line_end (GtkTextIter *iter);
346
347GDK_AVAILABLE_IN_ALL
348void gtk_text_iter_set_visible_line_offset (GtkTextIter *iter,
349 gint char_on_line);
350GDK_AVAILABLE_IN_ALL
351void gtk_text_iter_set_visible_line_index (GtkTextIter *iter,
352 gint byte_on_line);
353
354/* returns TRUE if a toggle was found; NULL for the tag pointer
355 * means “any tag toggle”, otherwise the next toggle of the
356 * specified tag is located.
357 */
358GDK_AVAILABLE_IN_ALL
359gboolean gtk_text_iter_forward_to_tag_toggle (GtkTextIter *iter,
360 GtkTextTag *tag);
361
362GDK_AVAILABLE_IN_ALL
363gboolean gtk_text_iter_backward_to_tag_toggle (GtkTextIter *iter,
364 GtkTextTag *tag);
365
366typedef gboolean (* GtkTextCharPredicate) (gunichar ch, gpointer user_data);
367
368GDK_AVAILABLE_IN_ALL
369gboolean gtk_text_iter_forward_find_char (GtkTextIter *iter,
370 GtkTextCharPredicate pred,
371 gpointer user_data,
372 const GtkTextIter *limit);
373GDK_AVAILABLE_IN_ALL
374gboolean gtk_text_iter_backward_find_char (GtkTextIter *iter,
375 GtkTextCharPredicate pred,
376 gpointer user_data,
377 const GtkTextIter *limit);
378
379GDK_AVAILABLE_IN_ALL
380gboolean gtk_text_iter_forward_search (const GtkTextIter *iter,
381 const gchar *str,
382 GtkTextSearchFlags flags,
383 GtkTextIter *match_start,
384 GtkTextIter *match_end,
385 const GtkTextIter *limit);
386
387GDK_AVAILABLE_IN_ALL
388gboolean gtk_text_iter_backward_search (const GtkTextIter *iter,
389 const gchar *str,
390 GtkTextSearchFlags flags,
391 GtkTextIter *match_start,
392 GtkTextIter *match_end,
393 const GtkTextIter *limit);
394
395/*
396 * Comparisons
397 */
398GDK_AVAILABLE_IN_ALL
399gboolean gtk_text_iter_equal (const GtkTextIter *lhs,
400 const GtkTextIter *rhs);
401GDK_AVAILABLE_IN_ALL
402gint gtk_text_iter_compare (const GtkTextIter *lhs,
403 const GtkTextIter *rhs);
404GDK_AVAILABLE_IN_ALL
405gboolean gtk_text_iter_in_range (const GtkTextIter *iter,
406 const GtkTextIter *start,
407 const GtkTextIter *end);
408
409/* Put these two in ascending order */
410GDK_AVAILABLE_IN_ALL
411void gtk_text_iter_order (GtkTextIter *first,
412 GtkTextIter *second);
413
414G_END_DECLS
415
416#endif
417

source code of include/gtk-3.0/gtk/gtktextiter.h