]> Pileus Git - ~andy/gtk/blob - gtk/gtktextbuffer.h
Doc comment fixing. (Mostly non-matching parameter names.)
[~andy/gtk] / gtk / gtktextbuffer.h
1 #ifndef GTK_TEXT_BUFFER_H
2 #define GTK_TEXT_BUFFER_H
3
4 #include <gtk/gtkwidget.h>
5 #include <gtk/gtktexttagtable.h>
6 #include <gtk/gtktextiter.h>
7 #include <gtk/gtktextmark.h>
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif /* __cplusplus */
12
13 /*
14  * This is the PUBLIC representation of a text buffer.
15  * GtkTextBTree is the PRIVATE internal representation of it.
16  */
17
18 typedef struct _GtkTextBTree GtkTextBTree;
19
20 #define GTK_TYPE_TEXT_BUFFER            (gtk_text_buffer_get_type())
21 #define GTK_TEXT_BUFFER(obj)            (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBuffer))
22 #define GTK_TEXT_BUFFER_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass))
23 #define GTK_IS_TEXT_BUFFER(obj)         (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_BUFFER))
24 #define GTK_IS_TEXT_BUFFER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_BUFFER))
25 #define GTK_TEXT_BUFFER_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass))
26
27 typedef struct _GtkTextBufferClass GtkTextBufferClass;
28
29 struct _GtkTextBuffer {
30   GtkObject parent_instance;
31
32   GtkTextTagTable *tag_table;
33   GtkTextBTree *btree;
34
35   /* Text currently pasted to the clipboard */
36   gchar *clipboard_text;
37
38   /* Whether the buffer has been modified since last save */
39   gboolean modified;
40
41   /* We use this for selections */
42   GtkWidget *selection_widget;
43   gboolean have_selection;
44   gboolean selection_handlers_installed;
45   gboolean paste_interactive;
46   gboolean paste_default_editable;
47 };
48
49 struct _GtkTextBufferClass {
50   GtkObjectClass parent_class;
51
52   void (* insert_text)     (GtkTextBuffer *buffer,
53                             GtkTextIter *pos,
54                             const gchar *text,
55                             gint length,
56                             gboolean interactive);
57
58
59   void (* delete_text)     (GtkTextBuffer *buffer,
60                             GtkTextIter *start,
61                             GtkTextIter *end,
62                             gboolean interactive);
63
64   /* Only for text changed, marks/tags don't cause this
65      to be emitted */
66   void (* changed)         (GtkTextBuffer *buffer);
67
68
69   /* New value for the modified flag */
70   void (* modified_changed)   (GtkTextBuffer *buffer);
71
72   /* Mark moved or created */
73   void (* mark_set)           (GtkTextBuffer *buffer,
74                                const GtkTextIter *location,
75                                GtkTextMark *mark);
76
77   void (* mark_deleted)       (GtkTextBuffer *buffer,
78                                GtkTextMark *mark);
79
80   void (* apply_tag)          (GtkTextBuffer *buffer,
81                                GtkTextTag *tag,
82                                const GtkTextIter *start_char,
83                                const GtkTextIter *end_char);
84
85   void (* remove_tag)         (GtkTextBuffer *buffer,
86                                GtkTextTag *tag,
87                                const GtkTextIter *start_char,
88                                const GtkTextIter *end_char);
89
90 };
91
92 GtkType        gtk_text_buffer_get_type       (void) G_GNUC_CONST;
93
94
95
96 /* table is NULL to create a new one */
97 GtkTextBuffer *gtk_text_buffer_new            (GtkTextTagTable *table);
98 gint           gtk_text_buffer_get_line_count (GtkTextBuffer   *buffer);
99 gint           gtk_text_buffer_get_char_count (GtkTextBuffer   *buffer);
100
101
102 GtkTextTagTable* gtk_text_buffer_get_tag_table (GtkTextBuffer  *buffer);
103
104 /* Insert into the buffer */
105 void gtk_text_buffer_insert            (GtkTextBuffer *buffer,
106                                         GtkTextIter   *iter,
107                                         const gchar   *text,
108                                         gint           len);
109 void gtk_text_buffer_insert_at_cursor  (GtkTextBuffer *buffer,
110                                         const gchar   *text,
111                                         gint           len);
112
113 gboolean gtk_text_buffer_insert_interactive           (GtkTextBuffer *buffer,
114                                                        GtkTextIter   *iter,
115                                                        const gchar   *text,
116                                                        gint           len,
117                                                        gboolean       default_editable);
118 gboolean gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer,
119                                                        const gchar   *text,
120                                                        gint           len,
121                                                        gboolean       default_editable);
122
123
124 /* Delete from the buffer */
125 void     gtk_text_buffer_delete             (GtkTextBuffer *buffer,
126                                              GtkTextIter   *start,
127                                              GtkTextIter   *end);
128 gboolean gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer,
129                                              GtkTextIter   *start_iter,
130                                              GtkTextIter   *end_iter,
131                                              gboolean       default_editable);
132
133
134
135 /* Obtain strings from the buffer */
136 gchar          *gtk_text_buffer_get_text            (GtkTextBuffer     *buffer,
137                                                      const GtkTextIter *start,
138                                                      const GtkTextIter *end,
139                                                      gboolean           include_hidden_chars);
140
141 gchar          *gtk_text_buffer_get_slice           (GtkTextBuffer     *buffer,
142                                                      const GtkTextIter *start,
143                                                      const GtkTextIter *end,
144                                                      gboolean           include_hidden_chars);
145
146 /* Insert a pixmap */
147 void gtk_text_buffer_insert_pixmap         (GtkTextBuffer *buffer,
148                                             GtkTextIter   *iter,
149                                             GdkPixmap     *pixmap,
150                                             GdkBitmap     *mask);
151
152 /* Mark manipulation */
153 GtkTextMark   *gtk_text_buffer_create_mark (GtkTextBuffer     *buffer,
154                                             const gchar       *mark_name,
155                                             const GtkTextIter *where,
156                                             gboolean           left_gravity);
157 void           gtk_text_buffer_move_mark   (GtkTextBuffer     *buffer,
158                                             GtkTextMark       *mark,
159                                             const GtkTextIter *where);
160 void           gtk_text_buffer_delete_mark (GtkTextBuffer     *buffer,
161                                             GtkTextMark       *mark);
162 GtkTextMark   *gtk_text_buffer_get_mark    (GtkTextBuffer     *buffer,
163                                             const gchar       *name);
164
165
166 /* efficiently move insert and selection_bound to same location */
167 void gtk_text_buffer_place_cursor (GtkTextBuffer     *buffer,
168                                    const GtkTextIter *where);
169
170
171
172 /* Tag manipulation */
173 void gtk_text_buffer_apply_tag             (GtkTextBuffer     *buffer,
174                                             GtkTextTag        *tag,
175                                             const GtkTextIter *start_index,
176                                             const GtkTextIter *end_index);
177 void gtk_text_buffer_remove_tag            (GtkTextBuffer     *buffer,
178                                             GtkTextTag        *tag,
179                                             const GtkTextIter *start_index,
180                                             const GtkTextIter *end_index);
181 void gtk_text_buffer_apply_tag_by_name     (GtkTextBuffer     *buffer,
182                                             const gchar       *name,
183                                             const GtkTextIter *start_index,
184                                             const GtkTextIter *end_index);
185 void gtk_text_buffer_remove_tag_by_name    (GtkTextBuffer     *buffer,
186                                             const gchar       *name,
187                                             const GtkTextIter *start_index,
188                                             const GtkTextIter *end_index);
189
190
191 /* You can either ignore the return value, or use it to
192  * set the attributes of the tag. tag_name can be NULL
193  */
194 GtkTextTag    *gtk_text_buffer_create_tag (GtkTextBuffer *buffer,
195                                            const gchar   *tag_name);
196
197 /* Obtain iterators pointed at various places, then you can move the
198    iterator around using the GtkTextIter operators */
199 void gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
200                                               GtkTextIter   *iter,
201                                               gint           line_number,
202                                               gint           char_offset);
203 void gtk_text_buffer_get_iter_at_offset      (GtkTextBuffer *buffer,
204                                               GtkTextIter   *iter,
205                                               gint           char_offset);
206 void gtk_text_buffer_get_iter_at_line        (GtkTextBuffer *buffer,
207                                               GtkTextIter   *iter,
208                                               gint           line_number);
209 void gtk_text_buffer_get_last_iter           (GtkTextBuffer *buffer,
210                                               GtkTextIter   *iter);
211 void gtk_text_buffer_get_bounds              (GtkTextBuffer *buffer,
212                                               GtkTextIter   *start,
213                                               GtkTextIter   *end);
214 void gtk_text_buffer_get_iter_at_mark        (GtkTextBuffer *buffer,
215                                               GtkTextIter   *iter,
216                                               GtkTextMark   *mark);
217
218
219
220 /* There's no get_first_iter because you just get the iter for
221    line or char 0 */
222
223 GSList         *gtk_text_buffer_get_tags (GtkTextBuffer     *buffer,
224                                           const GtkTextIter *iter);
225
226
227 /* Used to keep track of whether the buffer needs saving; anytime the
228    buffer contents change, the modified flag is turned on. Whenever
229    you save, turn it off. Tags and marks do not affect the modified
230    flag, but if you would like them to you can connect a handler to
231    the tag/mark signals and call set_modified in your handler */
232
233 gboolean        gtk_text_buffer_modified                (GtkTextBuffer *buffer);
234 void            gtk_text_buffer_set_modified            (GtkTextBuffer *buffer,
235                                                          gboolean       setting);
236 void            gtk_text_buffer_set_clipboard_contents  (GtkTextBuffer *buffer,
237                                                          const gchar   *text);
238 const gchar    *gtk_text_buffer_get_clipboard_contents  (GtkTextBuffer *buffer);
239
240
241 void            gtk_text_buffer_paste_primary_selection (GtkTextBuffer *buffer,
242                                                          GtkTextIter   *override_location,
243                                                          guint32        time,
244                                                          gboolean       interactive,
245                                                          gboolean       default_editable);
246 gboolean        gtk_text_buffer_delete_selection        (GtkTextBuffer *buffer,
247                                                          gboolean       interactive,
248                                                          gboolean       default_editable);
249 void            gtk_text_buffer_cut                     (GtkTextBuffer *buffer,
250                                                          guint32        time,
251                                                          gboolean       interactive,
252                                                          gboolean       default_editable);
253 void            gtk_text_buffer_copy                    (GtkTextBuffer *buffer,
254                                                          guint32        time);
255 void            gtk_text_buffer_paste_clipboard         (GtkTextBuffer *buffer,
256                                                          guint32        time,
257                                                          gboolean       interactive,
258                                                          gboolean       default_editable);
259 gboolean        gtk_text_buffer_get_selection_bounds    (GtkTextBuffer *buffer,
260                                                          GtkTextIter   *start,
261                                                          GtkTextIter   *end);
262
263
264 /* This function is not implemented. */
265 gboolean gtk_text_buffer_find_string(GtkTextBuffer *buffer,
266                                      GtkTextIter *iter,
267                                      const gchar *str,
268                                      const GtkTextIter *start,
269                                      const GtkTextIter *end);
270
271 #if 0
272 /* Waiting on glib 1.4 regexp facility */
273 gboolean gtk_text_buffer_find_regexp(GtkTextBuffer *buffer,
274                                      GRegexp *regexp,
275                                      const GtkTextIter *start,
276                                      const GtkTextIter *end);
277 #endif
278
279 /* INTERNAL private stuff */
280 void            gtk_text_buffer_spew                   (GtkTextBuffer      *buffer);
281
282 GtkTextBTree*   _gtk_text_buffer_get_btree             (GtkTextBuffer      *buffer);
283
284 #ifdef __cplusplus
285 }
286 #endif /* __cplusplus */
287
288 #endif