// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/iface.Editable.html).
pub type Editable

///|
pub(open) trait IEditable {
  fn as_editable(Self) -> Editable
  fn delegate_get_accessible_platform_state(Self, AccessiblePlatformState) -> Bool = _
  fn delete_selection(Self) -> Unit = _
  fn delete_text(Self, Int, Int) -> Unit = _
  fn finish_delegate(Self) -> Unit = _
  fn get_alignment(Self) -> Float = _
  fn get_chars(Self, Int, Int) -> String = _
  fn get_delegate(Self) -> Editable? = _
  fn get_editable(Self) -> Bool = _
  fn get_enable_undo(Self) -> Bool = _
  fn get_max_width_chars(Self) -> Int = _
  fn get_position(Self) -> Int = _
  fn get_selection_bounds(Self) -> (Bool, Int, Int) = _
  fn get_text(Self) -> String = _
  fn get_width_chars(Self) -> Int = _
  fn init_delegate(Self) -> Unit = _
  fn insert_text(Self, String, Int, Int) -> Int = _
  fn select_region(Self, Int, Int) -> Unit = _
  fn set_alignment(Self, Float) -> Unit = _
  fn set_editable(Self, Bool) -> Unit = _
  fn set_enable_undo(Self, Bool) -> Unit = _
  fn set_max_width_chars(Self, Int) -> Unit = _
  fn set_position(Self, Int) -> Unit = _
  fn set_text(Self, String) -> Unit = _
  fn set_width_chars(Self, Int) -> Unit = _
}

///|
pub impl IEditable for Editable with fn as_editable(self) {
  self
}

///|
/// Implementation contract for Editable.changed. Self is the retained MoonBit state; the second parameter is the invoked Editable object.
pub(open) trait VEditableChanged {
  fn changed(Self, Editable) -> Unit
}

///|
/// Implementation contract for Editable.delete_text. Self is the retained MoonBit state; the second parameter is the invoked Editable object.
pub(open) trait VEditableDeleteText {
  fn delete_text(Self, Editable, Int, Int) -> Unit
}

///|
/// Implementation contract for Editable.do_delete_text. Self is the retained MoonBit state; the second parameter is the invoked Editable object.
pub(open) trait VEditableDoDeleteText {
  fn do_delete_text(Self, Editable, Int, Int) -> Unit
}

///|
/// Implementation contract for Editable.set_selection_bounds. Self is the retained MoonBit state; the second parameter is the invoked Editable object.
pub(open) trait VEditableSetSelectionBounds {
  fn set_selection_bounds(Self, Editable, Int, Int) -> Unit
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.delegate_get_accessible_platform_state.html).
#borrow(self)
pub extern "c" fn Editable::delegate_get_accessible_platform_state(
  self : Editable,
  state : AccessiblePlatformState,
) -> Bool = "moonbit_gtk_editable_delegate_get_accessible_platform_state"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.delete_selection.html).
#borrow(self)
pub extern "c" fn Editable::delete_selection(self : Editable) = "moonbit_gtk_editable_delete_selection"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.delete_text.html).
#borrow(self)
pub extern "c" fn Editable::delete_text(
  self : Editable,
  start_pos : Int,
  end_pos : Int,
) = "moonbit_gtk_editable_delete_text"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.finish_delegate.html).
#borrow(self)
pub extern "c" fn Editable::finish_delegate(self : Editable) = "moonbit_gtk_editable_finish_delegate"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_alignment.html).
#borrow(self)
pub extern "c" fn Editable::get_alignment(self : Editable) -> Float = "moonbit_gtk_editable_get_alignment"

///|
#borrow(self_)
extern "c" fn moonbit_gtk_editable_get_chars(
  self_ : Editable,
  start_pos : Int,
  end_pos : Int,
) -> Bytes = "moonbit_gtk_editable_get_chars"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_chars.html).
pub fn Editable::get_chars(
  self : Editable,
  start_pos : Int,
  end_pos : Int,
) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_gtk_editable_get_chars(self, start_pos, end_pos),
  )
}

