2 * Copyright (C) 2006-2008 Benjamin Otte <otte@gnome.org>
3 * 2007 Pekka Lampila <pekka.lampila@iki.fi>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
21 #ifndef _SWFDEC_TEXT_BUFFER_H_
22 #define _SWFDEC_TEXT_BUFFER_H_
24 #include <glib-object.h>
25 #include <swfdec/swfdec_text_attributes.h>
29 typedef struct _SwfdecTextBuffer SwfdecTextBuffer
;
30 typedef GSequenceIter SwfdecTextBufferIter
;
31 typedef struct _SwfdecTextBufferClass SwfdecTextBufferClass
;
33 #define SWFDEC_TYPE_TEXT_BUFFER (swfdec_text_buffer_get_type())
34 #define SWFDEC_IS_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_BUFFER))
35 #define SWFDEC_IS_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_BUFFER))
36 #define SWFDEC_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_BUFFER, SwfdecTextBuffer))
37 #define SWFDEC_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_BUFFER, SwfdecTextBufferClass))
39 struct _SwfdecTextBuffer
43 GString
* text
; /* the text in this buffer */
44 GSequence
* attributes
; /* the attributes that apply to this text */
45 SwfdecTextAttributes default_attributes
; /* the attributes applied to new text */
47 gsize cursor_start
; /* byte offset into text for start of cursor */
48 gsize cursor_end
; /* if some text is selected smaller or bigger */
51 struct _SwfdecTextBufferClass
53 GObjectClass object_class
;
56 GType
swfdec_text_buffer_get_type (void);
58 SwfdecTextBuffer
* swfdec_text_buffer_new (void);
59 void swfdec_text_buffer_mark (SwfdecTextBuffer
* buffer
);
61 void swfdec_text_buffer_insert_text (SwfdecTextBuffer
* buffer
,
64 #define swfdec_text_buffer_append_text(buffer, text) \
65 swfdec_text_buffer_insert_text ((buffer), swfdec_text_buffer_get_length (buffer), (text));
66 void swfdec_text_buffer_delete_text (SwfdecTextBuffer
* buffer
,
70 const char * swfdec_text_buffer_get_text (SwfdecTextBuffer
* buffer
);
71 gsize
swfdec_text_buffer_get_length (SwfdecTextBuffer
* buffer
);
72 const SwfdecTextAttributes
*
73 swfdec_text_buffer_get_attributes (SwfdecTextBuffer
* buffer
,
75 void swfdec_text_buffer_set_attributes (SwfdecTextBuffer
* buffer
,
78 const SwfdecTextAttributes
*attr
,
80 guint
swfdec_text_buffer_get_unique (SwfdecTextBuffer
* buffer
,
83 const SwfdecTextAttributes
*
84 swfdec_text_buffer_get_default_attributes(SwfdecTextBuffer
* buffer
);
85 void swfdec_text_buffer_set_default_attributes(SwfdecTextBuffer
* buffer
,
86 const SwfdecTextAttributes
*attr
,
88 void swfdec_text_buffer_reset_default_attributes(SwfdecTextBuffer
* buffer
);
90 SwfdecTextBufferIter
* swfdec_text_buffer_get_iter (SwfdecTextBuffer
* buffer
,
92 SwfdecTextBufferIter
* swfdec_text_buffer_iter_next (SwfdecTextBuffer
* buffer
,
93 SwfdecTextBufferIter
* iter
);
94 const SwfdecTextAttributes
*
95 swfdec_text_buffer_iter_get_attributes (SwfdecTextBuffer
* buffer
,
96 SwfdecTextBufferIter
* iter
);
97 gsize
swfdec_text_buffer_iter_get_start (SwfdecTextBuffer
* buffer
,
98 SwfdecTextBufferIter
* iter
);
100 gsize
swfdec_text_buffer_get_cursor (SwfdecTextBuffer
* buffer
);
101 gboolean
swfdec_text_buffer_has_selection (SwfdecTextBuffer
* buffer
);
102 void swfdec_text_buffer_get_selection (SwfdecTextBuffer
* buffer
,
105 void swfdec_text_buffer_set_cursor (SwfdecTextBuffer
* buffer
,