///|
/// Iterates over the clusters in a shaped `GlyphItem`.
///
/// The iterator keeps both the glyph item and its UTF-8 text alive. Its state
/// is mutable, so each iterator should be advanced by only one caller at a
/// time.
pub type GlyphItemIter

///|
#borrow(glyph_item, text)
extern "c" fn moonbit_pango_glyph_item_iter_from_start(
  glyph_item : GlyphItem,
  text : Bytes,
) -> @glib.Nullable[GlyphItemIter] = "moonbit_pango_glyph_item_iter_from_start"

///|
/// Creates an iterator positioned at the first cluster.
pub fn GlyphItemIter::from_start(
  glyph_item : GlyphItem,
  text : String,
) -> GlyphItemIter? {
  moonbit_pango_glyph_item_iter_from_start(
    glyph_item,
    @encoding/utf8.encode(text),
  ).to_option()
}

///|
#borrow(glyph_item, text)
extern "c" fn moonbit_pango_glyph_item_iter_from_end(
  glyph_item : GlyphItem,
  text : Bytes,
) -> @glib.Nullable[GlyphItemIter] = "moonbit_pango_glyph_item_iter_from_end"

///|
/// Creates an iterator positioned at the last cluster.
pub fn GlyphItemIter::from_end(
  glyph_item : GlyphItem,
  text : String,
) -> GlyphItemIter? {
  moonbit_pango_glyph_item_iter_from_end(
    glyph_item,
    @encoding/utf8.encode(text),
  ).to_option()
}

///|
/// Advances to the next cluster, returning `false` at the end.
#borrow(self_)
pub extern "c" fn GlyphItemIter::next_cluster(self_ : GlyphItemIter) -> Bool = "moonbit_pango_glyph_item_iter_next_cluster"

///|
/// Moves to the previous cluster, returning `false` at the beginning.
#borrow(self_)
pub extern "c" fn GlyphItemIter::prev_cluster(self_ : GlyphItemIter) -> Bool = "moonbit_pango_glyph_item_iter_prev_cluster"

///|
/// The first glyph index in the current cluster.
#borrow(self_)
pub extern "c" fn GlyphItemIter::get_start_glyph(self_ : GlyphItemIter) -> Int = "moonbit_pango_glyph_item_iter_start_glyph_get"

///|
/// The first UTF-8 byte index in the current cluster.
#borrow(self_)
pub extern "c" fn GlyphItemIter::get_start_index(self_ : GlyphItemIter) -> Int = "moonbit_pango_glyph_item_iter_start_index_get"

///|
/// The first character index in the current cluster.
#borrow(self_)
pub extern "c" fn GlyphItemIter::get_start_char(self_ : GlyphItemIter) -> Int = "moonbit_pango_glyph_item_iter_start_char_get"

///|
/// The glyph index immediately after the current cluster.
#borrow(self_)
pub extern "c" fn GlyphItemIter::get_end_glyph(self_ : GlyphItemIter) -> Int = "moonbit_pango_glyph_item_iter_end_glyph_get"

///|
/// The UTF-8 byte index immediately after the current cluster.
#borrow(self_)
pub extern "c" fn GlyphItemIter::get_end_index(self_ : GlyphItemIter) -> Int = "moonbit_pango_glyph_item_iter_end_index_get"

///|
/// The character index immediately after the current cluster.
#borrow(self_)
pub extern "c" fn GlyphItemIter::get_end_char(self_ : GlyphItemIter) -> Int = "moonbit_pango_glyph_item_iter_end_char_get"