### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Gtk3/TextBuffer.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 3
#TL:1:Gnome::Gtk3::TextBuffer:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=head1 Gnome::Gtk3::TextBuffer

Stores attributed text for display in a B<Gnome::Gtk3::TextView>

=head1 Description

You may wish to begin by reading the [text widget conceptual overview](https://developer.gnome.org/gtk3/3.24/TextWidget.html) which gives an overview of all the objects and data types related to the text widget and how they work together.

=head2 See Also

B<Gnome::Gtk3::TextView>, B<Gnome::Gtk3::TextIter>, B<Gnome::Gtk3::TextMark>

=head1 Synopsis
=head2 Declaration

  unit class Gnome::Gtk3::TextBuffer;
  also is Gnome::GObject::Object;

=comment head2 Example

=end pod
#-------------------------------------------------------------------------------
use NativeCall;

use Gnome::N::X:api<1>;
use Gnome::N::N-GObject:api<1>;
use Gnome::N::NativeLib:api<1>;
use Gnome::GObject::Object:api<1>;
use Gnome::Gtk3::TextTag:api<1>;
use Gnome::Gtk3::TextTagTable:api<1>;
use Gnome::Gtk3::TextIter:api<1>;

#-------------------------------------------------------------------------------
# See /usr/include/gtk-3.0/gtk/gtktextbuffer.h
# https://developer.gnome.org/gtk3/stable/GtkTextBuffer.html
# https://developer.gnome.org/gtk3/stable/TextWidget.html
unit class Gnome::Gtk3::TextBuffer:auth<github:MARTIMM>:api<1>;
also is Gnome::GObject::Object;

#-------------------------------------------------------------------------------
=begin pod
=head1 Types
=end pod
#-------------------------------------------------------------------------------
=begin pod
=head2 enum GtkTextBufferTargetInfo

These values are used as “info” for the targets contained in the
lists returned by C<gtk_text_buffer_get_copy_target_list()> and
C<gtk_text_buffer_get_paste_target_list()>.

The values counts down from `-1` to avoid clashes
with application added drag destinations which usually start at 0.


=item GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS: Buffer contents
=item GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT: Rich text
=item GTK_TEXT_BUFFER_TARGET_INFO_TEXT: Text


=end pod

#TE:0:GtkTextBufferTargetInfo:
enum GtkTextBufferTargetInfo is export (
  'GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS' => - 1,
  'GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT'       => - 2,
  'GTK_TEXT_BUFFER_TARGET_INFO_TEXT'            => - 3
);

#-------------------------------------------------------------------------------
my Bool $signals-added = False;
#-------------------------------------------------------------------------------
=begin pod
=head1 Methods
=head2 new

Create a new plain object.

  multi method new ( )

Create an object using a native object from elsewhere. See also B<Gnome::GObject::Object>.

  multi method new ( N-GObject :$native-object! )

Create an object using a native object from a builder. See also B<Gnome::GObject::Object>.

  multi method new ( Str :$build-id! )

=end pod

#TM:1:new():
#TM:0:new(:native-object):
#TM:0:new(:build-id):

submethod BUILD ( *%options ) {

  # prevent creating wrong native-objects
  $signals-added = self.add-signal-types( $?CLASS.^name,
    :w0<changed modified-changed begin-user-action end-user-action>,
    :w1<mark-deleted paste-done>,
    :w2<insert-pixbuf insert-child-anchor delete-range mark-set>,
    :w3<insert-text apply-tag remove-tag>,
  ) unless $signals-added;

  return unless self.^name eq 'Gnome::Gtk3::TextBuffer';

  if ? %options<native-object> || ? %options<widget> || ? %options<build-id> {
    # provided in GObject
  }

  elsif %options.keys.elems {
    die X::Gnome.new(
      :message('Unsupported options for ' ~ self.^name ~
               ': ' ~ %options.keys.join(', ')
              )
    );
  }

  else {
    my Gnome::Gtk3::TextTagTable $tag-table .= new;
    self._set-native-object(gtk_text_buffer_new($tag-table._get-native-object));
  }

  # only after creating the native-object, the gtype is known
  self._set-class-info('GtkTextBuffer');
}

#-------------------------------------------------------------------------------
method _fallback ( $native-sub is copy --> Callable ) {

  my Callable $s;
  try { $s = &::("gtk_text_buffer_$native-sub"); };
  try { $s = &::("gtk_$native-sub"); } unless ?$s;
  try { $s = &::($native-sub); } if !$s and $native-sub ~~ m/^ 'gtk_' /;

  self._set-class-name-of-sub('GtkTextBuffer');
  $s = callsame unless ?$s;

  $s
}

#-------------------------------------------------------------------------------
#TM:2:gtk_text_buffer_new:new()
=begin pod
=head2 [gtk_] text_buffer_new

Creates a new text buffer.

Returns: a new text buffer

  method gtk_text_buffer_new ( N-GObject $table --> N-GObject  )

=item N-GObject $table; (allow-none): a tag table, or C<Any> to create a new one

=end pod

sub gtk_text_buffer_new ( N-GObject $table )
  returns N-GObject
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_get_line_count:
=begin pod
=head2 [[gtk_] text_buffer_] get_line_count

Obtains the number of lines in the buffer. This value is cached, so
the function is very fast.

Returns: number of lines in the buffer

  method gtk_text_buffer_get_line_count ( --> Int  )


=end pod

sub gtk_text_buffer_get_line_count ( N-GObject $buffer )
  returns int32
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_get_char_count:
=begin pod
=head2 [[gtk_] text_buffer_] get_char_count

Gets the number of characters in the buffer; note that characters
and bytes are not the same, you can’t e.g. expect the contents of
the buffer in string form to be this many bytes long. The character
count is cached, so this function is very fast.

Returns: number of characters in the buffer

  method gtk_text_buffer_get_char_count ( --> Int  )


=end pod

sub gtk_text_buffer_get_char_count ( N-GObject $buffer )
  returns int32
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_get_tag_table:
=begin pod
=head2 [[gtk_] text_buffer_] get_tag_table

Get the B<Gnome::Gtk3::TextTagTable> associated with this buffer.

Returns: (transfer none): the buffer’s tag table

  method gtk_text_buffer_get_tag_table ( --> N-GObject  )


=end pod

sub gtk_text_buffer_get_tag_table ( N-GObject $buffer )
  returns N-GObject
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_set_text:
=begin pod
=head2 [[gtk_] text_buffer_] set_text

Deletes current contents of I<buffer>, and inserts I<text> instead. If
I<len> is -1, I<text> must be nul-terminated. I<text> must be valid UTF-8.

  method gtk_text_buffer_set_text ( Str $text, Int $len )

=item Str $text; UTF-8 text to insert
=item Int $len; length of I<text> in bytes

=end pod

sub gtk_text_buffer_set_text ( N-GObject $buffer, Str $text ) {
  _gtk_text_buffer_set_text(
    $buffer, $text, $text.encode.bytes #`{{$text.chars}}
  );
}

sub _gtk_text_buffer_set_text ( N-GObject $buffer, Str $text, int32 $len )
  is native(&gtk-lib)
  is symbol('gtk_text_buffer_set_text')
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_insert:
=begin pod
=head2 [gtk_] text_buffer_insert

Inserts I<$len> bytes of I<$text> at position I<$iter>.  If I<$len> is -1,
I<text> must be nul-terminated and will be inserted in its
entirety. Emits the “insert-text” signal; insertion actually occurs
in the default handler for the signal. I<iter> is invalidated when
insertion occurs (because the buffer contents change), but the
default signal handler revalidates it to point to the end of the
inserted text.

  method gtk_text_buffer_insert (
    Gnome::Gtk3::TextIter $iter, Str $text, Int $len
  )

=item Gnome::Gtk3::TextIter $iter; a position in the buffer
=item Str $text; text in UTF-8 format
=item Int $len; length of text in bytes, or -1

=end pod

sub gtk_text_buffer_insert ( N-GObject $buffer, N-GTextIter $iter, Str $text, int32 $len )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_at_cursor:
=begin pod
=head2 [[gtk_] text_buffer_] insert_at_cursor

Simply calls C<gtk_text_buffer_insert()>, using the current
cursor position as the insertion point.

  method gtk_text_buffer_insert_at_cursor ( Str $text, Int $len )

=item Str $text; text in UTF-8 format
=item Int $len; length of text, in bytes

=end pod

sub gtk_text_buffer_insert_at_cursor ( N-GObject $buffer, Str $text, int32 $len )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_interactive:
=begin pod
=head2 [[gtk_] text_buffer_] insert_interactive

Like C<gtk_text_buffer_insert()>, but the insertion will not occur if
I<iter> is at a non-editable location in the buffer. Usually you
want to prevent insertions at ineditable locations if the insertion
results from a user action (is interactive).

I<default_editable> indicates the editability of text that doesn't
have a tag affecting editability applied to it. Typically the
result of C<gtk_text_view_get_editable()> is appropriate here.

Returns: whether text was actually inserted

  method gtk_text_buffer_insert_interactive (
    Gnome::Gtk3::TextIter $iter, Str $text, Int $len,
    Int $default_editable
    --> Int
  )

=item Gnome::Gtk3::TextIter $iter; a position in I<buffer>
=item Str $text; some UTF-8 text
=item Int $len; length of text in bytes, or -1
=item Int $default_editable; default editability of buffer

=end pod

sub gtk_text_buffer_insert_interactive ( N-GObject $buffer, N-GTextIter $iter, Str $text, int32 $len, int32 $default_editable )
  returns int32
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_interactive_at_cursor:
=begin pod
=head2 [[gtk_] text_buffer_] insert_interactive_at_cursor

Calls C<gtk_text_buffer_insert_interactive()> at the cursor
position.

I<default_editable> indicates the editability of text that doesn't
have a tag affecting editability applied to it. Typically the
result of C<gtk_text_view_get_editable()> is appropriate here.

Returns: whether text was actually inserted

  method gtk_text_buffer_insert_interactive_at_cursor ( Str $text, Int $len, Int $default_editable --> Int  )

=item Str $text; text in UTF-8 format
=item Int $len; length of text in bytes, or -1
=item Int $default_editable; default editability of buffer

=end pod

sub gtk_text_buffer_insert_interactive_at_cursor ( N-GObject $buffer, Str $text, int32 $len, int32 $default_editable )
  returns int32
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_range:
=begin pod
=head2 [[gtk_] text_buffer_] insert_range

Copies text, tags, and pixbufs between I<start> and I<end> (the order
of I<start> and I<end> doesn’t matter) and inserts the copy at I<iter>.
Used instead of simply getting/inserting text because it preserves
images and tags. If I<start> and I<end> are in a different buffer from
I<buffer>, the two buffers must share the same tag table.

Implemented via emissions of the insert_text and apply_tag signals,
so expect those.

  method gtk_text_buffer_insert_range (
    Gnome::Gtk3::TextIter $iter,
    Gnome::Gtk3::TextIter $start, Gnome::Gtk3::TextIter $end
  )

=item Gnome::Gtk3::TextIter $iter; a position in I<buffer>
=item Gnome::Gtk3::TextIter $start; a position in a B<Gnome::Gtk3::TextBuffer>
=item Gnome::Gtk3::TextIter $end; another position in the same buffer as I<start>

=end pod

sub gtk_text_buffer_insert_range ( N-GObject $buffer, N-GTextIter $iter, N-GObject $start, N-GObject $end )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_range_interactive:
=begin pod
=head2 [[gtk_] text_buffer_] insert_range_interactive

Same as C<gtk_text_buffer_insert_range()>, but does nothing if the
insertion point isn’t editable. The I<default_editable> parameter
indicates whether the text is editable at I<iter> if no tags
enclosing I<iter> affect editability. Typically the result of
C<gtk_text_view_get_editable()> is appropriate here.

Returns: whether an insertion was possible at I<iter>

  method gtk_text_buffer_insert_range_interactive (
    Gnome::Gtk3::TextIter $iter,
    Gnome::Gtk3::TextIter $start, Gnome::Gtk3::TextIter $end,
    Int $default_editable
    --> Int
  )

=item Gnome::Gtk3::TextIter $iter; a position in I<buffer>
=item Gnome::Gtk3::TextIter $start; a position in a B<Gnome::Gtk3::TextBuffer>
=item Gnome::Gtk3::TextIter $end; another position in the same buffer as I<start>
=item Int $default_editable; default editability of the buffer

=end pod

sub gtk_text_buffer_insert_range_interactive ( N-GObject $buffer, N-GTextIter $iter, N-GTextIter $start, N-GTextIter $end, int32 $default_editable )
  returns int32
  is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_with_tags:
=begin pod
=head2 [[gtk_] text_buffer_] insert_with_tags

Inserts I<text> into I<buffer> at I<iter>, applying the list of tags to
the newly-inserted text. The last tag specified must be C<Any> to
terminate the list. Equivalent to calling C<gtk_text_buffer_insert()>,
then C<gtk_text_buffer_apply_tag()> on the inserted text;
C<gtk_text_buffer_insert_with_tags()> is just a convenience function.

  method gtk_text_buffer_insert_with_tags ( Gnome::Gtk3::TextIter $iter, Str $text, Int $len, N-GObject $first_tag )

=item Gnome::Gtk3::TextIter $iter; an iterator in I<buffer>
=item Str $text; UTF-8 text
=item Int $len; length of I<text>, or -1
=item N-GObject $first_tag; first tag to apply to I<text> @...: C<Any>-terminated list of tags to apply

=end pod

sub gtk_text_buffer_insert_with_tags ( N-GObject $buffer, N-GTextIter $iter, Str $text, int32 $len, N-GObject $first_tag, Any $any = Any )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_with_tags_by_name:
=begin pod
=head2 [[gtk_] text_buffer_] insert_with_tags_by_name

Same as C<gtk_text_buffer_insert_with_tags()>, but allows you
to pass in tag names instead of tag objects.

  method gtk_text_buffer_insert_with_tags_by_name ( Gnome::Gtk3::TextIter $iter, Str $text, Int $len, Str $first_tag_name )

=item Gnome::Gtk3::TextIter $iter; position in I<buffer>
=item Str $text; UTF-8 text
=item Int $len; length of I<text>, or -1
=item Str $first_tag_name; name of a tag to apply to I<text> @...: more tag names

=end pod

sub gtk_text_buffer_insert_with_tags_by_name ( N-GObject $buffer, N-GTextIter $iter, Str $text, int32 $len, Str $first_tag_name, Any $any = Any )
  is native(&gtk-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_markup:
=begin pod
=head2 [[gtk_] text_buffer_] insert_markup

Inserts the text in I<markup> at position I<iter>. I<markup> will be inserted
in its entirety and must be nul-terminated and valid UTF-8. Emits the
 I<insert-text> signal, possibly multiple times; insertion
actually occurs in the default handler for the signal. I<iter> will point
to the end of the inserted text on return.


  method gtk_text_buffer_insert_markup (
    Gnome::Gtk3::TextIter $iter, Str $markup, Int $len
  )

=item Gnome::Gtk3::TextIter $iter; location to insert the markup
=item Str $markup; a nul-terminated UTF-8 string containing Pango markup
=item Int $len; length of I<markup> in bytes, or -1

=end pod

sub gtk_text_buffer_insert_markup ( N-GObject $buffer, N-GTextIter $iter, Str $markup, int32 $len )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_delete:
=begin pod
=head2 [gtk_] text_buffer_delete

Deletes text between I<start> and I<end>. The order of I<start> and I<end>
is not actually relevant; C<gtk_text_buffer_delete()> will reorder
them. This function actually emits the “delete-range” signal, and
the default handler of that signal deletes the text. Because the
buffer is modified, all outstanding iterators become invalid after
calling this function; however, the I<start> and I<end> will be
re-initialized to point to the location where text was deleted.

  method gtk_text_buffer_delete (
    Gnome::Gtk3::TextIter $start, Gnome::Gtk3::TextIter $end
  )

=item Gnome::Gtk3::TextIter $start; a position in I<buffer>
=item Gnome::Gtk3::TextIter $end; another position in I<buffer>

=end pod

sub gtk_text_buffer_delete ( N-GObject $buffer, N-GTextIter $start, N-GTextIter $end )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_delete_interactive:
=begin pod
=head2 [[gtk_] text_buffer_] delete_interactive

Deletes all editable text in the given range.
Calls C<gtk_text_buffer_delete()> for each editable sub-range of
[I<start>,I<end>). I<start> and I<end> are revalidated to point to
the location of the last deleted range, or left untouched if
no text was deleted.

Returns: whether some text was actually deleted

  method gtk_text_buffer_delete_interactive (
    Gnome::Gtk3::TextIter $start_iter, Gnome::Gtk3::TextIter $end_iter,
    Int $default_editable
    --> Int
  )

=item Gnome::Gtk3::TextIter $start_iter; start of range to delete
=item Gnome::Gtk3::TextIter $end_iter; end of range
=item Int $default_editable; whether the buffer is editable by default

=end pod

sub gtk_text_buffer_delete_interactive ( N-GObject $buffer, N-GTextIter $start_iter, N-GTextIter $end_iter, int32 $default_editable )
  returns int32
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_backspace:
=begin pod
=head2 [gtk_] text_buffer_backspace

Performs the appropriate action as if the user hit the delete
key with the cursor at the position specified by I<iter>. In the
normal case a single character will be deleted, but when
combining accents are involved, more than one character can
be deleted, and when precomposed character and accent combinations
are involved, less than one character will be deleted.

Because the buffer is modified, all outstanding iterators become
invalid after calling this function; however, the I<iter> will be
re-initialized to point to the location where text was deleted.

Returns: C<1> if the buffer was modified


  method gtk_text_buffer_backspace (
    Gnome::Gtk3::TextIter $iter, Int $interactive, Int $default_editable
    --> Int
  )

=item N-GObject $iter; a position in I<buffer>
=item Int $interactive; whether the deletion is caused by user interaction
=item Int $default_editable; whether the buffer is editable by default

=end pod

sub gtk_text_buffer_backspace ( N-GObject $buffer, N-GTextIter $iter, int32 $interactive, int32 $default_editable )
  returns int32
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_get_text:
=begin pod
=head2 [[gtk_] text_buffer_] get_text

Returns the text in the range [I<start>,I<end>). Excludes undisplayed
text (text marked with tags that set the invisibility attribute) if
I<include_hidden_chars> is C<0>. Does not include characters
representing embedded images, so byte and character indexes into
the returned string do not correspond to byte
and character indexes into the buffer. Contrast with
C<gtk_text_buffer_get_slice()>.

Returns: an allocated UTF-8 string

  method gtk_text_buffer_get_text (
    Gnome::Gtk3::TextIter $start, Gnome::Gtk3::TextIter $end,
    Int $include_hidden_chars --> Str
  )

=item Gnome::Gtk3::TextIter $start; start of a range
=item Gnome::Gtk3::TextIter $end; end of a range
=item Int $include_hidden_chars; whether to include invisible text

=end pod

sub gtk_text_buffer_get_text (
  N-GObject $buffer, N-GTextIter $start, N-GTextIter $end,
  int32 $include_hidden_chars
  --> Str
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:gtk_text_buffer_get_slice:
=begin pod
=head2 [[gtk_] text_buffer_] get_slice

Returns the text in the range [I<start>,I<end>). Excludes undisplayed
text (text marked with tags that set the invisibility attribute) if
I<include_hidden_chars> is C<0>. The returned string includes a
0xFFFC character whenever the buffer contains
embedded images, so byte and character indexes into
the returned string do correspond to byte
and character indexes into the buffer. Contrast with
C<gtk_text_buffer_get_text()>. Note that 0xFFFC can occur in normal
text as well, so it is not a reliable indicator that a pixbuf or
widget is in the buffer.

Returns: an allocated UTF-8 string

  method gtk_text_buffer_get_slice (
    Gnome::Gtk3::TextIter $start, Gnome::Gtk3::TextIter $end,
    Int $include_hidden_chars
    --> Str
  )

=item Gnome::Gtk3::TextIter $start; start of a range
=item Gnome::Gtk3::TextIter $end; end of a range
=item Int $include_hidden_chars; whether to include invisible text

=end pod

sub gtk_text_buffer_get_slice ( N-GObject $buffer, N-GTextIter $start, N-GTextIter $end, int32 $include_hidden_chars )
  returns Str
  is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_pixbuf:
=begin pod
=head2 [[gtk_] text_buffer_] insert_pixbuf

Inserts an image into the text buffer at I<iter>. The image will be
counted as one character in character counts, and when obtaining
the buffer contents as a string, will be represented by the Unicode
“object replacement character” 0xFFFC. Note that the “slice”
variants for obtaining portions of the buffer as a string include
this character for pixbufs, but the “text” variants do
not. e.g. see C<gtk_text_buffer_get_slice()> and
C<gtk_text_buffer_get_text()>.

  method gtk_text_buffer_insert_pixbuf ( Gnome::Gtk3::TextIter $iter, N-GObject $pixbuf )

=item Gnome::Gtk3::TextIter $iter; location to insert the pixbuf
=item N-GObject $pixbuf; a B<Gnome::Gdk3::Pixbuf>

=end pod

sub gtk_text_buffer_insert_pixbuf ( N-GObject $buffer, N-GTextIter $iter, N-GObject $pixbuf )
  is native(&gtk-lib)
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_insert_child_anchor:
=begin pod
=head2 [[gtk_] text_buffer_] insert_child_anchor

Inserts a child widget anchor into the text buffer at I<iter>. The
anchor will be counted as one character in character counts, and
when obtaining the buffer contents as a string, will be represented
by the Unicode “object replacement character” 0xFFFC. Note that the
“slice” variants for obtaining portions of the buffer as a string
include this character for child anchors, but the “text” variants do
not. E.g. see C<gtk_text_buffer_get_slice()> and
C<gtk_text_buffer_get_text()>. Consider
C<gtk_text_buffer_create_child_anchor()> as a more convenient
alternative to this function. The buffer will add a reference to
the anchor, so you can unref it after insertion.

  method gtk_text_buffer_insert_child_anchor ( Gnome::Gtk3::TextIter $iter, GtkTextChildAnchor $anchor )

=item Gnome::Gtk3::TextIter $iter; location to insert the anchor
=item GtkTextChildAnchor $anchor; a B<Gnome::Gtk3::TextChildAnchor>

=end pod

sub gtk_text_buffer_insert_child_anchor ( N-GObject $buffer, N-GTextIter $iter, GtkTextChildAnchor $anchor )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_create_child_anchor:
=begin pod
=head2 [[gtk_] text_buffer_] create_child_anchor

This is a convenience function which simply creates a child anchor
with C<gtk_text_child_anchor_new()> and inserts it into the buffer
with C<gtk_text_buffer_insert_child_anchor()>. The new anchor is
owned by the buffer; no reference count is returned to
the caller of C<gtk_text_buffer_create_child_anchor()>.

Returns: (transfer none): the created child anchor

  method gtk_text_buffer_create_child_anchor ( Gnome::Gtk3::TextIter $iter --> GtkTextChildAnchor  )

=item Gnome::Gtk3::TextIter $iter; location in the buffer

=end pod

sub gtk_text_buffer_create_child_anchor ( N-GObject $buffer, N-GTextIter $iter )
  returns GtkTextChildAnchor
  is native(&gtk-lib)
  { * }
}}

#`{{
#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_add_mark:
=begin pod
=head2 [[gtk_] text_buffer_] add_mark

Adds the mark at position I<where>. The mark must not be added to
another buffer, and if its name is not C<Any> then there must not
be another mark in the buffer with the same name.

Emits the  I<mark-set> signal as notification of the mark's
initial placement.


  method gtk_text_buffer_add_mark ( N-GObject $mark, N-GObject $where )

=item N-GObject $mark; the mark to add
=item N-GObject $where; location to place mark

=end pod

sub gtk_text_buffer_add_mark ( N-GObject $buffer, N-GObject $mark, N-GObject $where )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_create_mark:
=begin pod
=head2 [[gtk_] text_buffer_] create_mark

Creates a mark at position I<where>. If I<mark_name> is C<Any>, the mark
is anonymous; otherwise, the mark can be retrieved by name using
C<gtk_text_buffer_get_mark()>. If a mark has left gravity, and text is
inserted at the mark’s current location, the mark will be moved to
the left of the newly-inserted text. If the mark has right gravity
(I<left_gravity> = C<0>), the mark will end up on the right of
newly-inserted text. The standard left-to-right cursor is a mark
with right gravity (when you type, the cursor stays on the right
side of the text you’re typing).

The caller of this function does not own a
reference to the returned B<Gnome::Gtk3::TextMark>, so you can ignore the
return value if you like. Marks are owned by the buffer and go
away when the buffer does.

Emits the  I<mark-set> signal as notification of the mark's
initial placement.

Returns: (transfer none): the new B<Gnome::Gtk3::TextMark> object

  method gtk_text_buffer_create_mark ( Str $mark_name, N-GObject $where, Int $left_gravity --> N-GObject  )

=item Str $mark_name; (allow-none): name for mark, or C<Any>
=item N-GObject $where; location to place mark
=item Int $left_gravity; whether the mark has left gravity

=end pod

sub gtk_text_buffer_create_mark ( N-GObject $buffer, Str $mark_name, N-GObject $where, int32 $left_gravity )
  returns N-GObject
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_move_mark:
=begin pod
=head2 [[gtk_] text_buffer_] move_mark

Moves I<mark> to the new location I<where>. Emits the  I<mark-set>
signal as notification of the move.

  method gtk_text_buffer_move_mark ( N-GObject $mark, N-GObject $where )

=item N-GObject $mark; a B<Gnome::Gtk3::TextMark>
=item N-GObject $where; new location for I<mark> in I<buffer>

=end pod

sub gtk_text_buffer_move_mark ( N-GObject $buffer, N-GObject $mark, N-GObject $where )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_delete_mark:
=begin pod
=head2 [[gtk_] text_buffer_] delete_mark

Deletes I<mark>, so that it’s no longer located anywhere in the
buffer. Removes the reference the buffer holds to the mark, so if
you haven’t called C<g_object_ref()> on the mark, it will be freed. Even
if the mark isn’t freed, most operations on I<mark> become
invalid, until it gets added to a buffer again with
C<gtk_text_buffer_add_mark()>. Use C<gtk_text_mark_get_deleted()> to
find out if a mark has been removed from its buffer.
The  I<mark-deleted> signal will be emitted as notification after
the mark is deleted.

  method gtk_text_buffer_delete_mark ( N-GObject $mark )

=item N-GObject $mark; a B<Gnome::Gtk3::TextMark> in I<buffer>

=end pod

sub gtk_text_buffer_delete_mark ( N-GObject $buffer, N-GObject $mark )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_get_mark:
=begin pod
=head2 [[gtk_] text_buffer_] get_mark

Returns the mark named I<name> in buffer I<buffer>, or C<Any> if no such
mark exists in the buffer.

Returns: (nullable) (transfer none): a B<Gnome::Gtk3::TextMark>, or C<Any>

  method gtk_text_buffer_get_mark ( Str $name --> N-GObject  )

=item Str $name; a mark name

=end pod

sub gtk_text_buffer_get_mark ( N-GObject $buffer, Str $name )
  returns N-GObject
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_move_mark_by_name:
=begin pod
=head2 [[gtk_] text_buffer_] move_mark_by_name

Moves the mark named I<name> (which must exist) to location I<where>.
See C<gtk_text_buffer_move_mark()> for details.

  method gtk_text_buffer_move_mark_by_name ( Str $name, N-GObject $where )

=item Str $name; name of a mark
=item N-GObject $where; new location for mark

=end pod

sub gtk_text_buffer_move_mark_by_name ( N-GObject $buffer, Str $name, N-GObject $where )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_delete_mark_by_name:
=begin pod
=head2 [[gtk_] text_buffer_] delete_mark_by_name

Deletes the mark named I<name>; the mark must exist. See
C<gtk_text_buffer_delete_mark()> for details.

  method gtk_text_buffer_delete_mark_by_name ( Str $name )

=item Str $name; name of a mark in I<buffer>

=end pod

sub gtk_text_buffer_delete_mark_by_name ( N-GObject $buffer, Str $name )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_get_insert:
=begin pod
=head2 [[gtk_] text_buffer_] get_insert

Returns the mark that represents the cursor (insertion point).
Equivalent to calling C<gtk_text_buffer_get_mark()> to get the mark
named “insert”, but very slightly more efficient, and involves less
typing.

Returns: (transfer none): insertion point mark

  method gtk_text_buffer_get_insert ( --> N-GObject  )


=end pod

sub gtk_text_buffer_get_insert ( N-GObject $buffer )
  returns N-GObject
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_get_selection_bound:
=begin pod
=head2 [[gtk_] text_buffer_] get_selection_bound

Returns the mark that represents the selection bound.  Equivalent
to calling C<gtk_text_buffer_get_mark()> to get the mark named
“selection_bound”, but very slightly more efficient, and involves
less typing.

The currently-selected text in I<buffer> is the region between the
“selection_bound” and “insert” marks. If “selection_bound” and
“insert” are in the same place, then there is no current selection.
C<gtk_text_buffer_get_selection_bounds()> is another convenient function
for handling the selection, if you just want to know whether there’s a
selection and what its bounds are.

Returns: (transfer none): selection bound mark

  method gtk_text_buffer_get_selection_bound ( --> N-GObject  )


=end pod

sub gtk_text_buffer_get_selection_bound ( N-GObject $buffer )
  returns N-GObject
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_place_cursor:
=begin pod
=head2 [[gtk_] text_buffer_] place_cursor

This function moves the “insert” and “selection_bound” marks
simultaneously.  If you move them to the same place in two steps
with C<gtk_text_buffer_move_mark()>, you will temporarily select a
region in between their old and new locations, which can be pretty
inefficient since the temporarily-selected region will force stuff
to be recalculated. This function moves them as a unit, which can
be optimized.

  method gtk_text_buffer_place_cursor ( N-GObject $where )

=item N-GObject $where; where to put the cursor

=end pod

sub gtk_text_buffer_place_cursor ( N-GObject $buffer, N-GObject $where )
  is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:gtk_text_buffer_select_range:
=begin pod
=head2 [[gtk_] text_buffer_] select_range

This function moves the “insert” and “selection_bound” marks
simultaneously.  If you move them in two steps
with C<gtk_text_buffer_move_mark()>, you