2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkTextBuffer.html
27 * outFile = TextBuffer
28 * strct = GtkTextBuffer
44 * - gtk_text_buffer_set_text
45 * - gtk_text_buffer_insert_with_tags
46 * - gtk_text_buffer_insert_with_tags_by_name
47 * - gtk_text_buffer_create_tag
54 * - gtk.TextAttributes
59 * - gtk.TextChildAnchor
65 * - GdkBitmap* -> Bitmap
66 * - GdkPixbuf* -> Pixbuf
67 * - GdkRectangle* -> Rectangle
68 * - GtkClipboard* -> Clipboard
69 * - GtkTextAttributes* -> TextAttributes
70 * - GtkTextBuffer* -> TextBuffer
71 * - GtkTextChildAnchor* -> TextChildAnchor
72 * - GtkTextIter* -> TextIter
73 * - GtkTextMark* -> TextMark
74 * - GtkTextTag* -> TextTag
75 * - GtkTextTagTable* -> TextTagTable
76 * - GtkWidget* -> Widget
77 * - PangoTabArray* -> PgTabArray
82 module gtk
.TextBuffer
;
88 import tango
.io
.Stdout
; // use the tango loging?
92 private import gtkc
.gtktypes
;
94 private import gtkc
.gtk
;
97 private import glib
.Str
;
98 private import gtk
.TextBuffer
;
99 private import gdk
.Rectangle
;
100 private import gtk
.Widget
;
101 private import pango
.PgTabArray
;
102 private import gtk
.TextAttributes
;
103 private import gtk
.TextTagTable
;
104 private import gtk
.TextIter
;
105 private import gtk
.TextTag
;
106 private import gdk
.Pixbuf
;
107 private import gtk
.TextChildAnchor
;
108 private import gtk
.TextMark
;
109 private import gtk
.Clipboard
;
110 private import gdk
.Bitmap
;
114 private import tango
.core
.Vararg
;
116 private import std
.stdarg
;
124 * You may wish to begin by reading the text widget
125 * conceptual overview which gives an overview of all the objects and data
126 * types related to the text widget and how they work together.
128 private import gobject
.ObjectG
;
129 public class TextBuffer
: ObjectG
132 /** the main Gtk struct */
133 protected GtkTextBuffer
* gtkTextBuffer
;
136 public GtkTextBuffer
* getTextBufferStruct()
138 return gtkTextBuffer
;
142 /** the main Gtk struct as a void* */
143 protected void* getStruct()
145 return cast(void*)gtkTextBuffer
;
149 * Sets our main struct and passes it to the parent class
151 public this (GtkTextBuffer
* gtkTextBuffer
)
155 if ( gtkTextBuffer
is null )
160 Stdout("struct gtkTextBuffer is null on constructor").newline
;
164 printf("struct gtkTextBuffer is null on constructor");
171 assert(gtkTextBuffer
!is null, "struct gtkTextBuffer is null on constructor");
173 super(cast(GObject
*)gtkTextBuffer
);
174 this.gtkTextBuffer
= gtkTextBuffer
;
178 * Deletes current contents of buffer, and inserts text instead. If
179 * len is -1, text must be nul-terminated. text must be valid UTF-8.
183 * UTF-8 text to insert
185 * length of text in bytes
187 public void setText(char[] text
)
189 // void gtk_text_buffer_set_text (GtkTextBuffer *buffer, const gchar *text, gint len);
190 gtk_text_buffer_set_text(gtkTextBuffer
, Str
.toStringz(text
), text
.length
);
194 * Inserts len bytes of text at position iter. If len is -1,
195 * text must be nul-terminated and will be inserted in its
196 * entirety. Emits the "insert_text" signal; insertion actually occurs
197 * in the default handler for the signal. iter is invalidated when
198 * insertion occurs (because the buffer contents change), but the
199 * default signal handler revalidates it to point to the end of the
204 * a position in the buffer
206 * UTF-8 format text to insert
208 * length of text in bytes, or -1
210 public void insert(TextIter iter
, char[] text
)
212 // void gtk_text_buffer_insert (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len);
213 gtk_text_buffer_insert(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), Str
.toStringz(text
), text
.length
);
217 * Simply calls gtk_text_buffer_insert(), using the current
218 * cursor position as the insertion point.
222 * some text in UTF-8 format
224 * length of text, in bytes
226 public void insertAtCursor(char[] text
)
228 // void gtk_text_buffer_insert_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len);
229 gtk_text_buffer_insert_at_cursor(gtkTextBuffer
, Str
.toStringz(text
), text
.length
);
233 * Like gtk_text_buffer_insert(), but the insertion will not occur if
234 * iter is at a non-editable location in the buffer. Usually you
235 * want to prevent insertions at ineditable locations if the insertion
236 * results from a user action (is interactive).
237 * default_editable indicates the editability of text that doesn't
238 * have a tag affecting editability applied to it. Typically the
239 * result of gtk_text_view_get_editable() is appropriate here.
243 * a position in buffer
247 * length of text in bytes, or -1
249 * default editability of buffer
251 * whether text was actually inserted
253 public int insertInteractive(TextIter iter
, char[] text
, int defaultEditable
)
255 // gboolean gtk_text_buffer_insert_interactive (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, gboolean default_editable);
256 return gtk_text_buffer_insert_interactive(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), Str
.toStringz(text
), text
.length
, defaultEditable
);
260 * Calls gtk_text_buffer_insert_interactive() at the cursor
262 * default_editable indicates the editability of text that doesn't
263 * have a tag affecting editability applied to it. Typically the
264 * result of gtk_text_view_get_editable() is appropriate here.
268 * text in UTF-8 format
270 * length of text in bytes, or -1
272 * default editability of buffer
274 * whether text was actually inserted
276 public int insertInteractiveAtCursor(char[] text
, int defaultEditable
)
278 // gboolean gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len, gboolean default_editable);
279 return gtk_text_buffer_insert_interactive_at_cursor(gtkTextBuffer
, Str
.toStringz(text
), text
.length
, defaultEditable
);
283 * Inserts text into buffer at iter, applying the list of tags to
284 * the newly-inserted text. The last tag specified must be NULL to
285 * terminate the list. Equivalent to calling gtk_text_buffer_insert(),
286 * then gtk_text_buffer_apply_tag() on the inserted text;
287 * gtk_text_buffer_insert_with_tags() is just a convenience function.
291 * an iterator in buffer
295 * length of text, or -1
297 * first tag to apply to text
299 * NULL-terminated list of tags to apply
301 //version(Tango){} else -- still doesn't work on tango, but it compiles now
302 public void insertWithTags(TextIter iter
, char[] text
, ... )
304 for (int i
= 0; (i
<_arguments
.length
) && (_arguments
[i
] == typeid(TextTag
)); i
++)
306 TextTag tag
= va_arg
!(TextTag
)(_argptr
);
307 // void gtk_text_buffer_insert_with_tags (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, GtkTextTag *first_tag, ...);
308 gtk_text_buffer_insert_with_tags(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), Str
.toStringz(text
), text
.length
, (tag
is null) ?
null : tag
.getTextTagStruct(), null);
313 * Same as gtk_text_buffer_insert_with_tags(), but allows you
314 * to pass in tag names instead of tag objects.
322 * length of text, or -1
324 * name of a tag to apply to text
328 // version(Tango){} else -- still doesn't work on tango, but it compiles now
329 public void insertWithTagsByName(TextIter iter
, char[] text
, ... )
331 for (int i
= 0; (i
<_arguments
.length
) && (_arguments
[i
] == typeid(char[])); i
++)
333 char[] tagName
= va_arg
!(char[])(_argptr
);
334 // void gtk_text_buffer_insert_with_tags_by_name (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, const gchar *first_tag_name, ...);
335 gtk_text_buffer_insert_with_tags_by_name(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), Str
.toStringz(text
), text
.length
, Str
.toStringz(tagName
), null);
340 * Create a new tag for this buffer
341 * @param tagName can be null for no name
342 * @param propertyName
343 * @param propertyValue
345 TextTag
createTag(char[] tagName
, char[] propertyName
, int propertyValue
,
346 char[] propertyName1
, char[] propertyValue1
)
349 gtk_text_buffer_create_tag(gtkTextBuffer
,
350 Str
.toStringz(tagName
),
351 Str
.toStringz(propertyName
),propertyValue
,
352 Str
.toStringz(propertyName1
),
353 Str
.toStringz(propertyValue1
),
359 * Create a new tag for this buffer
360 * @param tagName can be null for no name
361 * @param propertyName
362 * @param propertyValue
364 TextTag
createTag(char[] tagName
, char[] propertyName
, int propertyValue
)
367 gtk_text_buffer_create_tag(gtkTextBuffer
,
368 Str
.toStringz(tagName
),
369 Str
.toStringz(propertyName
),propertyValue
,null)
375 * Create a new tag for this buffer
376 * @param tagName can be null for no name
377 * @param propertyName
378 * @param propertyValue
380 TextTag
createTag(char[] tagName
, char[] propertyName
, double propertyValue
)
383 gtk_text_buffer_create_tag(gtkTextBuffer
, Str
.toStringz(tagName
), Str
.toStringz(propertyName
),propertyValue
,null)
389 * Create a new tag for this buffer
390 * @param tagName can be null for no name
391 * @param propertyName
392 * @param propertyValue
393 * @param propertyName2
394 * @param propertyValue2
396 TextTag
createTag(char[] tagName
, char[] propertyName
, int propertyValue
, char[] propertyName2
, int propertyValue2
)
399 gtk_text_buffer_create_tag(gtkTextBuffer
, Str
.toStringz(tagName
), Str
.toStringz(propertyName
), propertyValue
, Str
.toStringz(propertyName2
), propertyValue2
, null)
403 TextTag
createTag(char[] tagName
, char[] propertyName
, int propertyValue
, char[] propertyName2
, int propertyValue2
, char[] propertyName3
, int propertyValue3
, char[] propertyName4
, int propertyValue4
, char[] propertyName5
, int propertyValue5
)
406 gtk_text_buffer_create_tag(gtkTextBuffer
, Str
.toStringz(tagName
), Str
.toStringz(propertyName
), propertyValue
, Str
.toStringz(propertyName2
), propertyValue2
, Str
.toStringz(propertyName3
), propertyValue3
, Str
.toStringz(propertyName4
), propertyValue4
, Str
.toStringz(propertyName5
), propertyValue5
, null)
410 * Create a new tag for this buffer
411 * @param tagName can be null for no name
412 * @param propertyName
413 * @param propertyValue
415 TextTag
createTag(char[] tagName
, char[] propertyName
, char[] propertyValue
)
418 gtk_text_buffer_create_tag(gtkTextBuffer
, Str
.toStringz(tagName
), Str
.toStringz(propertyName
),Str
.toStringz(propertyValue
),null)
424 * Create a new tag for this buffer
425 * @param tagName can be null for no name
426 * @param propertyName
427 * @param propertyValue
430 TextTag
createTag(char[] tagName
, char[] propertyName
, Bitmap propertyValue
)
433 gtk_text_buffer_create_tag(gtkTextBuffer
, Str
.toStringz(tagName
), Str
.toStringz(propertyName
),propertyValue
.getBitmapStruct(),null)
439 * Obtain the entire text
440 * @return The text char[]
444 TextIter start
= new TextIter();
445 TextIter end
= new TextIter();
446 getBounds(start
,end
);
447 return Str
.toString(gtk_text_buffer_get_slice(gtkTextBuffer
, start
.getTextIterStruct(), end
.getTextIterStruct(), true));
451 * Create a new tag for this buffer
452 * @param tagName can be null for no name
453 * @param propertyName
454 * @param propertyValue
455 * @param propertyName2
456 * @param propertyValue2
458 TextTag
createTag(char[] tagName
,
459 char[] propertyName
, char[] propertyValue
,
460 char[] propertyName2
, int propertyValue2
)
463 gtk_text_buffer_create_tag(gtkTextBuffer
, Str
.toStringz(tagName
),
464 Str
.toStringz(propertyName
), Str
.toStringz(propertyValue
),
465 Str
.toStringz(propertyName2
), propertyValue2
, null)
473 // imports for the signal processing
474 private import gobject
.Signals
;
475 private import gtkc
.gdktypes
;
476 int[char[]] connectedSignals
;
478 void delegate(TextTag
, TextIter
, TextIter
, TextBuffer
)[] onApplyTagListeners
;
479 void addOnApplyTag(void delegate(TextTag
, TextIter
, TextIter
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
481 if ( !("apply-tag" in connectedSignals
) )
486 cast(GCallback
)&callBackApplyTag
,
490 connectedSignals
["apply-tag"] = 1;
492 onApplyTagListeners
~= dlg
;
494 extern(C
) static void callBackApplyTag(GtkTextBuffer
* textbufferStruct
, GtkTextTag
* tag
, GtkTextIter
* start
, GtkTextIter
* end
, TextBuffer textBuffer
)
496 bool consumed
= false;
498 foreach ( void delegate(TextTag
, TextIter
, TextIter
, TextBuffer
) dlg
; textBuffer
.onApplyTagListeners
)
500 dlg(new TextTag(tag
), new TextIter(start
), new TextIter(end
), textBuffer
);
506 void delegate(TextBuffer
)[] onBeginUserActionListeners
;
507 void addOnBeginUserAction(void delegate(TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
509 if ( !("begin-user-action" in connectedSignals
) )
514 cast(GCallback
)&callBackBeginUserAction
,
518 connectedSignals
["begin-user-action"] = 1;
520 onBeginUserActionListeners
~= dlg
;
522 extern(C
) static void callBackBeginUserAction(GtkTextBuffer
* textbufferStruct
, TextBuffer textBuffer
)
524 bool consumed
= false;
526 foreach ( void delegate(TextBuffer
) dlg
; textBuffer
.onBeginUserActionListeners
)
534 void delegate(TextBuffer
)[] onChangedListeners
;
535 void addOnChanged(void delegate(TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
537 if ( !("changed" in connectedSignals
) )
542 cast(GCallback
)&callBackChanged
,
546 connectedSignals
["changed"] = 1;
548 onChangedListeners
~= dlg
;
550 extern(C
) static void callBackChanged(GtkTextBuffer
* textbufferStruct
, TextBuffer textBuffer
)
552 bool consumed
= false;
554 foreach ( void delegate(TextBuffer
) dlg
; textBuffer
.onChangedListeners
)
562 void delegate(TextIter
, TextIter
, TextBuffer
)[] onDeleteRangeListeners
;
563 void addOnDeleteRange(void delegate(TextIter
, TextIter
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
565 if ( !("delete-range" in connectedSignals
) )
570 cast(GCallback
)&callBackDeleteRange
,
574 connectedSignals
["delete-range"] = 1;
576 onDeleteRangeListeners
~= dlg
;
578 extern(C
) static void callBackDeleteRange(GtkTextBuffer
* textbufferStruct
, GtkTextIter
* start
, GtkTextIter
* end
, TextBuffer textBuffer
)
580 bool consumed
= false;
582 foreach ( void delegate(TextIter
, TextIter
, TextBuffer
) dlg
; textBuffer
.onDeleteRangeListeners
)
584 dlg(new TextIter(start
), new TextIter(end
), textBuffer
);
590 void delegate(TextBuffer
)[] onEndUserActionListeners
;
591 void addOnEndUserAction(void delegate(TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
593 if ( !("end-user-action" in connectedSignals
) )
598 cast(GCallback
)&callBackEndUserAction
,
602 connectedSignals
["end-user-action"] = 1;
604 onEndUserActionListeners
~= dlg
;
606 extern(C
) static void callBackEndUserAction(GtkTextBuffer
* textbufferStruct
, TextBuffer textBuffer
)
608 bool consumed
= false;
610 foreach ( void delegate(TextBuffer
) dlg
; textBuffer
.onEndUserActionListeners
)
618 void delegate(TextIter
, TextChildAnchor
, TextBuffer
)[] onInsertChildAnchorListeners
;
619 void addOnInsertChildAnchor(void delegate(TextIter
, TextChildAnchor
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
621 if ( !("insert-child-anchor" in connectedSignals
) )
625 "insert-child-anchor",
626 cast(GCallback
)&callBackInsertChildAnchor
,
630 connectedSignals
["insert-child-anchor"] = 1;
632 onInsertChildAnchorListeners
~= dlg
;
634 extern(C
) static void callBackInsertChildAnchor(GtkTextBuffer
* textbufferStruct
, GtkTextIter
* location
, GtkTextChildAnchor
* anchor
, TextBuffer textBuffer
)
636 bool consumed
= false;
638 foreach ( void delegate(TextIter
, TextChildAnchor
, TextBuffer
) dlg
; textBuffer
.onInsertChildAnchorListeners
)
640 dlg(new TextIter(location
), new TextChildAnchor(anchor
), textBuffer
);
646 void delegate(TextIter
, Pixbuf
, TextBuffer
)[] onInsertPixbufListeners
;
647 void addOnInsertPixbuf(void delegate(TextIter
, Pixbuf
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
649 if ( !("insert-pixbuf" in connectedSignals
) )
654 cast(GCallback
)&callBackInsertPixbuf
,
658 connectedSignals
["insert-pixbuf"] = 1;
660 onInsertPixbufListeners
~= dlg
;
662 extern(C
) static void callBackInsertPixbuf(GtkTextBuffer
* textbufferStruct
, GtkTextIter
* location
, GdkPixbuf
* pixbuf
, TextBuffer textBuffer
)
664 bool consumed
= false;
666 foreach ( void delegate(TextIter
, Pixbuf
, TextBuffer
) dlg
; textBuffer
.onInsertPixbufListeners
)
668 dlg(new TextIter(location
), new Pixbuf(pixbuf
), textBuffer
);
674 void delegate(TextIter
, char[], gint
, TextBuffer
)[] onInsertTextListeners
;
675 void addOnInsertText(void delegate(TextIter
, char[], gint
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
677 if ( !("insert-text" in connectedSignals
) )
682 cast(GCallback
)&callBackInsertText
,
686 connectedSignals
["insert-text"] = 1;
688 onInsertTextListeners
~= dlg
;
690 extern(C
) static void callBackInsertText(GtkTextBuffer
* textbufferStruct
, GtkTextIter
* location
, gchar
* text
, gint len
, TextBuffer textBuffer
)
692 bool consumed
= false;
694 foreach ( void delegate(TextIter
, char[], gint
, TextBuffer
) dlg
; textBuffer
.onInsertTextListeners
)
696 dlg(new TextIter(location
), Str
.toString(text
), len
, textBuffer
);
702 void delegate(TextMark
, TextBuffer
)[] onMarkDeletedListeners
;
703 void addOnMarkDeleted(void delegate(TextMark
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
705 if ( !("mark-deleted" in connectedSignals
) )
710 cast(GCallback
)&callBackMarkDeleted
,
714 connectedSignals
["mark-deleted"] = 1;
716 onMarkDeletedListeners
~= dlg
;
718 extern(C
) static void callBackMarkDeleted(GtkTextBuffer
* textbufferStruct
, GtkTextMark
* mark
, TextBuffer textBuffer
)
720 bool consumed
= false;
722 foreach ( void delegate(TextMark
, TextBuffer
) dlg
; textBuffer
.onMarkDeletedListeners
)
724 dlg(new TextMark(mark
), textBuffer
);
730 void delegate(TextIter
, TextMark
, TextBuffer
)[] onMarkSetListeners
;
731 void addOnMarkSet(void delegate(TextIter
, TextMark
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
733 if ( !("mark-set" in connectedSignals
) )
738 cast(GCallback
)&callBackMarkSet
,
742 connectedSignals
["mark-set"] = 1;
744 onMarkSetListeners
~= dlg
;
746 extern(C
) static void callBackMarkSet(GtkTextBuffer
* textbufferStruct
, GtkTextIter
* location
, GtkTextMark
* mark
, TextBuffer textBuffer
)
748 bool consumed
= false;
750 foreach ( void delegate(TextIter
, TextMark
, TextBuffer
) dlg
; textBuffer
.onMarkSetListeners
)
752 dlg(new TextIter(location
), new TextMark(mark
), textBuffer
);
758 void delegate(TextBuffer
)[] onModifiedChangedListeners
;
759 void addOnModifiedChanged(void delegate(TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
761 if ( !("modified-changed" in connectedSignals
) )
766 cast(GCallback
)&callBackModifiedChanged
,
770 connectedSignals
["modified-changed"] = 1;
772 onModifiedChangedListeners
~= dlg
;
774 extern(C
) static void callBackModifiedChanged(GtkTextBuffer
* textbufferStruct
, TextBuffer textBuffer
)
776 bool consumed
= false;
778 foreach ( void delegate(TextBuffer
) dlg
; textBuffer
.onModifiedChangedListeners
)
786 void delegate(TextTag
, TextIter
, TextIter
, TextBuffer
)[] onRemoveTagListeners
;
787 void addOnRemoveTag(void delegate(TextTag
, TextIter
, TextIter
, TextBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
789 if ( !("remove-tag" in connectedSignals
) )
794 cast(GCallback
)&callBackRemoveTag
,
798 connectedSignals
["remove-tag"] = 1;
800 onRemoveTagListeners
~= dlg
;
802 extern(C
) static void callBackRemoveTag(GtkTextBuffer
* textbufferStruct
, GtkTextTag
* tag
, GtkTextIter
* start
, GtkTextIter
* end
, TextBuffer textBuffer
)
804 bool consumed
= false;
806 foreach ( void delegate(TextTag
, TextIter
, TextIter
, TextBuffer
) dlg
; textBuffer
.onRemoveTagListeners
)
808 dlg(new TextTag(tag
), new TextIter(start
), new TextIter(end
), textBuffer
);
817 * Creates a new text buffer.
819 * a tag table, or NULL to create a new one
823 public this (TextTagTable table
)
825 // GtkTextBuffer* gtk_text_buffer_new (GtkTextTagTable *table);
826 this(cast(GtkTextBuffer
*)gtk_text_buffer_new((table
is null) ?
null : table
.getTextTagTableStruct()) );
830 * Obtains the number of lines in the buffer. This value is cached, so
831 * the function is very fast.
835 * number of lines in the buffer
837 public int getLineCount()
839 // gint gtk_text_buffer_get_line_count (GtkTextBuffer *buffer);
840 return gtk_text_buffer_get_line_count(gtkTextBuffer
);
844 * Gets the number of characters in the buffer; note that characters
845 * and bytes are not the same, you can't e.g. expect the contents of
846 * the buffer in string form to be this many bytes long. The character
847 * count is cached, so this function is very fast.
851 * number of characters in the buffer
853 public int getCharCount()
855 // gint gtk_text_buffer_get_char_count (GtkTextBuffer *buffer);
856 return gtk_text_buffer_get_char_count(gtkTextBuffer
);
860 * Get the GtkTextTagTable associated with this buffer.
864 * the buffer's tag table
866 public TextTagTable
getTagTable()
868 // GtkTextTagTable* gtk_text_buffer_get_tag_table (GtkTextBuffer *buffer);
869 return new TextTagTable( gtk_text_buffer_get_tag_table(gtkTextBuffer
) );
873 * Inserts len bytes of text at position iter. If len is -1,
874 * text must be nul-terminated and will be inserted in its
875 * entirety. Emits the "insert_text" signal; insertion actually occurs
876 * in the default handler for the signal. iter is invalidated when
877 * insertion occurs (because the buffer contents change), but the
878 * default signal handler revalidates it to point to the end of the
883 * a position in the buffer
885 * UTF-8 format text to insert
887 * length of text in bytes, or -1
889 public void insert(TextIter iter
, char[] text
, int len
)
891 // void gtk_text_buffer_insert (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len);
892 gtk_text_buffer_insert(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), Str
.toStringz(text
), len
);
896 * Simply calls gtk_text_buffer_insert(), using the current
897 * cursor position as the insertion point.
901 * some text in UTF-8 format
903 * length of text, in bytes
905 public void insertAtCursor(char[] text
, int len
)
907 // void gtk_text_buffer_insert_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len);
908 gtk_text_buffer_insert_at_cursor(gtkTextBuffer
, Str
.toStringz(text
), len
);
912 * Like gtk_text_buffer_insert(), but the insertion will not occur if
913 * iter is at a non-editable location in the buffer. Usually you
914 * want to prevent insertions at ineditable locations if the insertion
915 * results from a user action (is interactive).
916 * default_editable indicates the editability of text that doesn't
917 * have a tag affecting editability applied to it. Typically the
918 * result of gtk_text_view_get_editable() is appropriate here.
922 * a position in buffer
926 * length of text in bytes, or -1
928 * default editability of buffer
930 * whether text was actually inserted
932 public int insertInteractive(TextIter iter
, char[] text
, int len
, int defaultEditable
)
934 // gboolean gtk_text_buffer_insert_interactive (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, gboolean default_editable);
935 return gtk_text_buffer_insert_interactive(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), Str
.toStringz(text
), len
, defaultEditable
);
939 * Calls gtk_text_buffer_insert_interactive() at the cursor
941 * default_editable indicates the editability of text that doesn't
942 * have a tag affecting editability applied to it. Typically the
943 * result of gtk_text_view_get_editable() is appropriate here.
947 * text in UTF-8 format
949 * length of text in bytes, or -1
951 * default editability of buffer
953 * whether text was actually inserted
955 public int insertInteractiveAtCursor(char[] text
, int len
, int defaultEditable
)
957 // gboolean gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len, gboolean default_editable);
958 return gtk_text_buffer_insert_interactive_at_cursor(gtkTextBuffer
, Str
.toStringz(text
), len
, defaultEditable
);
962 * Copies text, tags, and pixbufs between start and end (the order
963 * of start and end doesn't matter) and inserts the copy at iter.
964 * Used instead of simply getting/inserting text because it preserves
965 * images and tags. If start and end are in a different buffer from
966 * buffer, the two buffers must share the same tag table.
967 * Implemented via emissions of the insert_text and apply_tag signals,
972 * a position in buffer
974 * a position in a GtkTextBuffer
976 * another position in the same buffer as start
978 public void insertRange(TextIter iter
, TextIter start
, TextIter end
)
980 // void gtk_text_buffer_insert_range (GtkTextBuffer *buffer, GtkTextIter *iter, const GtkTextIter *start, const GtkTextIter *end);
981 gtk_text_buffer_insert_range(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
985 * Same as gtk_text_buffer_insert_range(), but does nothing if the
986 * insertion point isn't editable. The default_editable parameter
987 * indicates whether the text is editable at iter if no tags
988 * enclosing iter affect editability. Typically the result of
989 * gtk_text_view_get_editable() is appropriate here.
993 * a position in buffer
995 * a position in a GtkTextBuffer
997 * another position in the same buffer as start
999 * default editability of the buffer
1001 * whether an insertion was possible at iter
1003 public int insertRangeInteractive(TextIter iter
, TextIter start
, TextIter end
, int defaultEditable
)
1005 // gboolean gtk_text_buffer_insert_range_interactive (GtkTextBuffer *buffer, GtkTextIter *iter, const GtkTextIter *start, const GtkTextIter *end, gboolean default_editable);
1006 return gtk_text_buffer_insert_range_interactive(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct(), defaultEditable
);
1012 * Deletes text between start and end. The order of start and end
1013 * is not actually relevant; gtk_text_buffer_delete() will reorder
1014 * them. This function actually emits the "delete_range" signal, and
1015 * the default handler of that signal deletes the text. Because the
1016 * buffer is modified, all outstanding iterators become invalid after
1017 * calling this function; however, the start and end will be
1018 * re-initialized to point to the location where text was deleted.
1022 * a position in buffer
1024 * another position in buffer
1026 public void delet(TextIter start
, TextIter end
)
1028 // void gtk_text_buffer_delete (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end);
1029 gtk_text_buffer_delete(gtkTextBuffer
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1033 * Deletes all editable text in the given range.
1034 * Calls gtk_text_buffer_delete() for each editable sub-range of
1035 * [start,end). start and end are revalidated to point to
1036 * the location of the last deleted range, or left untouched if
1037 * no text was deleted.
1041 * start of range to delete
1045 * whether the buffer is editable by default
1047 * whether some text was actually deleted
1049 public int deleteInteractive(TextIter startIter
, TextIter endIter
, int defaultEditable
)
1051 // gboolean gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer, GtkTextIter *start_iter, GtkTextIter *end_iter, gboolean default_editable);
1052 return gtk_text_buffer_delete_interactive(gtkTextBuffer
, (startIter
is null) ?
null : startIter
.getTextIterStruct(), (endIter
is null) ?
null : endIter
.getTextIterStruct(), defaultEditable
);
1056 * Performs the appropriate action as if the user hit the delete
1057 * key with the cursor at the position specified by iter. In the
1058 * normal case a single character will be deleted, but when
1059 * combining accents are involved, more than one character can
1060 * be deleted, and when precomposed character and accent combinations
1061 * are involved, less than one character will be deleted.
1062 * Because the buffer is modified, all outstanding iterators become
1063 * invalid after calling this function; however, the iter will be
1064 * re-initialized to point to the location where text was deleted.
1068 * a position in buffer
1070 * whether the deletion is caused by user interaction
1072 * whether the buffer is editable by default
1074 * TRUE if the buffer was modified
1077 public int backspace(TextIter iter
, int interactive
, int defaultEditable
)
1079 // gboolean gtk_text_buffer_backspace (GtkTextBuffer *buffer, GtkTextIter *iter, gboolean interactive, gboolean default_editable);
1080 return gtk_text_buffer_backspace(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), interactive
, defaultEditable
);
1085 * Returns the text in the range [start,end). Excludes undisplayed
1086 * text (text marked with tags that set the invisibility attribute) if
1087 * include_hidden_chars is FALSE. Does not include characters
1088 * representing embedded images, so byte and character indexes into
1089 * the returned string do not correspond to byte
1090 * and character indexes into the buffer. Contrast with
1091 * gtk_text_buffer_get_slice().
1098 * include_hidden_chars:
1099 * whether to include invisible text
1101 * an allocated UTF-8 string
1103 public char[] getText(TextIter start
, TextIter end
, int includeHiddenChars
)
1105 // gchar* gtk_text_buffer_get_text (GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end, gboolean include_hidden_chars);
1106 return Str
.toString(gtk_text_buffer_get_text(gtkTextBuffer
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct(), includeHiddenChars
) );
1110 * Returns the text in the range [start,end). Excludes undisplayed
1111 * text (text marked with tags that set the invisibility attribute) if
1112 * include_hidden_chars is FALSE. The returned string includes a
1113 * 0xFFFC character whenever the buffer contains
1114 * embedded images, so byte and character indexes into
1115 * the returned string do correspond to byte
1116 * and character indexes into the buffer. Contrast with
1117 * gtk_text_buffer_get_text(). Note that 0xFFFC can occur in normal
1118 * text as well, so it is not a reliable indicator that a pixbuf or
1119 * widget is in the buffer.
1126 * include_hidden_chars:
1127 * whether to include invisible text
1129 * an allocated UTF-8 string
1131 public char[] getSlice(TextIter start
, TextIter end
, int includeHiddenChars
)
1133 // gchar* gtk_text_buffer_get_slice (GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end, gboolean include_hidden_chars);
1134 return Str
.toString(gtk_text_buffer_get_slice(gtkTextBuffer
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct(), includeHiddenChars
) );
1138 * Inserts an image into the text buffer at iter. The image will be
1139 * counted as one character in character counts, and when obtaining
1140 * the buffer contents as a string, will be represented by the Unicode
1141 * "object replacement character" 0xFFFC. Note that the "slice"
1142 * variants for obtaining portions of the buffer as a string include
1143 * this character for pixbufs, but the "text" variants do
1144 * not. e.g. see gtk_text_buffer_get_slice() and
1145 * gtk_text_buffer_get_text().
1149 * location to insert the pixbuf
1153 public void insertPixbuf(TextIter iter
, Pixbuf pixbuf
)
1155 // void gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer, GtkTextIter *iter, GdkPixbuf *pixbuf);
1156 gtk_text_buffer_insert_pixbuf(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (pixbuf
is null) ?
null : pixbuf
.getPixbufStruct());
1160 * Inserts a child widget anchor into the text buffer at iter. The
1161 * anchor will be counted as one character in character counts, and
1162 * when obtaining the buffer contents as a string, will be represented
1163 * by the Unicode "object replacement character" 0xFFFC. Note that the
1164 * "slice" variants for obtaining portions of the buffer as a string
1165 * include this character for child anchors, but the "text" variants do
1166 * not. e.g. see gtk_text_buffer_get_slice() and
1167 * gtk_text_buffer_get_text(). Consider
1168 * gtk_text_buffer_create_child_anchor() as a more convenient
1169 * alternative to this function. The buffer will add a reference to
1170 * the anchor, so you can unref it after insertion.
1174 * location to insert the anchor
1176 * a GtkTextChildAnchor
1178 public void insertChildAnchor(TextIter iter
, TextChildAnchor anchor
)
1180 // void gtk_text_buffer_insert_child_anchor (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextChildAnchor *anchor);
1181 gtk_text_buffer_insert_child_anchor(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (anchor
is null) ?
null : anchor
.getTextChildAnchorStruct());
1185 * This is a convenience function which simply creates a child anchor
1186 * with gtk_text_child_anchor_new() and inserts it into the buffer
1187 * with gtk_text_buffer_insert_child_anchor(). The new anchor is
1188 * owned by the buffer; no reference count is returned to
1189 * the caller of gtk_text_buffer_create_child_anchor().
1193 * location in the buffer
1195 * the created child anchor
1197 public TextChildAnchor
createChildAnchor(TextIter iter
)
1199 // GtkTextChildAnchor* gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer, GtkTextIter *iter);
1200 return new TextChildAnchor( gtk_text_buffer_create_child_anchor(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct()) );
1204 * Creates a mark at position where. If mark_name is NULL, the mark
1205 * is anonymous; otherwise, the mark can be retrieved by name using
1206 * gtk_text_buffer_get_mark(). If a mark has left gravity, and text is
1207 * inserted at the mark's current location, the mark will be moved to
1208 * the left of the newly-inserted text. If the mark has right gravity
1209 * (left_gravity = FALSE), the mark will end up on the right of
1210 * newly-inserted text. The standard left-to-right cursor is a mark
1211 * with right gravity (when you type, the cursor stays on the right
1212 * side of the text you're typing).
1213 * The caller of this function does not own a reference
1214 * to the returned GtkTextMark, so you can ignore the return value
1215 * if you like. Marks are owned by the buffer and go away when the
1217 * Emits the "mark_set" signal as notification of the mark's initial
1222 * name for mark, or NULL
1224 * location to place mark
1226 * whether the mark has left gravity
1228 * the new GtkTextMark object
1230 public TextMark
createMark(char[] markName
, TextIter where
, int leftGravity
)
1232 // GtkTextMark* gtk_text_buffer_create_mark (GtkTextBuffer *buffer, const gchar *mark_name, const GtkTextIter *where, gboolean left_gravity);
1233 return new TextMark( gtk_text_buffer_create_mark(gtkTextBuffer
, Str
.toStringz(markName
), (where
is null) ?
null : where
.getTextIterStruct(), leftGravity
) );
1237 * Moves mark to the new location where. Emits the "mark_set" signal
1238 * as notification of the move.
1244 * new location for mark in buffer
1246 public void moveMark(TextMark mark
, TextIter where
)
1248 // void gtk_text_buffer_move_mark (GtkTextBuffer *buffer, GtkTextMark *mark, const GtkTextIter *where);
1249 gtk_text_buffer_move_mark(gtkTextBuffer
, (mark
is null) ?
null : mark
.getTextMarkStruct(), (where
is null) ?
null : where
.getTextIterStruct());
1253 * Moves the mark named name (which must exist) to location where.
1254 * See gtk_text_buffer_move_mark() for details.
1260 * new location for mark
1262 public void moveMarkByName(char[] name
, TextIter where
)
1264 // void gtk_text_buffer_move_mark_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *where);
1265 gtk_text_buffer_move_mark_by_name(gtkTextBuffer
, Str
.toStringz(name
), (where
is null) ?
null : where
.getTextIterStruct());
1269 * Deletes mark, so that it's no longer located anywhere in the
1270 * buffer. Removes the reference the buffer holds to the mark, so if
1271 * you haven't called g_object_ref() on the mark, it will be freed. Even
1272 * if the mark isn't freed, most operations on mark become
1273 * invalid. There is no way to undelete a
1274 * mark. gtk_text_mark_get_deleted() will return TRUE after this
1275 * function has been called on a mark; gtk_text_mark_get_deleted()
1276 * indicates that a mark no longer belongs to a buffer. The "mark_deleted"
1277 * signal will be emitted as notification after the mark is deleted.
1281 * a GtkTextMark in buffer
1283 public void deleteMark(TextMark mark
)
1285 // void gtk_text_buffer_delete_mark (GtkTextBuffer *buffer, GtkTextMark *mark);
1286 gtk_text_buffer_delete_mark(gtkTextBuffer
, (mark
is null) ?
null : mark
.getTextMarkStruct());
1290 * Deletes the mark named name; the mark must exist. See
1291 * gtk_text_buffer_delete_mark() for details.
1295 * name of a mark in buffer
1297 public void deleteMarkByName(char[] name
)
1299 // void gtk_text_buffer_delete_mark_by_name (GtkTextBuffer *buffer, const gchar *name);
1300 gtk_text_buffer_delete_mark_by_name(gtkTextBuffer
, Str
.toStringz(name
));
1304 * Returns the mark named name in buffer buffer, or NULL if no such
1305 * mark exists in the buffer.
1311 * a GtkTextMark, or NULL
1313 public TextMark
getMark(char[] name
)
1315 // GtkTextMark* gtk_text_buffer_get_mark (GtkTextBuffer *buffer, const gchar *name);
1316 return new TextMark( gtk_text_buffer_get_mark(gtkTextBuffer
, Str
.toStringz(name
)) );
1320 * Returns the mark that represents the cursor (insertion point).
1321 * Equivalent to calling gtk_text_buffer_get_mark() to get the mark
1322 * named "insert", but very slightly more efficient, and involves less
1327 * insertion point mark
1329 public TextMark
getInsert()
1331 // GtkTextMark* gtk_text_buffer_get_insert (GtkTextBuffer *buffer);
1332 return new TextMark( gtk_text_buffer_get_insert(gtkTextBuffer
) );
1336 * Returns the mark that represents the selection bound. Equivalent
1337 * to calling gtk_text_buffer_get_mark() to get the mark named
1338 * "selection_bound", but very slightly more efficient, and involves
1340 * The currently-selected text in buffer is the region between the
1341 * "selection_bound" and "insert" marks. If "selection_bound" and
1342 * "insert" are in the same place, then there is no current selection.
1343 * gtk_text_buffer_get_selection_bounds() is another convenient function
1344 * for handling the selection, if you just want to know whether there's a
1345 * selection and what its bounds are.
1349 * selection bound mark
1351 public TextMark
getSelectionBound()
1353 // GtkTextMark* gtk_text_buffer_get_selection_bound (GtkTextBuffer *buffer);
1354 return new TextMark( gtk_text_buffer_get_selection_bound(gtkTextBuffer
) );
1358 * Indicates whether the buffer has some text currently selected.
1362 * TRUE if the there is text selected
1365 public int getHasSelection()
1367 // gboolean gtk_text_buffer_get_has_selection (GtkTextBuffer *buffer);
1368 return gtk_text_buffer_get_has_selection(gtkTextBuffer
);
1372 * This function moves the "insert" and "selection_bound" marks
1373 * simultaneously. If you move them to the same place in two steps
1374 * with gtk_text_buffer_move_mark(), you will temporarily select a
1375 * region in between their old and new locations, which can be pretty
1376 * inefficient since the temporarily-selected region will force stuff
1377 * to be recalculated. This function moves them as a unit, which can
1382 * where to put the cursor
1384 public void placeCursor(TextIter where
)
1386 // void gtk_text_buffer_place_cursor (GtkTextBuffer *buffer, const GtkTextIter *where);
1387 gtk_text_buffer_place_cursor(gtkTextBuffer
, (where
is null) ?
null : where
.getTextIterStruct());
1391 * This function moves the "insert" and "selection_bound" marks
1392 * simultaneously. If you move them in two steps
1393 * with gtk_text_buffer_move_mark(), you will temporarily select a
1394 * region in between their old and new locations, which can be pretty
1395 * inefficient since the temporarily-selected region will force stuff
1396 * to be recalculated. This function moves them as a unit, which can
1401 * where to put the "insert" mark
1403 * where to put the "selection_bound" mark
1406 public void selectRange(TextIter
ins, TextIter
bound)
1408 // void gtk_text_buffer_select_range (GtkTextBuffer *buffer, const GtkTextIter *ins, const GtkTextIter *bound);
1409 gtk_text_buffer_select_range(gtkTextBuffer
, (ins is null) ?
null : ins.getTextIterStruct(), (bound is null) ?
null : bound.getTextIterStruct());
1413 * Emits the "apply_tag" signal on buffer. The default
1414 * handler for the signal applies tag to the given range.
1415 * start and end do not have to be in order.
1421 * one bound of range to be tagged
1423 * other bound of range to be tagged
1425 public void applyTag(TextTag tag
, TextIter start
, TextIter end
)
1427 // void gtk_text_buffer_apply_tag (GtkTextBuffer *buffer, GtkTextTag *tag, const GtkTextIter *start, const GtkTextIter *end);
1428 gtk_text_buffer_apply_tag(gtkTextBuffer
, (tag
is null) ?
null : tag
.getTextTagStruct(), (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1432 * Emits the "remove_tag" signal. The default handler for the signal
1433 * removes all occurrences of tag from the given range. start and
1434 * end don't have to be in order.
1440 * one bound of range to be untagged
1442 * other bound of range to be untagged
1444 public void removeTag(TextTag tag
, TextIter start
, TextIter end
)
1446 // void gtk_text_buffer_remove_tag (GtkTextBuffer *buffer, GtkTextTag *tag, const GtkTextIter *start, const GtkTextIter *end);
1447 gtk_text_buffer_remove_tag(gtkTextBuffer
, (tag
is null) ?
null : tag
.getTextTagStruct(), (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1451 * Calls gtk_text_tag_table_lookup() on the buffer's tag table to
1452 * get a GtkTextTag, then calls gtk_text_buffer_apply_tag().
1456 * name of a named GtkTextTag
1458 * one bound of range to be tagged
1460 * other bound of range to be tagged
1462 public void applyTagByName(char[] name
, TextIter start
, TextIter end
)
1464 // void gtk_text_buffer_apply_tag_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *start, const GtkTextIter *end);
1465 gtk_text_buffer_apply_tag_by_name(gtkTextBuffer
, Str
.toStringz(name
), (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1469 * Calls gtk_text_tag_table_lookup() on the buffer's tag table to
1470 * get a GtkTextTag, then calls gtk_text_buffer_remove_tag().
1474 * name of a GtkTextTag
1476 * one bound of range to be untagged
1478 * other bound of range to be untagged
1480 public void removeTagByName(char[] name
, TextIter start
, TextIter end
)
1482 // void gtk_text_buffer_remove_tag_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *start, const GtkTextIter *end);
1483 gtk_text_buffer_remove_tag_by_name(gtkTextBuffer
, Str
.toStringz(name
), (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1487 * Removes all tags in the range between start and end. Be careful
1488 * with this function; it could remove tags added in code unrelated to
1489 * the code you're currently writing. That is, using this function is
1490 * probably a bad idea if you have two or more unrelated code sections
1495 * one bound of range to be untagged
1497 * other bound of range to be untagged
1499 public void removeAllTags(TextIter start
, TextIter end
)
1501 // void gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end);
1502 gtk_text_buffer_remove_all_tags(gtkTextBuffer
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1507 * Obtains an iterator pointing to char_offset within the given
1508 * line. The char_offset must exist, offsets off the end of the line
1509 * are not allowed. Note characters, not bytes;
1510 * UTF-8 may encode one character as multiple bytes.
1514 * iterator to initialize
1516 * line number counting from 0
1518 * char offset from start of line
1520 public void getIterAtLineOffset(TextIter iter
, int lineNumber
, int charOffset
)
1522 // void gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer, GtkTextIter *iter, gint line_number, gint char_offset);
1523 gtk_text_buffer_get_iter_at_line_offset(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), lineNumber
, charOffset
);
1527 * Initializes iter to a position char_offset chars from the start
1528 * of the entire buffer. If char_offset is -1 or greater than the number
1529 * of characters in the buffer, iter is initialized to the end iterator,
1530 * the iterator one past the last valid character in the buffer.
1534 * iterator to initialize
1536 * char offset from start of buffer, counting from 0, or -1
1538 public void getIterAtOffset(TextIter iter
, int charOffset
)
1540 // void gtk_text_buffer_get_iter_at_offset (GtkTextBuffer *buffer, GtkTextIter *iter, gint char_offset);
1541 gtk_text_buffer_get_iter_at_offset(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), charOffset
);
1545 * Initializes iter to the start of the given line.
1549 * iterator to initialize
1551 * line number counting from 0
1553 public void getIterAtLine(TextIter iter
, int lineNumber
)
1555 // void gtk_text_buffer_get_iter_at_line (GtkTextBuffer *buffer, GtkTextIter *iter, gint line_number);
1556 gtk_text_buffer_get_iter_at_line(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), lineNumber
);
1560 * Obtains an iterator pointing to byte_index within the given line.
1561 * byte_index must be the start of a UTF-8 character, and must not be
1562 * beyond the end of the line. Note bytes, not
1563 * characters; UTF-8 may encode one character as multiple bytes.
1567 * iterator to initialize
1569 * line number counting from 0
1571 * byte index from start of line
1573 public void getIterAtLineIndex(TextIter iter
, int lineNumber
, int byteIndex
)
1575 // void gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer, GtkTextIter *iter, gint line_number, gint byte_index);
1576 gtk_text_buffer_get_iter_at_line_index(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), lineNumber
, byteIndex
);
1580 * Initializes iter with the current position of mark.
1584 * iterator to initialize
1586 * a GtkTextMark in buffer
1588 public void getIterAtMark(TextIter iter
, TextMark mark
)
1590 // void gtk_text_buffer_get_iter_at_mark (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextMark *mark);
1591 gtk_text_buffer_get_iter_at_mark(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (mark
is null) ?
null : mark
.getTextMarkStruct());
1595 * Obtains the location of anchor within buffer.
1599 * an iterator to be initialized
1601 * a child anchor that appears in buffer
1603 public void getIterAtChildAnchor(TextIter iter
, TextChildAnchor anchor
)
1605 // void gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextChildAnchor *anchor);
1606 gtk_text_buffer_get_iter_at_child_anchor(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (anchor
is null) ?
null : anchor
.getTextChildAnchorStruct());
1610 * Initialized iter with the first position in the text buffer. This
1611 * is the same as using gtk_text_buffer_get_iter_at_offset() to get
1612 * the iter at character offset 0.
1616 * iterator to initialize
1618 public void getStartIter(TextIter iter
)
1620 // void gtk_text_buffer_get_start_iter (GtkTextBuffer *buffer, GtkTextIter *iter);
1621 gtk_text_buffer_get_start_iter(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct());
1625 * Initializes iter with the "end iterator," one past the last valid
1626 * character in the text buffer. If dereferenced with
1627 * gtk_text_iter_get_char(), the end iterator has a character value of
1628 * 0. The entire buffer lies in the range from the first position in
1629 * the buffer (call gtk_text_buffer_get_start_iter() to get
1630 * character position 0) to the end iterator.
1634 * iterator to initialize
1636 public void getEndIter(TextIter iter
)
1638 // void gtk_text_buffer_get_end_iter (GtkTextBuffer *buffer, GtkTextIter *iter);
1639 gtk_text_buffer_get_end_iter(gtkTextBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct());
1643 * Retrieves the first and last iterators in the buffer, i.e. the
1644 * entire buffer lies within the range [start,end).
1648 * iterator to initialize with first position in the buffer
1650 * iterator to initialize with the end iterator
1652 public void getBounds(TextIter start
, TextIter end
)
1654 // void gtk_text_buffer_get_bounds (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end);
1655 gtk_text_buffer_get_bounds(gtkTextBuffer
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1659 * Indicates whether the buffer has been modified since the last call
1660 * to gtk_text_buffer_set_modified() set the modification flag to
1661 * FALSE. Used for example to enable a "save" function in a text
1666 * TRUE if the buffer has been modified
1668 public int getModified()
1670 // gboolean gtk_text_buffer_get_modified (GtkTextBuffer *buffer);
1671 return gtk_text_buffer_get_modified(gtkTextBuffer
);
1675 * Used to keep track of whether the buffer has been modified since the
1676 * last time it was saved. Whenever the buffer is saved to disk, call
1677 * gtk_text_buffer_set_modified (buffer, FALSE). When the buffer is modified,
1678 * it will automatically toggled on the modified bit again. When the modified
1679 * bit flips, the buffer emits a "modified_changed" signal.
1683 * modification flag setting
1685 public void setModified(int setting
)
1687 // void gtk_text_buffer_set_modified (GtkTextBuffer *buffer, gboolean setting);
1688 gtk_text_buffer_set_modified(gtkTextBuffer
, setting
);
1692 * Deletes the range between the "insert" and "selection_bound" marks,
1693 * that is, the currently-selected text. If interactive is TRUE,
1694 * the editability of the selection will be considered (users can't delete
1699 * whether the deletion is caused by user interaction
1701 * whether the buffer is editable by default
1703 * whether there was a non-empty selection to delete
1705 public int deleteSelection(int interactive
, int defaultEditable
)
1707 // gboolean gtk_text_buffer_delete_selection (GtkTextBuffer *buffer, gboolean interactive, gboolean default_editable);
1708 return gtk_text_buffer_delete_selection(gtkTextBuffer
, interactive
, defaultEditable
);
1712 * Pastes the contents of a clipboard at the insertion point, or at override_location.
1713 * (Note: pasting is asynchronous, that is, we'll ask for the paste data and
1714 * return, and at some point later after the main loop runs, the paste
1715 * data will be inserted.)
1719 * the GtkClipboard to paste from
1720 * override_location:
1721 * location to insert pasted text, or NULL for at the cursor
1723 * whether the buffer is editable by default
1725 public void pasteClipboard(Clipboard clipboard
, TextIter overrideLocation
, int defaultEditable
)
1727 // void gtk_text_buffer_paste_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard, GtkTextIter *override_location, gboolean default_editable);
1728 gtk_text_buffer_paste_clipboard(gtkTextBuffer
, (clipboard
is null) ?
null : clipboard
.getClipboardStruct(), (overrideLocation
is null) ?
null : overrideLocation
.getTextIterStruct(), defaultEditable
);
1732 * Copies the currently-selected text to a clipboard.
1736 * the GtkClipboard object to copy to.
1738 public void copyClipboard(Clipboard clipboard
)
1740 // void gtk_text_buffer_copy_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard);
1741 gtk_text_buffer_copy_clipboard(gtkTextBuffer
, (clipboard
is null) ?
null : clipboard
.getClipboardStruct());
1745 * Copies the currently-selected text to a clipboard, then deletes
1746 * said text if it's editable.
1750 * the GtkClipboard object to cut to.
1752 * default editability of the buffer
1754 public void cutClipboard(Clipboard clipboard
, int defaultEditable
)
1756 // void gtk_text_buffer_cut_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard, gboolean default_editable);
1757 gtk_text_buffer_cut_clipboard(gtkTextBuffer
, (clipboard
is null) ?
null : clipboard
.getClipboardStruct(), defaultEditable
);
1761 * Returns TRUE if some text is selected; places the bounds
1762 * of the selection in start and end (if the selection has length 0,
1763 * then start and end are filled in with the same value).
1764 * start and end will be in ascending order. If start and end are
1765 * NULL, then they are not filled in, but the return value still indicates
1766 * whether text is selected.
1768 * a GtkTextBuffer a GtkTextBuffer
1770 * iterator to initialize with selection start
1772 * iterator to initialize with selection end
1774 * whether the selection has nonzero length
1776 public int getSelectionBounds(TextIter start
, TextIter end
)
1778 // gboolean gtk_text_buffer_get_selection_bounds (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end);
1779 return gtk_text_buffer_get_selection_bounds(gtkTextBuffer
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct());
1783 * Called to indicate that the buffer operations between here and a
1784 * call to gtk_text_buffer_end_user_action() are part of a single
1785 * user-visible operation. The operations between
1786 * gtk_text_buffer_begin_user_action() and
1787 * gtk_text_buffer_end_user_action() can then be grouped when creating
1788 * an undo stack. GtkTextBuffer maintains a count of calls to
1789 * gtk_text_buffer_begin_user_action() that have not been closed with
1790 * a call to gtk_text_buffer_end_user_action(), and emits the "begin_user_action"
1791 * and "end_user_action" signals only for the outermost pair of calls.
1792 * This allows you to build user actions from other user actions.
1793 * The "interactive" buffer mutation functions, such as
1794 * gtk_text_buffer_insert_interactive(), automatically call begin/end
1795 * user action around the buffer operations they perform, so there's
1796 * no need to add extra calls if you user action consists solely of a
1797 * single call to one of those functions.
1801 public void beginUserAction()
1803 // void gtk_text_buffer_begin_user_action (GtkTextBuffer *buffer);
1804 gtk_text_buffer_begin_user_action(gtkTextBuffer
);
1808 * Should be paired with a call to gtk_text_buffer_begin_user_action().
1809 * See that function for a full explanation.
1813 public void endUserAction()
1815 // void gtk_text_buffer_end_user_action (GtkTextBuffer *buffer);
1816 gtk_text_buffer_end_user_action(gtkTextBuffer
);
1820 * Adds clipboard to the list of clipboards in which the selection contents
1821 * of buffer are available. In most cases, clipboard will be the GtkClipboard
1822 * of type GDK_SELECTION_PRIMARY for a view of buffer.
1828 public void addSelectionClipboard(Clipboard clipboard
)
1830 // void gtk_text_buffer_add_selection_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard);
1831 gtk_text_buffer_add_selection_clipboard(gtkTextBuffer
, (clipboard
is null) ?
null : clipboard
.getClipboardStruct());
1835 * Removes a GtkClipboard added with gtk_text_buffer_add_selection_clipboard()
1839 * a GtkClipboard added to buffer by gtk_text_buffer_add_selection_clipboard().
1841 public void removeSelectionClipboard(Clipboard clipboard
)
1843 // void gtk_text_buffer_remove_selection_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard);
1844 gtk_text_buffer_remove_selection_clipboard(gtkTextBuffer
, (clipboard
is null) ?
null : clipboard
.getClipboardStruct());
1850 * This function deserializes rich text in format format and inserts
1852 * formats to be used must be registered using
1853 * gtk_text_buffer_register_deserialize_format() or
1854 * gtk_text_buffer_register_deserialize_tagset() beforehand.
1856 * the GtkTextBuffer format is registered with
1858 * the GtkTextBuffer to deserialize into
1860 * the rich text format to use for deserializing
1862 * insertion point for the deserialized text
1864 * data to deserialize
1868 * return location for a GError
1870 * TRUE on success, FALSE otherwise.
1873 public int deserialize(TextBuffer contentBuffer
, GdkAtom format
, TextIter iter
, byte* data
, uint length
, GError
** error
)
1875 // gboolean gtk_text_buffer_deserialize (GtkTextBuffer *register_buffer, GtkTextBuffer *content_buffer, GdkAtom format, GtkTextIter *iter, const guint8 *data, gsize length, GError **error);
1876 return gtk_text_buffer_deserialize(gtkTextBuffer
, (contentBuffer
is null) ?
null : contentBuffer
.getTextBufferStruct(), format
, (iter
is null) ?
null : iter
.getTextIterStruct(), data
, length
, error
);
1880 * This functions returns the value set with
1881 * gtk_text_buffer_deserialize_set_can_create_tags()
1885 * a GdkAtom representing a registered rich text format
1887 * whether deserializing this format may create tags
1890 public int deserializeGetCanCreateTags(GdkAtom format
)
1892 // gboolean gtk_text_buffer_deserialize_get_can_create_tags (GtkTextBuffer *buffer, GdkAtom format);
1893 return gtk_text_buffer_deserialize_get_can_create_tags(gtkTextBuffer
, format
);
1897 * Use this function to allow a rich text deserialization function to
1898 * create new tags in the receiving buffer. Note that using this
1899 * function is almost always a bad idea, because the rich text
1900 * functions you register should know how to map the rich text format
1901 * they handler to your text buffers set of tags.
1902 * The ability of creating new (arbitrary!) tags in the receiving buffer
1903 * is meant for special rich text formats like the internal one that
1904 * is registered using gtk_text_buffer_register_deserialize_tagset(),
1905 * because that format is essentially a dump of the internal structure
1906 * of the source buffer, including its tag names.
1907 * You should allow creation of tags only if you know what you are
1908 * doing, e.g. if you defined a tagset name for your application
1909 * suite's text buffers and you know that it's fine to receive new
1910 * tags from these buffers, because you know that your application can
1911 * handle the newly created tags.
1915 * a GdkAtom representing a registered rich text format
1917 * whether deserializing this format may create tags
1920 public void deserializeSetCanCreateTags(GdkAtom format
, int canCreateTags
)
1922 // void gtk_text_buffer_deserialize_set_can_create_tags (GtkTextBuffer *buffer, GdkAtom format, gboolean can_create_tags);
1923 gtk_text_buffer_deserialize_set_can_create_tags(gtkTextBuffer
, format
, canCreateTags
);
1927 * This function returns the list of targets this text buffer can
1928 * provide for copying and as DND source. The targets in the list are
1929 * added with info values from the GtkTextBufferTargetInfo enum,
1930 * using gtk_target_list_add_rich_text_targets() and
1931 * gtk_target_list_add_text_targets()
1938 public GtkTargetList
* getCopyTargetList()
1940 // GtkTargetList* gtk_text_buffer_get_copy_target_list (GtkTextBuffer *buffer);
1941 return gtk_text_buffer_get_copy_target_list(gtkTextBuffer
);
1945 * This function returns the rich text deserialize formats registered
1946 * with buffer using gtk_text_buffer_register_deserialize_format() or
1947 * gtk_text_buffer_register_deserialize_tagset()
1951 * return location for the number of formats
1953 * an array of GdkAtoms representing the registered
1957 public GdkAtom
* getDeserializeFormats(int* nFormats
)
1959 // GdkAtom* gtk_text_buffer_get_deserialize_formats (GtkTextBuffer *buffer, gint *n_formats);
1960 return gtk_text_buffer_get_deserialize_formats(gtkTextBuffer
, nFormats
);
1964 * This function returns the list of targets this text buffer supports
1965 * for pasting and as DND destination. The targets in the list are
1966 * added with info values from the GtkTextBufferTargetInfo enum,
1967 * using gtk_target_list_add_rich_text_targets() and
1968 * gtk_target_list_add_text_targets()
1975 public GtkTargetList
* getPasteTargetList()
1977 // GtkTargetList* gtk_text_buffer_get_paste_target_list (GtkTextBuffer *buffer);
1978 return gtk_text_buffer_get_paste_target_list(gtkTextBuffer
);
1982 * This function returns the rich text serialize formats registered
1983 * with buffer using gtk_text_buffer_register_serialize_format() or
1984 * gtk_text_buffer_register_serialize_tagset()
1988 * return location for the number of formats
1990 * an array of GdkAtoms representing the registered
1994 public GdkAtom
* getSerializeFormats(int* nFormats
)
1996 // GdkAtom* gtk_text_buffer_get_serialize_formats (GtkTextBuffer *buffer, gint *n_formats);
1997 return gtk_text_buffer_get_serialize_formats(gtkTextBuffer
, nFormats
);
2001 * This function registers a rich text deserialization function along with
2002 * its mime_type with the passed buffer.
2006 * the format's mime-type
2008 * the deserialize function to register
2010 * function's user_data
2011 * user_data_destroy:
2012 * a function to call when user_data is no longer needed
2014 * the GdkAtom that corresponds to the newly registered
2015 * format's mime-type.
2018 public GdkAtom
registerDeserializeFormat(char[] mimeType
, GtkTextBufferDeserializeFunc funct
, void* userData
, GDestroyNotify userDataDestroy
)
2020 // GdkAtom gtk_text_buffer_register_deserialize_format (GtkTextBuffer *buffer, const gchar *mime_type, GtkTextBufferDeserializeFunc function, gpointer user_data, GDestroyNotify user_data_destroy);
2021 return gtk_text_buffer_register_deserialize_format(gtkTextBuffer
, Str
.toStringz(mimeType
), funct
, userData
, userDataDestroy
);
2025 * This function registers GTK+'s internal rich text serialization
2026 * format with the passed buffer. See
2027 * gtk_text_buffer_register_serialize_tagset() for details.
2031 * an optional tagset name, on NULL
2033 * the GdkAtom that corresponds to the newly registered
2034 * format's mime-type.
2037 public GdkAtom
registerDeserializeTagset(char[] tagsetName
)
2039 // GdkAtom gtk_text_buffer_register_deserialize_tagset (GtkTextBuffer *buffer, const gchar *tagset_name);
2040 return gtk_text_buffer_register_deserialize_tagset(gtkTextBuffer
, Str
.toStringz(tagsetName
));
2044 * This function registers a rich text serialization function along with
2045 * its mime_type with the passed buffer.
2049 * the format's mime-type
2051 * the serialize function to register
2053 * function's user_data
2054 * user_data_destroy:
2055 * a function to call when user_data is no longer needed
2057 * the GdkAtom that corresponds to the newly registered
2058 * format's mime-type.
2061 public GdkAtom
registerSerializeFormat(char[] mimeType
, GtkTextBufferSerializeFunc funct
, void* userData
, GDestroyNotify userDataDestroy
)
2063 // GdkAtom gtk_text_buffer_register_serialize_format (GtkTextBuffer *buffer, const gchar *mime_type, GtkTextBufferSerializeFunc function, gpointer user_data, GDestroyNotify user_data_destroy);
2064 return gtk_text_buffer_register_serialize_format(gtkTextBuffer
, Str
.toStringz(mimeType
), funct
, userData
, userDataDestroy
);
2068 * This function registers GTK+'s internal rich text serialization
2069 * format with the passed buffer. The internal format does not comply
2070 * to any standard rich text format and only works between GtkTextBuffer
2071 * instances. It is capable of serializing all of a text buffer's tags
2072 * and embedded pixbufs.
2073 * This function is just a wrapper around
2074 * gtk_text_buffer_register_serialize_format(). The mime type used
2075 * for registering is "application/x-gtk-text-buffer-rich-text", or
2076 * "application/x-gtk-text-buffer-rich-text;format=tagset_name" if a
2077 * tagset_name was passed.
2078 * The tagset_name can be used to restrict the transfer of rich text
2079 * to buffers with compatible sets of tags, in order to avoid unknown
2080 * tags from being pasted. It is probably the common case to pass an
2081 * identifier != NULL here, since the NULL tagset requires the
2082 * receiving buffer to deal with with pasting of arbitrary tags.
2086 * an optional tagset name, on NULL
2088 * the GdkAtom that corresponds to the newly registered
2089 * format's mime-type.
2092 public GdkAtom
registerSerializeTagset(char[] tagsetName
)
2094 // GdkAtom gtk_text_buffer_register_serialize_tagset (GtkTextBuffer *buffer, const gchar *tagset_name);
2095 return gtk_text_buffer_register_serialize_tagset(gtkTextBuffer
, Str
.toStringz(tagsetName
));
2100 * This function serializes the portion of text between start
2101 * and end in the rich text format represented by format.
2102 * formats to be used must be registered using
2103 * gtk_text_buffer_register_serialize_format() or
2104 * gtk_text_buffer_register_serialize_tagset() beforehand.
2106 * the GtkTextBuffer format is registered with
2108 * the GtkTextBuffer to serialize
2110 * the rich text format to use for serializing
2112 * start of block of text to serialize
2114 * end of block of test to serialize
2116 * return location for the length of the serialized data
2118 * the serialized data, encoded as format
2121 public byte* serialize(TextBuffer contentBuffer
, GdkAtom format
, TextIter start
, TextIter end
, uint* length
)
2123 // guint8* gtk_text_buffer_serialize (GtkTextBuffer *register_buffer, GtkTextBuffer *content_buffer, GdkAtom format, const GtkTextIter *start, const GtkTextIter *end, gsize *length);
2124 return gtk_text_buffer_serialize(gtkTextBuffer
, (contentBuffer
is null) ?
null : contentBuffer
.getTextBufferStruct(), format
, (start
is null) ?
null : start
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct(), length
);
2128 * This function unregisters a rich text format that was previously
2129 * registered using gtk_text_buffer_register_deserialize_format() or
2130 * gtk_text_buffer_register_deserialize_tagset().
2134 * a GdkAtom representing a registered rich text format.
2137 public void unregisterDeserializeFormat(GdkAtom format
)
2139 // void gtk_text_buffer_unregister_deserialize_format (GtkTextBuffer *buffer, GdkAtom format);
2140 gtk_text_buffer_unregister_deserialize_format(gtkTextBuffer
, format
);
2144 * This function unregisters a rich text format that was previously
2145 * registered using gtk_text_buffer_register_serialize_format() or
2146 * gtk_text_buffer_register_serialize_tagset()
2150 * a GdkAtom representing a registered rich text format.
2153 * The "copy-target-list" property
2154 * "copy-target-list" GtkTargetList : Read
2155 * The list of targets this buffer supports for clipboard copying
2156 * and as DND source.
2159 public void unregisterSerializeFormat(GdkAtom format
)
2161 // void gtk_text_buffer_unregister_serialize_format (GtkTextBuffer *buffer, GdkAtom format);
2162 gtk_text_buffer_unregister_serialize_format(gtkTextBuffer
, format
);