gtktextiter.h 9.71 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/* 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
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
13
14
15
16
17
18
19
20
21
22
23
 * 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, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*
 * 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
24
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25
26
 */

27
28
29
#ifndef GTK_TEXT_ITER_H
#define GTK_TEXT_ITER_H

30
#include <gtk/gtktexttag.h>
31
#include <gtk/gtktextchild.h>
32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/*
 * 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;

struct _GtkTextIter {
  gpointer dummy1;
  gpointer dummy2;
  gint dummy3;
  gint dummy4;
  gint dummy5;
  gint dummy6;
Havoc Pennington's avatar
Havoc Pennington committed
52
53
54
55
56
57
  gint dummy7;
  gint dummy8;
  gpointer dummy9;
  gpointer dummy10;
  gint dummy11;
  gint dummy12;
58
59
60
61
62
};


/* This is primarily intended for language bindings that want to avoid
   a "buffer" argument to text insertions, deletions, etc. */
63
GtkTextBuffer *gtk_text_iter_get_buffer (const GtkTextIter *iter);
64
65
66
67
68
69
70
71
72
73
74

/*
 * Life cycle
 */

GtkTextIter *gtk_text_iter_copy     (const GtkTextIter *iter);
void         gtk_text_iter_free     (GtkTextIter       *iter);

/*
 * Convert to different kinds of index
 */
75
76
77
78
79
80

gint gtk_text_iter_get_offset      (const GtkTextIter *iter);
gint gtk_text_iter_get_line        (const GtkTextIter *iter);
gint gtk_text_iter_get_line_offset (const GtkTextIter *iter);
gint gtk_text_iter_get_line_index  (const GtkTextIter *iter);

81
82
83
84

/*
 * "Dereference" operators
 */
85
gunichar gtk_text_iter_get_char          (const GtkTextIter  *iter);
86

Havoc Pennington's avatar
Havoc Pennington committed
87
88
89
/* includes the 0xFFFC char for pixmaps/widgets, so char offsets
 * into the returned string map properly into buffer char offsets
 */
90
gchar   *gtk_text_iter_get_slice         (const GtkTextIter  *start,
91
                                          const GtkTextIter  *end);
92

Havoc Pennington's avatar
Havoc Pennington committed
93
/* includes only text, no 0xFFFC */
94
gchar   *gtk_text_iter_get_text          (const GtkTextIter  *start,
95
                                          const GtkTextIter  *end);
96
97
/* exclude invisible chars */
gchar   *gtk_text_iter_get_visible_slice (const GtkTextIter  *start,
98
                                          const GtkTextIter  *end);
99
gchar   *gtk_text_iter_get_visible_text  (const GtkTextIter  *start,
100
                                          const GtkTextIter  *end);
101

Havoc Pennington's avatar
Havoc Pennington committed
102
103
GdkPixbuf* gtk_text_iter_get_pixbuf (const GtkTextIter *iter);
GSList  *  gtk_text_iter_get_marks  (const GtkTextIter *iter);
104

105
106
GtkTextChildAnchor* gtk_text_iter_get_child_anchor (const GtkTextIter *iter);

107
108
109
/* Return list of tags toggled at this point (toggled_on determines
   whether the list is of on-toggles or off-toggles) */
GSList  *gtk_text_iter_get_toggled_tags  (const GtkTextIter  *iter,
110
                                          gboolean             toggled_on);
111
112

gboolean gtk_text_iter_begins_tag        (const GtkTextIter  *iter,
113
                                          GtkTextTag         *tag);
114
115

gboolean gtk_text_iter_ends_tag          (const GtkTextIter  *iter,
116
                                          GtkTextTag         *tag);
117
118

gboolean gtk_text_iter_toggles_tag       (const GtkTextIter  *iter,
119
                                          GtkTextTag         *tag);
120
121

gboolean gtk_text_iter_has_tag           (const GtkTextIter   *iter,
122
                                          GtkTextTag          *tag);
123
GSList  *gtk_text_iter_get_tags          (const GtkTextIter   *iter);
124

125
126
127
gboolean gtk_text_iter_editable          (const GtkTextIter   *iter,
                                          gboolean             default_setting);

128
129
130
gboolean gtk_text_iter_starts_word       (const GtkTextIter   *iter);
gboolean gtk_text_iter_ends_word         (const GtkTextIter   *iter);
gboolean gtk_text_iter_inside_word       (const GtkTextIter   *iter);
131
132
133
134
135
gboolean gtk_text_iter_starts_line       (const GtkTextIter   *iter);
gboolean gtk_text_iter_ends_line         (const GtkTextIter   *iter);

