]> Pileus Git - ~andy/gtk/blob - gtk/gtktextiter.h
Some updates
[~andy/gtk] / gtk / gtktextiter.h
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef GTK_TEXT_ITER_H
28 #define GTK_TEXT_ITER_H
29
30 #include <gtk/gtktexttag.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 /*
37  * Iter: represents a location in the text. Becomes invalid if the
38  * characters/pixmaps/widgets (indexable objects) in the text buffer
39  * are changed.
40  */
41
42 typedef struct _GtkTextBuffer GtkTextBuffer;
43
44 struct _GtkTextIter {
45   gpointer dummy1;
46   gpointer dummy2;
47   gint dummy3;
48   gint dummy4;
49   gint dummy5;
50   gint dummy6;
51   gint dummy7;
52   gint dummy8;
53   gpointer dummy9;
54   gpointer dummy10;
55   gint dummy11;
56   gint dummy12;
57 };
58
59
60 /* This is primarily intended for language bindings that want to avoid
61    a "buffer" argument to text insertions, deletions, etc. */
62 GtkTextBuffer *gtk_text_iter_get_buffer(const GtkTextIter *iter);
63
64 /*
65  * Life cycle
66  */
67
68 GtkTextIter *gtk_text_iter_copy     (const GtkTextIter *iter);
69 void         gtk_text_iter_free     (GtkTextIter       *iter);
70
71 /*
72  * Convert to different kinds of index
73  */
74
75 gint gtk_text_iter_get_offset      (const GtkTextIter *iter);
76 gint gtk_text_iter_get_line        (const GtkTextIter *iter);
77 gint gtk_text_iter_get_line_offset (const GtkTextIter *iter);
78 gint gtk_text_iter_get_line_index  (const GtkTextIter *iter);
79
80
81 /*
82  * "Dereference" operators
83  */
84 gunichar gtk_text_iter_get_char          (const GtkTextIter  *iter);
85
86 /* includes the 0xFFFD char for pixmaps/widgets, so char offsets
87    into the returned string map properly into buffer char offsets */
88 gchar   *gtk_text_iter_get_slice         (const GtkTextIter  *start,
89                                           const GtkTextIter  *end);
90
91 /* includes only text, no 0xFFFD */
92 gchar   *gtk_text_iter_get_text          (const GtkTextIter  *start,
93                                           const GtkTextIter  *end);
94 /* exclude invisible chars */
95 gchar   *gtk_text_iter_get_visible_slice (const GtkTextIter  *start,
96                                           const GtkTextIter  *end);
97 gchar   *gtk_text_iter_get_visible_text  (const GtkTextIter  *start,
98                                           const GtkTextIter  *end);
99
100 GdkPixbuf* gtk_text_iter_get_pixbuf (const GtkTextIter *iter);
101 GSList  *  gtk_text_iter_get_marks  (const GtkTextIter *iter);
102
103 /* Return list of tags toggled at this point (toggled_on determines
104    whether the list is of on-toggles or off-toggles) */
105 GSList  *gtk_text_iter_get_toggled_tags  (const GtkTextIter  *iter,
106                                           gboolean             toggled_on);
107
108 gboolean gtk_text_iter_begins_tag        (const GtkTextIter  *iter,
109                                           GtkTextTag         *tag);
110
111 gboolean gtk_text_iter_ends_tag          (const GtkTextIter  *iter,
112                                           GtkTextTag         *tag);
113
114 gboolean gtk_text_iter_toggles_tag       (const GtkTextIter  *iter,
115                                           GtkTextTag         *tag);
116
117 gboolean gtk_text_iter_has_tag           (const GtkTextIter   *iter,
118                                           GtkTextTag          *tag);
119
120 gboolean gtk_text_iter_editable          (const GtkTextIter   *iter,
121                                           gboolean             default_setting);
122
123 gboolean gtk_text_iter_starts_line       (const GtkTextIter   *iter);
124 gboolean gtk_text_iter_ends_line         (const GtkTextIter   *iter);
125
126 gint     gtk_text_iter_get_chars_in_line (const GtkTextIter   *iter);
127
128 gboolean gtk_text_iter_get_attributes    (const GtkTextIter    *iter,
129                                           GtkTextAttributes   *values);
130
131 gboolean gtk_text_iter_is_last           (const GtkTextIter    *iter);
132 gboolean gtk_text_iter_is_first          (const GtkTextIter    *iter);
133
134 /*
135  * Moving around the buffer
136  */
137
138 gboolean gtk_text_iter_next_char            (GtkTextIter *iter);
139 gboolean gtk_text_iter_prev_char            (GtkTextIter *iter);
140 gboolean gtk_text_iter_forward_chars        (GtkTextIter *iter,
141                                              gint         count);
142 gboolean gtk_text_iter_backward_chars       (GtkTextIter *iter,
143                                              gint         count);
144 gboolean gtk_text_iter_forward_line         (GtkTextIter *iter);
145 gboolean gtk_text_iter_backward_line        (GtkTextIter *iter);
146 gboolean gtk_text_iter_forward_lines        (GtkTextIter *iter,
147                                              gint         count);
148 gboolean gtk_text_iter_backward_lines       (GtkTextIter *iter,
149                                              gint         count);
150 gboolean gtk_text_iter_forward_word_ends    (GtkTextIter *iter,
151                                              gint         count);
152 gboolean gtk_text_iter_backward_word_starts (GtkTextIter *iter,
153                                              gint         count);
154 gboolean gtk_text_iter_forward_word_end     (GtkTextIter *iter);
155 gboolean gtk_text_iter_backward_word_start  (GtkTextIter *iter);
156
157 void     gtk_text_iter_set_offset         (GtkTextIter *iter,
158                                            gint         char_offset);
159 void     gtk_text_iter_set_line           (GtkTextIter *iter,
160                                            gint         line_number);
161 void     gtk_text_iter_set_line_offset    (GtkTextIter *iter,
162                                            gint         char_on_line);
163 void     gtk_text_iter_forward_to_end     (GtkTextIter *iter);
164 gboolean gtk_text_iter_forward_to_newline (GtkTextIter *iter);
165
166
167 /* returns TRUE if a toggle was found; NULL for the tag pointer
168    means "any tag toggle", otherwise the next toggle of the
169    specified tag is located. */
170 gboolean gtk_text_iter_forward_to_tag_toggle (GtkTextIter *iter,
171                                               GtkTextTag  *tag);
172
173 gboolean gtk_text_iter_backward_to_tag_toggle (GtkTextIter *iter,
174                                                GtkTextTag  *tag);
175
176 typedef gboolean (* GtkTextCharPredicate) (gunichar ch, gpointer user_data);
177
178 gboolean gtk_text_iter_forward_find_char      (GtkTextIter *iter,
179                                                GtkTextCharPredicate pred,
180                                                gpointer user_data);
181
182 gboolean gtk_text_iter_backward_find_char     (GtkTextIter *iter,
183                                                GtkTextCharPredicate pred,
184                                                gpointer user_data);
185
186 gboolean gtk_text_iter_forward_search         (const GtkTextIter *iter,
187                                                const gchar *str,
188                                                gboolean     visible_only,
189                                                gboolean     slice,
190                                                GtkTextIter *match_start,
191                                                GtkTextIter *match_end);
192
193 gboolean gtk_text_iter_backward_search        (GtkTextIter *iter,
194                                                const char  *str,
195                                                gboolean visible_only,
196                                                gboolean slice);
197
198 /*
199  * Comparisons
200  */
201 gboolean gtk_text_iter_equal           (const GtkTextIter *lhs,
202                                         const GtkTextIter *rhs);
203 gint     gtk_text_iter_compare         (const GtkTextIter *lhs,
204                                         const GtkTextIter *rhs);
205 gboolean gtk_text_iter_in_range        (const GtkTextIter *iter,
206                                         const GtkTextIter *start,
207                                         const GtkTextIter *end);
208
209 /* Put these two in ascending order */
210 void     gtk_text_iter_reorder         (GtkTextIter *first,
211                                         GtkTextIter *second);
212
213 /* Debug */
214 void     gtk_text_iter_spew            (const GtkTextIter *iter,
215                                         const gchar *desc);
216
217 #ifdef __cplusplus
218 }
219 #endif /* __cplusplus */
220
221 #endif
222
223