~inkscape.dev/inkscape-devlibs/devlibs-gtk3

« back to all changes in this revision

Viewing changes to include/gtk-2.0/gtk/gtktextbuffer.h

  • Committer: JazzyNico
  • Date: 2013-01-21 10:11:05 UTC
  • Revision ID: nicoduf@yahoo.fr-20130121101105-i8d8slkq9ng4olx8
Adding gtk2 libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GTK - The GIMP Toolkit
 
2
 * gtktextbuffer.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
#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
 
28
#error "Only <gtk/gtk.h> can be included directly."
 
29
#endif
 
30
 
 
31
#ifndef __GTK_TEXT_BUFFER_H__
 
32
#define __GTK_TEXT_BUFFER_H__
 
33
 
 
34
#include <gtk/gtkwidget.h>
 
35
#include <gtk/gtkclipboard.h>
 
36
#include <gtk/gtktexttagtable.h>
 
37
#include <gtk/gtktextiter.h>
 
38
#include <gtk/gtktextmark.h>
 
39
#include <gtk/gtktextchild.h>
 
40
 
 
41
G_BEGIN_DECLS
 
42
 
 
43
/*
 
44
 * This is the PUBLIC representation of a text buffer.
 
45
 * GtkTextBTree is the PRIVATE internal representation of it.
 
46
 */
 
47
 
 
48
/* these values are used as "info" for the targets contained in the
 
49
 * lists returned by gtk_text_buffer_get_copy,paste_target_list()
 
50
 *
 
51
 * the enum counts down from G_MAXUINT to avoid clashes with application
 
52
 * added drag destinations which usually start at 0.
 
53
 */
 
54
typedef enum
 
55
{
 
56
  GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS = - 1,
 
57
  GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT       = - 2,
 
58
  GTK_TEXT_BUFFER_TARGET_INFO_TEXT            = - 3
 
59
} GtkTextBufferTargetInfo;
 
60
 
 
61
typedef struct _GtkTextBTree GtkTextBTree;
 
62
 
 
63
typedef struct _GtkTextLogAttrCache GtkTextLogAttrCache;
 
64
 
 
65
#define GTK_TYPE_TEXT_BUFFER            (gtk_text_buffer_get_type ())
 
66
#define GTK_TEXT_BUFFER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBuffer))
 
67
#define GTK_TEXT_BUFFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass))
 
68
#define GTK_IS_TEXT_BUFFER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_BUFFER))
 
69
#define GTK_IS_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_BUFFER))
 
70
#define GTK_TEXT_BUFFER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass))
 
71
 
 
72
typedef struct _GtkTextBufferClass GtkTextBufferClass;
 
73
 
 
74
struct _GtkTextBuffer
 
75
{
 
76
  GObject parent_instance;
 
77
 
 
78
  GtkTextTagTable *GSEAL (tag_table);
 
79
  GtkTextBTree *GSEAL (btree);
 
80
 
 
81
  GSList *GSEAL (clipboard_contents_buffers);
 
82
  GSList *GSEAL (selection_clipboards);
 
83
 
 
84
  GtkTextLogAttrCache *GSEAL (log_attr_cache);
 
85
 
 
86
  guint GSEAL (user_action_count);
 
87
 
 
88
  /* Whether the buffer has been modified since last save */
 
89
  guint GSEAL (modified) : 1;
 
90
 
 
91
  guint GSEAL (has_selection) : 1;
 
92
};
 
93
 
 
94
struct _GtkTextBufferClass
 