gint     gtk_text_iter_get_chars_in_line (const GtkTextIter   *iter);

136
gboolean gtk_text_iter_get_attributes    (const GtkTextIter    *iter,
137
138
                                          GtkTextAttributes    *values);
gchar*   gtk_text_iter_get_language      (const GtkTextIter    *iter);
139
140
141
gboolean gtk_text_iter_is_last           (const GtkTextIter    *iter);
gboolean gtk_text_iter_is_first          (const GtkTextIter    *iter);

142
143
144
/*
 * Moving around the buffer
 */
145

146
147
gboolean gtk_text_iter_forward_char            (GtkTextIter *iter);
gboolean gtk_text_iter_backward_char            (GtkTextIter *iter);
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
gboolean gtk_text_iter_forward_chars        (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_backward_chars       (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_forward_line         (GtkTextIter *iter);
gboolean gtk_text_iter_backward_line        (GtkTextIter *iter);
gboolean gtk_text_iter_forward_lines        (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_backward_lines       (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_forward_word_ends    (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_backward_word_starts (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_forward_word_end     (GtkTextIter *iter);
gboolean gtk_text_iter_backward_word_start  (GtkTextIter *iter);

void     gtk_text_iter_set_offset         (GtkTextIter *iter,
                                           gint         char_offset);
void     gtk_text_iter_set_line           (GtkTextIter *iter,
                                           gint         line_number);
void     gtk_text_iter_set_line_offset    (GtkTextIter *iter,
                                           gint         char_on_line);
Havoc Pennington's avatar
Havoc Pennington committed
171
172
void     gtk_text_iter_set_line_index     (GtkTextIter *iter,
                                           gint         byte_on_line);
173
174
void     gtk_text_iter_forward_to_end     (GtkTextIter *iter);
gboolean gtk_text_iter_forward_to_newline (GtkTextIter *iter);
175

Havoc Pennington's avatar
Havoc Pennington committed
176

177
/* returns TRUE if a toggle was found; NULL for the tag pointer
178
179
180
 * means "any tag toggle", otherwise the next toggle of the
 * specified tag is located.
 */
181
182
gboolean gtk_text_iter_forward_to_tag_toggle (GtkTextIter *iter,
                                              GtkTextTag  *tag);
183

184
185
gboolean gtk_text_iter_backward_to_tag_toggle (GtkTextIter *iter,
                                               GtkTextTag  *tag);
186

187
typedef gboolean (* GtkTextCharPredicate) (gunichar ch, gpointer user_data);
188

189
190
191
192
193
194
195
196
gboolean gtk_text_iter_forward_find_char  (GtkTextIter          *iter,
                                           GtkTextCharPredicate  pred,
                                           gpointer              user_data,
                                           const GtkTextIter    *limit);
gboolean gtk_text_iter_backward_find_char (GtkTextIter          *iter,
                                           GtkTextCharPredicate  pred,
                                           gpointer              user_data,
                                           const GtkTextIter    *limit);
197

198
199
200
201
202
gboolean gtk_text_iter_forward_search  (const GtkTextIter *iter,
                                        const gchar       *str,
                                        gboolean           visible_only,
                                        gboolean           slice,
                                        GtkTextIter       *match_start,
203
204
205
                                        GtkTextIter       *match_end,
                                        const GtkTextIter *limit);

206
207
208
209
210
gboolean gtk_text_iter_backward_search (const GtkTextIter *iter,
                                        const gchar       *str,
                                        gboolean           visible_only,
                                        gboolean           slice,
                                        GtkTextIter       *match_start,
211
212
                                        GtkTextIter       *match_end,
                                        const GtkTextIter *limit);
213

214

215
216
217
218
/*
 * Comparisons
 */
gboolean gtk_text_iter_equal           (const GtkTextIter *lhs,
219
                                        const GtkTextIter *rhs);
220
gint     gtk_text_iter_compare         (const GtkTextIter *lhs,
221
                                        const GtkTextIter *rhs);
Havoc Pennington's avatar
Havoc Pennington committed
222
gboolean gtk_text_iter_in_range        (const GtkTextIter *iter,
223
224
                                        const GtkTextIter *start,
                                        const GtkTextIter *end);
225
226
227

/* Put these two in ascending order */
void     gtk_text_iter_reorder         (GtkTextIter *first,
228
                                        GtkTextIter *second);
229
230
231

/* Debug */
void     gtk_text_iter_spew            (const GtkTextIter *iter,
232
                                        const gchar *desc);
233
234
235
236
237
238
239
240

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif