// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/class.Pty.html).
pub type Pty

///|
pub(open) trait IPty {
  fn as_pty(Self) -> Pty
  fn child_setup(Self) -> Unit = _
  fn get_fd(Self) -> Int = _
  fn get_size(Self) -> (Bool, Int, Int) raise @glib.Error_ = _
  fn set_size(Self, Int, Int) -> Bool raise @glib.Error_ = _
  fn set_utf8(Self, Bool) -> Bool raise @glib.Error_ = _
}

///|
pub impl IPty for Pty with fn as_pty(self) {
  self
}

///|
#borrow(cancellable, error)
extern "c" fn moonbit_vte_pty_new_foreign_sync(
  fd : Int,
  cancellable : @glib.Nullable[@gio.Cancellable],
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Pty = "moonbit_vte_pty_new_foreign_sync"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/ctor.Pty.new_foreign_sync.html).
pub fn Pty::new_foreign_sync(
  fd : Int,
  cancellable : &@gio.ICancellable?,
) -> Pty raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_vte_pty_new_foreign_sync(
    fd,
    match cancellable {
      Some(v) => @glib.Nullable::some(v.as_cancellable())
      None => @glib.Nullable::null()
    },
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
#borrow(cancellable, error)
extern "c" fn moonbit_vte_pty_new_sync(
  flags : Int,
  cancellable : @glib.Nullable[@gio.Cancellable],
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Pty = "moonbit_vte_pty_new_sync"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/ctor.Pty.new_sync.html).
pub fn Pty::new_sync(
  flags : PtyFlags,
  cancellable : &@gio.ICancellable?,
) -> Pty raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_vte_pty_new_sync(
    flags.to_int(),
    match cancellable {
      Some(v) => @glib.Nullable::some(v.as_cancellable())
      None => @glib.Nullable::null()
    },
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/method.Pty.child_setup.html).
#borrow(self)
pub extern "c" fn Pty::child_setup(self : Pty) = "moonbit_vte_pty_child_setup"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/method.Pty.get_fd.html).
#borrow(self)
pub extern "c" fn Pty::get_fd(self : Pty) -> Int = "moonbit_vte_pty_get_fd"

///|
#borrow(self_, rows, columns, error)
extern "c" fn moonbit_vte_pty_get_size(
  self_ : Pty,
  rows : Ref[Int],
  columns : Ref[Int],
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_vte_pty_get_size"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/method.Pty.get_size.html).
pub fn Pty::get_size(self : Pty) -> (Bool, Int, Int) raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let rows = Ref(0)
  let columns = Ref(0)
  let result = moonbit_vte_pty_get_size(self, rows, columns, error_)
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  (result, rows.val, columns.val)
}

///|
#borrow(self_, error)
extern "c" fn moonbit_vte_pty_set_size(
  self_ : Pty,
  rows : Int,
  columns : Int,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_vte_pty_set_size"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/method.Pty.set_size.html).
pub fn Pty::set_size(
  self : Pty,
  rows : Int,
  columns : Int,
) -> Bool raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_vte_pty_set_size(self, rows, columns, error_)
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

///|
#borrow(self_, error)
extern "c" fn moonbit_vte_pty_set_utf8(
  self_ : Pty,
  utf8 : Bool,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_vte_pty_set_utf8"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/method.Pty.set_utf8.html).
pub fn Pty::set_utf8(self : Pty, utf8 : Bool) -> Bool raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_vte_pty_set_utf8(self, utf8, error_)
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/vte/gtk4/property.Pty.flags.html).
#borrow(self_)
extern "c" fn __ffi_moonbit_vte_pty_get_flags(self_ : Pty) -> Int = "moonbit_vte_pty_get_flags"

///|
pub fn Pty::get_flags(self : Pty) -> PtyFlags {
  PtyFlags::from_int(__ffi_moonbit_vte_pty_get_flags(self))
}

///|
impl IPty with fn child_setup(self) -> Unit {
  self.as_pty().child_setup()
}

///|
impl IPty with fn get_fd(self) -> Int {
  self.as_pty().get_fd()
}

///|
impl IPty with fn get_size(self) -> (Bool, Int, Int) raise @glib.Error_ {
  self.as_pty().get_size()
}

///|
impl IPty with fn set_size(self, rows, columns) -> Bool raise @glib.Error_ {
  self.as_pty().set_size(rows, columns)
}

///|
impl IPty with fn set_utf8(self, utf8) -> Bool raise @glib.Error_ {
  self.as_pty().set_utf8(utf8)
}

///|
pub fn Pty::as_gobject_object(self : Pty) -> @gobject.Object = "%identity"

///|
pub impl @gobject.IObject for Pty with fn as_object(self) {
  self.as_gobject_object()
}