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 | |
36 | G_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 | */ |
53 | typedef 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 | |
66 | typedef struct _GtkTextBuffer GtkTextBuffer; |
67 | |
68 | #define GTK_TYPE_TEXT_ITER (gtk_text_iter_get_type ()) |
69 | |
70 | struct _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. */ |
96 | GDK_AVAILABLE_IN_ALL |
97 | GtkTextBuffer *gtk_text_iter_get_buffer (const GtkTextIter *iter); |
98 | |
99 | /* |
100 | * Life cycle |
101 | */ |
102 | |
103 | GDK_AVAILABLE_IN_ALL |
104 | GtkTextIter *gtk_text_iter_copy (const GtkTextIter *iter); |
105 | GDK_AVAILABLE_IN_ALL |
106 | void gtk_text_iter_free (GtkTextIter *iter); |
107 | GDK_AVAILABLE_IN_3_2 |
108 | void gtk_text_iter_assign (GtkTextIter *iter, |
109 | const GtkTextIter *other); |
110 | |
111 | GDK_AVAILABLE_IN_ALL |
112 | GType gtk_text_iter_get_type (void) G_GNUC_CONST; |
113 | |
114 | /* |
115 | * Convert to different kinds of index |
116 | */ |
117 | |
118 | GDK_AVAILABLE_IN_ALL |
119 | gint gtk_text_iter_get_offset (const GtkTextIter *iter); |
120 | GDK_AVAILABLE_IN_ALL |
121 | gint gtk_text_iter_get_line (const GtkTextIter *iter); |
122 | GDK_AVAILABLE_IN_ALL |
123 | gint gtk_text_iter_get_line_offset (const GtkTextIter *iter); |
124 | GDK_AVAILABLE_IN_ALL |
125 | gint gtk_text_iter_get_line_index (const GtkTextIter *iter); |
126 | |
127 | GDK_AVAILABLE_IN_ALL |
128 | gint gtk_text_iter_get_visible_line_offset (const GtkTextIter *iter); |
129 | GDK_AVAILABLE_IN_ALL |
130 | gint gtk_text_iter_get_visible_line_index (const GtkTextIter *iter); |
131 | |
132 | |
133 | /* |
134 | * “Dereference” operators |
135 | */ |
136 | GDK_AVAILABLE_IN_ALL |
137 | gunichar 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 | */ |
142 | GDK_AVAILABLE_IN_ALL |
143 | gchar *gtk_text_iter_get_slice (const GtkTextIter *start, |
144 | const GtkTextIter *end); |
145 | |
146 | /* includes only text, no 0xFFFC */ |
147 | GDK_AVAILABLE_IN_ALL |
148 | gchar *gtk_text_iter_get_text (const GtkTextIter *start, |
149 | const GtkTextIter *end); |
150 | /* exclude invisible chars */ |
151 | GDK_AVAILABLE_IN_ALL |
152 | gchar *gtk_text_iter_get_visible_slice (const GtkTextIter *start, |
153 | const GtkTextIter *end); |
154 | GDK_AVAILABLE_IN_ALL |
155 | gchar *gtk_text_iter_get_visible_text (const GtkTextIter *start, |
156 | const GtkTextIter *end); |
157 | |
158 | GDK_AVAILABLE_IN_ALL |
159 | GdkPixbuf* gtk_text_iter_get_pixbuf (const GtkTextIter *iter); |
160 | GDK_AVAILABLE_IN_ALL |
161 | GSList * gtk_text_iter_get_marks (const GtkTextIter *iter); |
162 | |
163 | GDK_AVAILABLE_IN_ALL |
164 | GtkTextChildAnchor* 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 | */ |
169 | GDK_AVAILABLE_IN_ALL |
170 | GSList *gtk_text_iter_get_toggled_tags (const GtkTextIter *iter, |
171 | gboolean toggled_on); |
172 | |
173 | GDK_AVAILABLE_IN_3_20 |
174 | gboolean gtk_text_iter_starts_tag (const GtkTextIter *iter, |
175 | GtkTextTag *tag); |
176 | |
177 | GDK_DEPRECATED_IN_3_20_FOR(gtk_text_iter_starts_tag) |
178 | gboolean gtk_text_iter_begins_tag (const GtkTextIter *iter, |
179 | GtkTextTag *tag); |
180 | |
181 | GDK_AVAILABLE_IN_ALL |
182 | gboolean gtk_text_iter_ends_tag (const GtkTextIter *iter, |
183 | GtkTextTag *tag); |
184 | |
185 | GDK_AVAILABLE_IN_ALL |
186 | gboolean gtk_text_iter_toggles_tag (const GtkTextIter *iter, |
187 | GtkTextTag *tag); |
188 | |
189 | GDK_AVAILABLE_IN_ALL |
190 | gboolean gtk_text_iter_has_tag (const GtkTextIter *iter, |
191 | GtkTextTag *tag); |
192 | GDK_AVAILABLE_IN_ALL |
193 | GSList *gtk_text_iter_get_tags (const GtkTextIter *iter); |
194 | |
195 | GDK_AVAILABLE_IN_ALL |
196 | gboolean gtk_text_iter_editable (const GtkTextIter *iter, |
197 | gboolean default_setting); |
198 | GDK_AVAILABLE_IN_ALL |
199 | gboolean gtk_text_iter_can_insert (const GtkTextIter *iter, |
200 | gboolean default_editability); |
201 | |
202 | GDK_AVAILABLE_IN_ALL |
203 | gboolean gtk_text_iter_starts_word (const GtkTextIter *iter); |
204 | GDK_AVAILABLE_IN_ALL |
205 | gboolean gtk_text_iter_ends_word (const GtkTextIter *iter); |
206 | GDK_AVAILABLE_IN_ALL |
207 | gboolean gtk_text_iter_inside_word (const GtkTextIter *iter); |
208 | GDK_AVAILABLE_IN_ALL |
209 | gboolean gtk_text_iter_starts_sentence (const GtkTextIter *iter); |
210 | GDK_AVAILABLE_IN_ALL |
211 | gboolean gtk_text_iter_ends_sentence (const GtkTextIter *iter); |
212 | GDK_AVAILABLE_IN_ALL |
213 | gboolean gtk_text_iter_inside_sentence (const GtkTextIter *iter); |
214 | GDK_AVAILABLE_IN_ALL |
215 | gboolean gtk_text_iter_starts_line (const GtkTextIter *iter); |
216 | GDK_AVAILABLE_IN_ALL |
217 | gboolean gtk_text_iter_ends_line (const GtkTextIter *iter); |
218 | GDK_AVAILABLE_IN_ALL |
219 | gboolean gtk_text_iter_is_cursor_position (const GtkTextIter *iter); |
220 | |
221 | GDK_AVAILABLE_IN_ALL |
222 | gint gtk_text_iter_get_chars_in_line (const GtkTextIter *iter); |
223 | GDK_AVAILABLE_IN_ALL |
224 | gint gtk_text_iter_get_bytes_in_line (const GtkTextIter *iter); |
225 | |
226 | GDK_AVAILABLE_IN_ALL |
227 | gboolean gtk_text_iter_get_attributes (const GtkTextIter *iter, |
228 | GtkTextAttributes *values); |
229 | GDK_AVAILABLE_IN_ALL |
230 | PangoLanguage* gtk_text_iter_get_language (const GtkTextIter *iter); |
231 | GDK_AVAILABLE_IN_ALL |
232 | gboolean gtk_text_iter_is_end (const GtkTextIter *iter); |
233 | GDK_AVAILABLE_IN_ALL |
234 | gboolean gtk_text_iter_is_start (const GtkTextIter *iter); |
235 | |
236 | /* |
237 | * Moving around the buffer |
238 | */ |
239 | |
240 | GDK_AVAILABLE_IN_ALL |
241 | gboolean gtk_text_iter_forward_char (GtkTextIter *iter); |
242 | GDK_AVAILABLE_IN_ALL |
243 | gboolean gtk_text_iter_backward_char (GtkTextIter *iter); |
244 | GDK_AVAILABLE_IN_ALL |
245 | gboolean gtk_text_iter_forward_chars (GtkTextIter *iter, |
246 | gint count); |
247 | GDK_AVAILABLE_IN_ALL |
248 | gboolean gtk_text_iter_backward_chars (GtkTextIter *iter, |
249 | gint count); |
250 | GDK_AVAILABLE_IN_ALL |
251 | gboolean gtk_text_iter_forward_line (GtkTextIter *iter); |
252 | GDK_AVAILABLE_IN_ALL |
253 | gboolean gtk_text_iter_backward_line (GtkTextIter *iter); |
254 | GDK_AVAILABLE_IN_ALL |
255 | gboolean gtk_text_iter_forward_lines (GtkTextIter *iter, |
256 | gint count); |
257 | GDK_AVAILABLE_IN_ALL |
258 | gboolean gtk_text_iter_backward_lines (GtkTextIter *iter, |
259 | gint count); |
260 | GDK_AVAILABLE_IN_ALL |
261 | gboolean gtk_text_iter_forward_word_end (GtkTextIter *iter); |
262 | GDK_AVAILABLE_IN_ALL |
263 | gboolean gtk_text_iter_backward_word_start (GtkTextIter *iter); |
264 | GDK_AVAILABLE_IN_ALL |
265 | gboolean gtk_text_iter_forward_word_ends (GtkTextIter *iter, |
266 | gint count); |
267 | GDK_AVAILABLE_IN_ALL |
268 | gboolean gtk_text_iter_backward_word_starts (GtkTextIter *iter, |
269 | gint count); |
270 | |
271 | GDK_AVAILABLE_IN_ALL |
272 | gboolean gtk_text_iter_forward_visible_line (GtkTextIter *iter); |
273 | GDK_AVAILABLE_IN_ALL |
274 | gboolean gtk_text_iter_backward_visible_line (GtkTextIter *iter); |
275 | GDK_AVAILABLE_IN_ALL |
276 | gboolean gtk_text_iter_forward_visible_lines (GtkTextIter *iter, |
277 | gint count); |
278 | GDK_AVAILABLE_IN_ALL |
279 | gboolean gtk_text_iter_backward_visible_lines (GtkTextIter *iter, |
280 | gint count); |
281 | |
282 | GDK_AVAILABLE_IN_ALL |
283 | gboolean gtk_text_iter_forward_visible_word_end (GtkTextIter *iter); |
284 | GDK_AVAILABLE_IN_ALL |
285 | gboolean gtk_text_iter_backward_visible_word_start (GtkTextIter *iter); |
286 | GDK_AVAILABLE_IN_ALL |
287 | gboolean gtk_text_iter_forward_visible_word_ends (GtkTextIter *iter, |
288 | gint count); |
289 | GDK_AVAILABLE_IN_ALL |
290 | gboolean gtk_text_iter_backward_visible_word_starts (GtkTextIter *iter, |
291 | gint count); |
292 | |
293 | GDK_AVAILABLE_IN_ALL |
294 | gboolean gtk_text_iter_forward_sentence_end (GtkTextIter *iter); |
295 | GDK_AVAILABLE_IN_ALL |
296 | gboolean gtk_text_iter_backward_sentence_start (GtkTextIter *iter); |
297 | GDK_AVAILABLE_IN_ALL |
298 | gboolean gtk_text_iter_forward_sentence_ends (GtkTextIter *iter, |
299 | gint count); |
300 | GDK_AVAILABLE_IN_ALL |
301 | gboolean 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 | */ |
308 | GDK_AVAILABLE_IN_ALL |
309 | gboolean gtk_text_iter_forward_cursor_position (GtkTextIter *iter); |
310 | GDK_AVAILABLE_IN_ALL |
311 | gboolean gtk_text_iter_backward_cursor_position (GtkTextIter *iter); |
312 | GDK_AVAILABLE_IN_ALL |
313 | gboolean gtk_text_iter_forward_cursor_positions (GtkTextIter *iter, |
314 | gint count); |
315 | GDK_AVAILABLE_IN_ALL |
316 | gboolean gtk_text_iter_backward_cursor_positions (GtkTextIter *iter, |
317 | gint count); |
318 | |
319 | GDK_AVAILABLE_IN_ALL |
320 | gboolean gtk_text_iter_forward_visible_cursor_position (GtkTextIter *iter); |
321 | GDK_AVAILABLE_IN_ALL |
322 | gboolean gtk_text_iter_backward_visible_cursor_position (GtkTextIter *iter); |
323 | GDK_AVAILABLE_IN_ALL |
324 | gboolean gtk_text_iter_forward_visible_cursor_positions (GtkTextIter *iter, |
325 | gint count); |
326 | GDK_AVAILABLE_IN_ALL |
327 | gboolean gtk_text_iter_backward_visible_cursor_positions (GtkTextIter *iter, |
328 | gint count); |
329 | |
330 | GDK_AVAILABLE_IN_ALL |
331 | void gtk_text_iter_set_offset (GtkTextIter *iter, |
332 | gint char_offset); |
333 | GDK_AVAILABLE_IN_ALL |
334 | void gtk_text_iter_set_line (GtkTextIter *iter, |
335 | gint line_number); |
336 | GDK_AVAILABLE_IN_ALL |
337 | void gtk_text_iter_set_line_offset (GtkTextIter *iter, |
338 | gint char_on_line); |
339 | GDK_AVAILABLE_IN_ALL |
340 | void gtk_text_iter_set_line_index (GtkTextIter *iter, |
341 | gint byte_on_line); |
342 | GDK_AVAILABLE_IN_ALL |
343 | void gtk_text_iter_forward_to_end (GtkTextIter *iter); |
344 | GDK_AVAILABLE_IN_ALL |
345 | gboolean gtk_text_iter_forward_to_line_end (GtkTextIter *iter); |
346 | |
347 | GDK_AVAILABLE_IN_ALL |
348 | void gtk_text_iter_set_visible_line_offset (GtkTextIter *iter, |
349 | gint char_on_line); |
350 | GDK_AVAILABLE_IN_ALL |
351 | void 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 | */ |
358 | GDK_AVAILABLE_IN_ALL |
359 | gboolean gtk_text_iter_forward_to_tag_toggle (GtkTextIter *iter, |
360 | GtkTextTag *tag); |
361 | |
362 | GDK_AVAILABLE_IN_ALL |
363 | gboolean gtk_text_iter_backward_to_tag_toggle (GtkTextIter *iter, |
364 | GtkTextTag *tag); |
365 | |
366 | typedef gboolean (* GtkTextCharPredicate) (gunichar ch, gpointer user_data); |
367 | |
368 | GDK_AVAILABLE_IN_ALL |
369 | gboolean gtk_text_iter_forward_find_char (GtkTextIter *iter, |
370 | GtkTextCharPredicate pred, |
371 | gpointer user_data, |
372 | const GtkTextIter *limit); |
373 | GDK_AVAILABLE_IN_ALL |
374 | gboolean gtk_text_iter_backward_find_char (GtkTextIter *iter, |
375 | GtkTextCharPredicate pred, |
376 | gpointer user_data, |
377 | const GtkTextIter *limit); |
378 | |
379 | GDK_AVAILABLE_IN_ALL |
380 | gboolean 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 | |
387 | GDK_AVAILABLE_IN_ALL |
388 | gboolean 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 | */ |
398 | GDK_AVAILABLE_IN_ALL |
399 | gboolean gtk_text_iter_equal (const GtkTextIter *lhs, |
400 | const GtkTextIter *rhs); |
401 | GDK_AVAILABLE_IN_ALL |
402 | gint gtk_text_iter_compare (const GtkTextIter *lhs, |
403 | const GtkTextIter *rhs); |
404 | GDK_AVAILABLE_IN_ALL |
405 | gboolean gtk_text_iter_in_range (const GtkTextIter *iter, |
406 | const GtkTextIter *start, |
407 | const GtkTextIter *end); |
408 | |
409 | /* Put these two in ascending order */ |
410 | GDK_AVAILABLE_IN_ALL |
411 | void gtk_text_iter_order (GtkTextIter *first, |
412 | GtkTextIter *second); |
413 | |
414 | G_END_DECLS |
415 | |
416 | #endif |
417 | |