///|
#borrow(self_)
extern "c" fn moonbit_gtk_editable_get_delegate(
  self_ : Editable,
) -> @glib.Nullable[Editable] = "moonbit_gtk_editable_get_delegate"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_delegate.html).
pub fn Editable::get_delegate(self : Editable) -> Editable? {
  let raw_result = moonbit_gtk_editable_get_delegate(self)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_editable.html).
#borrow(self)
pub extern "c" fn Editable::get_editable(self : Editable) -> Bool = "moonbit_gtk_editable_get_editable"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_enable_undo.html).
#borrow(self)
pub extern "c" fn Editable::get_enable_undo(self : Editable) -> Bool = "moonbit_gtk_editable_get_enable_undo"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_max_width_chars.html).
#borrow(self)
pub extern "c" fn Editable::get_max_width_chars(self : Editable) -> Int = "moonbit_gtk_editable_get_max_width_chars"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_position.html).
#borrow(self)
pub extern "c" fn Editable::get_position(self : Editable) -> Int = "moonbit_gtk_editable_get_position"

///|
#borrow(self_, start_pos, end_pos)
extern "c" fn moonbit_gtk_editable_get_selection_bounds(
  self_ : Editable,
  start_pos : Ref[Int],
  end_pos : Ref[Int],
) -> Bool = "moonbit_gtk_editable_get_selection_bounds"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_selection_bounds.html).
pub fn Editable::get_selection_bounds(self : Editable) -> (Bool, Int, Int) {
  let start_pos = Ref(0)
  let end_pos = Ref(0)
  let result = moonbit_gtk_editable_get_selection_bounds(
    self, start_pos, end_pos,
  )
  (result, start_pos.val, end_pos.val)
}

///|
#borrow(self_)
extern "c" fn moonbit_gtk_editable_get_text(self_ : Editable) -> Bytes = "moonbit_gtk_editable_get_text"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_text.html).
pub fn Editable::get_text(self : Editable) -> String {
  @encoding/utf8.decode_lossy(moonbit_gtk_editable_get_text(self))
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.get_width_chars.html).
#borrow(self)
pub extern "c" fn Editable::get_width_chars(self : Editable) -> Int = "moonbit_gtk_editable_get_width_chars"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.init_delegate.html).
#borrow(self)
pub extern "c" fn Editable::init_delegate(self : Editable) = "moonbit_gtk_editable_init_delegate"

///|
#borrow(self_, text, position_ref)
extern "c" fn moonbit_gtk_editable_insert_text(
  self_ : Editable,
  text : Bytes,
  length : Int,
  position_ref : Ref[Int],
) = "moonbit_gtk_editable_insert_text"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.insert_text.html).
pub fn Editable::insert_text(
  self : Editable,
  text : String,
  length : Int,
  position : Int,
) -> Int {
  let position_ref = Ref(position)
  moonbit_gtk_editable_insert_text(
    self,
    @encoding/utf8.encode(text),
    length,
    position_ref,
  )
  position_ref.val
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.select_region.html).
#borrow(self)
pub extern "c" fn Editable::select_region(
  self : Editable,
  start_pos : Int,
  end_pos : Int,
) = "moonbit_gtk_editable_select_region"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_alignment.html).
#borrow(self)
pub extern "c" fn Editable::set_alignment(self : Editable, xalign : Float) = "moonbit_gtk_editable_set_alignment"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_editable.html).
#borrow(self)
pub extern "c" fn Editable::set_editable(self : Editable, is_editable : Bool) = "moonbit_gtk_editable_set_editable"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_enable_undo.html).
#borrow(self)
pub extern "c" fn Editable::set_enable_undo(
  self : Editable,
  enable_undo : Bool,
) = "moonbit_gtk_editable_set_enable_undo"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_max_width_chars.html).
#borrow(self)
pub extern "c" fn Editable::set_max_width_chars(self : Editable, n_chars : Int) = "moonbit_gtk_editable_set_max_width_chars"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_position.html).
#borrow(self)
pub extern "c" fn Editable::set_position(self : Editable, position : Int) = "moonbit_gtk_editable_set_position"

///|
#borrow(self_, text)
extern "c" fn moonbit_gtk_editable_set_text(self_ : Editable, text : Bytes) = "moonbit_gtk_editable_set_text"

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_text.html).
pub fn Editable::set_text(self : Editable, text : String) -> Unit {
  moonbit_gtk_editable_set_text(self, @encoding/utf8.encode(text))
}

///|
/// [Upstream documentation](https://docs.gtk.org/gtk4/method.Editable.set_width_chars.html).
#borrow(self)
pub extern "c" fn Editable::set_width_chars(self : Editable, n_chars : Int) = "moonbit_gtk_editable_set_width_chars"

///|
impl IEditable with fn delegate_get_accessible_platform_state(self, state) -> Bool {
  self.as_editable().delegate_get_accessible_platform_state(state)
}

///|
impl IEditable with fn delete_selection(self) -> Unit {
  self.as_editable().delete_selection()
}

///|
impl IEditable with fn delete_text(self, start_pos, end_pos) -> Unit {
  self.as_editable().delete_text(start_pos, end_pos)
}

///|
impl IEditable with fn finish_delegate(self) -> Unit {
  self.as_editable().finish_delegate()
}

///|
impl IEditable with fn get_alignment(self) -> Float {
  self.as_editable().get_alignment()
}

///|
impl IEditable with fn get_chars(self, start_pos, end_pos) -> String {
  self.as_editable().get_chars(start_pos, end_pos)
}

///|
impl IEditable with fn get_delegate(self) -> Editable? {
  self.as_editable().get_delegate()
}

///|
impl IEditable with fn get_editable(self) -> Bool {
  self.as_editable().get_editable()
}

///|
impl IEditable with fn get_enable_undo(self) -> Bool {
  self.as_editable().get_enable_undo()
}

///|
impl IEditable with fn get_max_width_chars(self) -> Int {
  self.as_editable().get_max_width_chars()
}

///|
impl IEditable with fn get_position(self) -> Int {
  self.as_editable().get_position()
}

///|
impl IEditable with fn get_selection_bounds(self) -> (Bool, Int, Int) {
  self.as_editable().get_selection_bounds()
}

///|
impl IEditable with fn get_text(self) -> String {
  self.as_editable().get_text()
}

///|
impl IEditable with fn get_width_chars(self) -> Int {
  self.as_editable().get_width_chars()
}

///|
impl IEditable with fn init_delegate(self) -> Unit {
  self.as_editable().init_delegate()
}

///|
impl IEditable with fn insert_text(self, text, length, position) -> Int {
  self.as_editable().insert_text(text, length, position)
}

///|
impl IEditable with fn select_region(self, start_pos, end_pos) -> Unit {
  self.as_editable().select_region(start_pos, end_pos)
}

///|
impl IEditable with fn set_alignment(self, xalign) -> Unit {
  self.as_editable().set_alignment(xalign)
}

///|
impl IEditable with fn set_editable(self, is_editable) -> Unit {
  self.as_editable().set_editable(is_editable)
}

///|
impl IEditable with fn set_enable_undo(self, enable_undo) -> Unit {
  self.as_editable().set_enable_undo(enable_undo)
}

///|
impl IEditable with fn set_max_width_chars(self, n_chars) -> Unit {
  self.as_editable().set_max_width_chars(n_chars)
}

///|
impl IEditable with fn set_position(self, position) -> Unit {
  self.as_editable().set_position(position)
}

///|
impl IEditable with fn set_text(self, text) -> Unit {
  self.as_editable().set_text(text)
}

///|
impl IEditable with fn set_width_chars(self, n_chars) -> Unit {
  self.as_editable().set_width_chars(n_chars)
}

///|
pub fn Editable::as_widget(self : Editable) -> Widget = "%identity"

///|
pub impl IWidget for Editable with fn as_widget(self) {
  self.as_widget()
}