95
{
 
96
  GObjectClass parent_class;
 
97
 
 
98
  void (* insert_text)     (GtkTextBuffer *buffer,
 
99
                            GtkTextIter *pos,
 
100
                            const gchar *text,
 
101
                            gint length);
 
102
 
 
103
  void (* insert_pixbuf)   (GtkTextBuffer *buffer,
 
104
                            GtkTextIter   *pos,
 
105
                            GdkPixbuf     *pixbuf);
 
106
 
 
107
  void (* insert_child_anchor)   (GtkTextBuffer      *buffer,
 
108
                                  GtkTextIter        *pos,
 
109
                                  GtkTextChildAnchor *anchor);
 
110
 
 
111
  void (* delete_range)     (GtkTextBuffer *buffer,
 
112
                             GtkTextIter   *start,
 
113
                             GtkTextIter   *end);
 
114
 
 
115
  /* Only for text/widgets/pixbuf changed, marks/tags don't cause this
 
116
   * to be emitted
 
117
   */
 
118
  void (* changed)         (GtkTextBuffer *buffer);
 
119
 
 
120
 
 
121
  /* New value for the modified flag */
 
122
  void (* modified_changed)   (GtkTextBuffer *buffer);
 
123
 
 
124
  /* Mark moved or created */
 
125
  void (* mark_set)           (GtkTextBuffer *buffer,
 
126
                               const GtkTextIter *location,
 
127
                               GtkTextMark *mark);
 
128
 
 
129
  void (* mark_deleted)       (GtkTextBuffer *buffer,
 
130
                               GtkTextMark *mark);
 
131
 
 
132
  void (* apply_tag)          (GtkTextBuffer *buffer,
 
133
                               GtkTextTag *tag,
 
134
                               const GtkTextIter *start_char,
 
135
                               const GtkTextIter *end_char);
 
136
 
 
137
  void (* remove_tag)         (GtkTextBuffer *buffer,
 
138
                               GtkTextTag *tag,
 
139
                               const GtkTextIter *start_char,
 
140
                               const GtkTextIter *end_char);
 
141
 
 
142
  /* Called at the start and end of an atomic user action */
 
143
  void (* begin_user_action)  (GtkTextBuffer *buffer);
 
144
  void (* end_user_action)    (GtkTextBuffer *buffer);
 
145
 
 
146
  void (* paste_done)         (GtkTextBuffer *buffer,
 
147
                               GtkClipboard  *clipboard);
 
148
 
 
149
  /* Padding for future expansion */
 
150
  void (*_gtk_reserved1) (void);
 
151
  void (*_gtk_reserved2) (void);
 
152
  void (*_gtk_reserved3) (void);
 
153
  void (*_gtk_reserved4) (void);
 
154
  void (*_gtk_reserved5) (void);
 
155
};
 
156
 
 
157
GType        gtk_text_buffer_get_type       (void) G_GNUC_CONST;
 
158
 
 
159
 
 
160
 
 
161
/* table is NULL to create a new one */
 
162
GtkTextBuffer *gtk_text_buffer_new            (GtkTextTagTable *table);
 
163
gint           gtk_text_buffer_get_line_count (GtkTextBuffer   *buffer);
 
164
gint           gtk_text_buffer_get_char_count (GtkTextBuffer   *buffer);
 
165
 
 
166
 
 
167
GtkTextTagTable* gtk_text_buffer_get_tag_table (GtkTextBuffer  *buffer);
 
168
 
 
169
/* Delete whole buffer, then insert */
 
170
void gtk_text_buffer_set_text          (GtkTextBuffer *buffer,
 
171
                                        const gchar   *text,
 
172
                                        gint           len);
 
173
 
 
174
/* Insert into the buffer */
 
175
void gtk_text_buffer_insert            (GtkTextBuffer *buffer,
 
176
                                        GtkTextIter   *iter,
 
177
                                        const gchar   *text,
 
178
                                        gint           len);
 
179
void gtk_text_buffer_insert_at_cursor  (GtkTextBuffer *buffer,
 
180
                                        const gchar   *text,
 
181
                                        gint           len);
 
182
 
 
183
gboolean gtk_text_buffer_insert_interactive           (GtkTextBuffer *buffer,
 
184
                                                       GtkTextIter   *iter,
 
185
                                                       const gchar   *text,
 
186
                                                       gint           len,
 
187
                                                       gboolean       default_editable);
 
188
gboolean gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer,
 
189
                                                       const gchar   *text,
 
190
                                                       gint           len,
 
191
                                                       gboolean       default_editable);
 
