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