192
 
 
193
void     gtk_text_buffer_insert_range             (GtkTextBuffer     *buffer,
 
194
                                                   GtkTextIter       *iter,
 
195
                                                   const GtkTextIter *start,
 
196
                                                   const GtkTextIter *end);
 
197
gboolean gtk_text_buffer_insert_range_interactive (GtkTextBuffer     *buffer,
 
198
                                                   GtkTextIter       *iter,
 
199
                                                   const GtkTextIter *start,
 
200
                                                   const GtkTextIter *end,
 
201
                                                   gboolean           default_editable);
 
202
 
 
203
void    gtk_text_buffer_insert_with_tags          (GtkTextBuffer     *buffer,
 
204
                                                   GtkTextIter       *iter,
 
205
                                                   const gchar       *text,
 
206
                                                   gint               len,
 
207
                                                   GtkTextTag        *first_tag,
 
208
                                                   ...) G_GNUC_NULL_TERMINATED;
 
209
 
 
210
void    gtk_text_buffer_insert_with_tags_by_name  (GtkTextBuffer     *buffer,
 
211
                                                   GtkTextIter       *iter,
 
212
                                                   const gchar       *text,
 
213
                                                   gint               len,
 
214
                                                   const gchar       *first_tag_name,
 
215
                                                   ...) G_GNUC_NULL_TERMINATED;
 
216
 
 
217
/* Delete from the buffer */
 
218
void     gtk_text_buffer_delete             (GtkTextBuffer *buffer,
 
219
                                             GtkTextIter   *start,
 
220
                                             GtkTextIter   *end);
 
221
gboolean gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer,
 
222
                                             GtkTextIter   *start_iter,
 
223
                                             GtkTextIter   *end_iter,
 
224
                                             gboolean       default_editable);
 
225
gboolean gtk_text_buffer_backspace          (GtkTextBuffer *buffer,
 
226
                                             GtkTextIter   *iter,
 
227
                                             gboolean       interactive,
 
228
                                             gboolean       default_editable);
 
229
 
 
230
/* Obtain strings from the buffer */
 
231
gchar          *gtk_text_buffer_get_text            (GtkTextBuffer     *buffer,
 
232
                                                     const GtkTextIter *start,
 
233
                                                     const GtkTextIter *end,
 
234
                                                     gboolean           include_hidden_chars);
 
235
 
 
236
gchar          *gtk_text_buffer_get_slice           (GtkTextBuffer     *buffer,
 
237
                                                     const GtkTextIter *start,
 
238
                                                     const GtkTextIter *end,
 
239
                                                     gboolean           include_hidden_chars);
 
240
 
 
241
/* Insert a pixbuf */
 
242
void gtk_text_buffer_insert_pixbuf         (GtkTextBuffer *buffer,
 
243
                                            GtkTextIter   *iter,
 
244
                                            GdkPixbuf     *pixbuf);
 
245
 
 
246
/* Insert a child anchor */
 
247
void               gtk_text_buffer_insert_child_anchor (GtkTextBuffer      *buffer,
 
248
                                                        GtkTextIter        *iter,
 
249
                                                        GtkTextChildAnchor *anchor);
 
250
 
 
251
/* Convenience, create and insert a child anchor */
 
252
GtkTextChildAnchor *gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
 
253
                                                         GtkTextIter   *iter);
 
254
 
 
255
/* Mark manipulation */
 
256
void           gtk_text_buffer_add_mark    (GtkTextBuffer     *buffer,
 
257
                                            GtkTextMark       *mark,
 
258
                                            const GtkTextIter *where);
 
259
GtkTextMark   *gtk_text_buffer_create_mark (GtkTextBuffer     *buffer,
 
260
                                            const gchar       *mark_name,
 
261
                                            const GtkTextIter *where,
 
262
                                            gboolean           left_gravity);
 
263
void           gtk_text_buffer_move_mark   (GtkTextBuffer     *buffer,
 
264
                                            GtkTextMark       *mark,
 
265
                                            const GtkTextIter *where);
 
266
void           gtk_text_buffer_delete_mark (GtkTextBuffer     *buffer,
 
267
                                            GtkTextMark       *mark);
 
268
GtkTextMark*   gtk_text_buffer_get_mark    (GtkTextBuffer     *buffer,
 
269
                                            const gchar       *name);
 
270
 
 
271
void gtk_text_buffer_move_mark_by_name   (GtkTextBuffer     *buffer,
 
272
                                          const gchar       *name,
 
273
                                          const GtkTextIter *where);
 
274
void gtk_text_buffer_delete_mark_by_name (GtkTextBuffer     *buffer,
 
275
                                          const gchar       *name);
 
276
 
 
277
GtkTextMark* gtk_text_buffer_get_insert          (GtkTextBuffer *buffer);
 
278
GtkTextMark* gtk_text_buffer_get_selection_bound (GtkTextBuffer *buffer);
 
279
 
 
280
/* efficiently move insert and selection_bound at the same time */
 
281
void gtk_text_buffer_place_cursor (GtkTextBuffer     *buffer,
 
282
                                   const GtkTextIter *where);
 
283
void gtk_text_buffer_select_range (GtkTextBuffer     *buffer,
 
284
                                   const GtkTextIter *ins,
 
285
                                   const GtkTextIter *bound);
 
286
 
 
287
 
 
288
 
 
289
/* Tag manipulation */
 
290
void gtk_text_buffer_apply_tag             (GtkTextBuffer     *buffer,
 
291
                                            GtkTextTag        *tag,
 
292
                                            const GtkTextIter *start,
 
293
                                            const GtkTextIter *end);
 
294
void gtk_text_buffer_remove_tag            (GtkTextBuffer     *buffer,
 
295
                                            GtkTextTag        *tag,
 
296
                                            const GtkTextIter *start,
 
297
                                            const GtkTextIter *end);
 
298
void gtk_text_buffer_apply_tag_by_name     (GtkTextBuffer     *buffer,
 
299
                                            const gchar       *name,
 
300
                                            const GtkTextIter *start,
 
301
                                            const GtkTextIter *end);
 
302
void gtk_text_buffer_remove_tag_by_name    (GtkTextBuffer     *buffer,
 
303
                                            const gchar       *name,
 
304
                                            const GtkTextIter *start,
 
305
                                            const GtkTextIter *end);
 
306
void gtk_text_buffer_remove_all_tags       (GtkTextBuffer     *buffer,
 
307
                                            const GtkTextIter *start,
 
308
                                            const GtkTextIter *end);
 
309
 
 
310
 
 
311
/* You can either ignore the return value, or use it to
 
312
 * set the attributes of the tag. tag_name can be NULL
 
313
 */
 
314
GtkTextTag    *gtk_text_buffer_create_tag (GtkTextBuffer *buffer,
 
315
                                           const gchar   *tag_name,
 
316
                                           const gchar   *first_property_name,
 
317
                                           ...);
 
318
 
 
319
/* Obtain iterators pointed at various places, then you can move the
 
320
 * iterator around using the GtkTextIter operators
 
321
 */
 
322
void gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
 
323
                                              GtkTextIter   *iter,
 
324
                                              gint           line_number,
 
325
                                              gint           char_offset);
 
326
void gtk_text_buffer_get_iter_at_line_index  (GtkTextBuffer *buffer,
 
327
                                              GtkTextIter   *iter,
 
328
                                              gint           line_number,
 
329
                                              gint           byte_index);
 
330
void gtk_text_buffer_get_iter_at_offset      (GtkTextBuffer *buffer,
 
331
                                              GtkTextIter   *iter,
 
332
                                              gint           char_offset);
 
333
void gtk_text_buffer_get_iter_at_line        (GtkTextBuffer *buffer,
 
334
                                              GtkTextIter   *iter,
 
335
                                              gint           line_number);
 
336
void gtk_text_buffer_get_start_iter          (GtkTextBuffer *buffer,
 
337
                                              GtkTextIter   *iter);
 
338
void gtk_text_buffer_get_end_iter            (GtkTextBuffer *buffer,
 
339
                                              GtkTextIter   *iter);
 
340
void gtk_text_buffer_get_bounds              (GtkTextBuffer *buffer,
 
341
                                              GtkTextIter   *start,
 
342
                                              GtkTextIter   *end);
 
343
void gtk_text_buffer_get_iter_at_mark        (GtkTextBuffer *buffer,
 
344
                                              GtkTextIter   *iter,
 
345
                                              GtkTextMark   *mark);
 
346
 
 
347
void gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer      *buffer,
 
348
                                               GtkTextIter        *iter,
 
349
                                               GtkTextChildAnchor *anchor);
 
350
 
 
351
/* There's no get_first_iter because you just get the iter for
 
352
   line or char 0 */
 
353
 
 
354
/* Used to keep track of whether the buffer needs saving; anytime the
 
355
   buffer contents change, the modified flag is turned on. Whenever
 
356
   you save, turn it off. Tags and marks do not affect the modified
 
357
   flag, but if you would like them to you can connect a handler to
 
358
   the tag/mark signals and call set_modified in your handler */
 
359
 
 
360
gboolean        gtk_text_buffer_get_modified            (GtkTextBuffer *buffer);
 
361
void            gtk_text_buffer_set_modified            (GtkTextBuffer *buffer,
 
362
                                                         gboolean       setting);
 
363
 
 
364
gboolean        gtk_text_buffer_get_has_selection       (GtkTextBuffer *buffer);
 
365
 
 
366
void gtk_text_buffer_add_selection_clipboard    (GtkTextBuffer     *buffer,
 
367
                                                 GtkClipboard      *clipboard);
 
368
void gtk_text_buffer_remove_selection_clipboard (GtkTextBuffer     *buffer,
 
369
                                                 GtkClipboard      *clipboard);
 
370
 
 
371
void            gtk_text_buffer_cut_clipboard           (GtkTextBuffer *buffer,
 
372
                                                         GtkClipboard  *clipboard,
 
373
                                                         gboolean       default_editable);
 
374
void            gtk_text_buffer_copy_clipboard          (GtkTextBuffer *buffer,
 
375
                                                         GtkClipboard  *clipboard);
 
376
void            gtk_text_buffer_paste_clipboard         (GtkTextBuffer *buffer,
 
377
                                                         GtkClipboard  *clipboard,
 
378
                                                         GtkTextIter   *override_location,
 
379
                                                         gboolean       default_editable);
 
380
 
 
381
gboolean        gtk_text_buffer_get_selection_bounds    (GtkTextBuffer *buffer,
 
382
                                                         GtkTextIter   *start,
 
383
                                                         GtkTextIter   *end);
 
384
gboolean        gtk_text_buffer_delete_selection        (GtkTextBuffer *buffer,
 
385
                                                         gboolean       interactive,
 
386
                                                         gboolean       default_editable);
 
387
 
 
388
/* Called to specify atomic user actions, used to implement undo */
 
389
void            gtk_text_buffer_begin_user_action       (GtkTextBuffer *buffer);
 
390
void            gtk_text_buffer_end_user_action         (GtkTextBuffer *buffer);
 
391
 
 
392
GtkTargetList * gtk_text_buffer_get_copy_target_list    (GtkTextBuffer *buffer);
 
393
GtkTargetList * gtk_text_buffer_get_paste_target_list   (GtkTextBuffer *buffer);
 
394
 
 
395
/* INTERNAL private stuff */
 
396
void            _gtk_text_buffer_spew                  (GtkTextBuffer      *buffer);
 
397
 
 
398
GtkTextBTree*   _gtk_text_buffer_get_btree             (GtkTextBuffer      *buffer);
 
399
 
 
400
const PangoLogAttr* _gtk_text_buffer_get_line_log_attrs (GtkTextBuffer     *buffer,
 
401
                                                         const GtkTextIter *anywhere_in_line,
 
402
                                                         gint              *char_len);
 
403
 
 
404
void _gtk_text_buffer_notify_will_remove_tag (GtkTextBuffer *buffer,
 
405
                                              GtkTextTag    *tag);
 
406
 
 
407
G_END_DECLS
 
408
 
 
409
#endif