{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Vte.Objects.Pty
    ( 

-- * Exported types
    Pty(..)                                 ,
    IsPty                                   ,
    toPty                                   ,
    noPty                                   ,


 -- * Methods
-- ** childSetup #method:childSetup#
    PtyChildSetupMethodInfo                 ,
    ptyChildSetup                           ,


-- ** close #method:close#
    PtyCloseMethodInfo                      ,
    ptyClose                                ,


-- ** getFd #method:getFd#
    PtyGetFdMethodInfo                      ,
    ptyGetFd                                ,


-- ** getSize #method:getSize#
    PtyGetSizeMethodInfo                    ,
    ptyGetSize                              ,


-- ** newForeignSync #method:newForeignSync#
    ptyNewForeignSync                       ,


-- ** newSync #method:newSync#
    ptyNewSync                              ,


-- ** setSize #method:setSize#
    PtySetSizeMethodInfo                    ,
    ptySetSize                              ,


-- ** setUtf8 #method:setUtf8#
    PtySetUtf8MethodInfo                    ,
    ptySetUtf8                              ,




 -- * Properties
-- ** fd #attr:fd#
    PtyFdPropertyInfo                       ,
    constructPtyFd                          ,
    getPtyFd                                ,
    ptyFd                                   ,


-- ** flags #attr:flags#
    PtyFlagsPropertyInfo                    ,
    constructPtyFlags                       ,
    getPtyFlags                             ,
    ptyFlags                                ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Interfaces.Initable as Gio.Initable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Vte.Flags as Vte.Flags

newtype Pty = Pty (ManagedPtr Pty)
foreign import ccall "vte_pty_get_type"
    c_vte_pty_get_type :: IO GType

instance GObject Pty where
    gobjectType _ = c_vte_pty_get_type
    

class GObject o => IsPty o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Pty a) =>
    IsPty a
#endif
instance IsPty Pty
instance GObject.Object.IsObject Pty
instance Gio.Initable.IsInitable Pty

toPty :: IsPty o => o -> IO Pty
toPty = unsafeCastTo Pty

noPty :: Maybe Pty
noPty = Nothing

type family ResolvePtyMethod (t :: Symbol) (o :: *) :: * where
    ResolvePtyMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePtyMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePtyMethod "childSetup" o = PtyChildSetupMethodInfo
    ResolvePtyMethod "close" o = PtyCloseMethodInfo
    ResolvePtyMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePtyMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePtyMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolvePtyMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePtyMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePtyMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePtyMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolvePtyMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePtyMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolvePtyMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolvePtyMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePtyMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePtyMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePtyMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePtyMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolvePtyMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePtyMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePtyMethod "getFd" o = PtyGetFdMethodInfo
    ResolvePtyMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePtyMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePtyMethod "getSize" o = PtyGetSizeMethodInfo
    ResolvePtyMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePtyMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePtyMethod "setSize" o = PtySetSizeMethodInfo
    ResolvePtyMethod "setUtf8" o = PtySetUtf8MethodInfo
    ResolvePtyMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePtyMethod t Pty, O.MethodInfo info Pty p) => O.IsLabelProxy t (Pty -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePtyMethod t Pty, O.MethodInfo info Pty p) => O.IsLabel t (Pty -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "fd"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getPtyFd :: (MonadIO m, IsPty o) => o -> m Int32
getPtyFd obj = liftIO $ getObjectPropertyInt32 obj "fd"

constructPtyFd :: (IsPty o) => Int32 -> IO (GValueConstruct o)
constructPtyFd val = constructObjectPropertyInt32 "fd" val

data PtyFdPropertyInfo
instance AttrInfo PtyFdPropertyInfo where
    type AttrAllowedOps PtyFdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint PtyFdPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint PtyFdPropertyInfo = IsPty
    type AttrGetType PtyFdPropertyInfo = Int32
    type AttrLabel PtyFdPropertyInfo = "fd"
    type AttrOrigin PtyFdPropertyInfo = Pty
    attrGet _ = getPtyFd
    attrSet _ = undefined
    attrConstruct _ = constructPtyFd
    attrClear _ = undefined

-- VVV Prop "flags"
   -- Type: TInterface (Name {namespace = "Vte", name = "PtyFlags"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getPtyFlags :: (MonadIO m, IsPty o) => o -> m [Vte.Flags.PtyFlags]
getPtyFlags obj = liftIO $ getObjectPropertyFlags obj "flags"

constructPtyFlags :: (IsPty o) => [Vte.Flags.PtyFlags] -> IO (GValueConstruct o)
constructPtyFlags val = constructObjectPropertyFlags "flags" val

data PtyFlagsPropertyInfo
instance AttrInfo PtyFlagsPropertyInfo where
    type AttrAllowedOps PtyFlagsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint PtyFlagsPropertyInfo = (~) [Vte.Flags.PtyFlags]
    type AttrBaseTypeConstraint PtyFlagsPropertyInfo = IsPty
    type AttrGetType PtyFlagsPropertyInfo = [Vte.Flags.PtyFlags]
    type AttrLabel PtyFlagsPropertyInfo = "flags"
    type AttrOrigin PtyFlagsPropertyInfo = Pty
    attrGet _ = getPtyFlags
    attrSet _ = undefined
    attrConstruct _ = constructPtyFlags
    attrClear _ = undefined

instance O.HasAttributeList Pty
type instance O.AttributeList Pty = PtyAttributeList
type PtyAttributeList = ('[ '("fd", PtyFdPropertyInfo), '("flags", PtyFlagsPropertyInfo)] :: [(Symbol, *)])

ptyFd :: AttrLabelProxy "fd"
ptyFd = AttrLabelProxy

ptyFlags :: AttrLabelProxy "flags"
ptyFlags = AttrLabelProxy

type instance O.SignalList Pty = PtySignalList
type PtySignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Pty::new_foreign_sync
-- method type : Constructor
-- Args : [Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor to the PTY", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Vte", name = "Pty"}))
-- throws : True
-- Skip return : False

foreign import ccall "vte_pty_new_foreign_sync" vte_pty_new_foreign_sync :: 
    Int32 ->                                -- fd : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Pty)

{- |
Creates a new 'GI.Vte.Objects.Pty.Pty' for the PTY master /@fd@/.

No entry will be made in the lastlog, utmp or wtmp system files.

Note that the newly created 'GI.Vte.Objects.Pty.Pty' will take ownership of /@fd@/
and close it on finalize.
-}
ptyNewForeignSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Int32
    {- ^ /@fd@/: a file descriptor to the PTY -}
    -> Maybe (a)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> m Pty
    {- ^ __Returns:__ a new 'GI.Vte.Objects.Pty.Pty' for /@fd@/, or 'Nothing' on error with /@error@/ filled in /(Can throw 'Data.GI.Base.GError.GError')/ -}
ptyNewForeignSync fd cancellable = liftIO $ do
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ vte_pty_new_foreign_sync fd maybeCancellable
        checkUnexpectedReturnNULL "ptyNewForeignSync" result
        result' <- (wrapObject Pty) result
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method Pty::new_sync
-- method type : Constructor
-- Args : [Arg {argCName = "flags", argType = TInterface (Name {namespace = "Vte", name = "PtyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags from #VtePtyFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Vte", name = "Pty"}))
-- throws : True
-- Skip return : False

foreign import ccall "vte_pty_new_sync" vte_pty_new_sync :: 
    CUInt ->                                -- flags : TInterface (Name {namespace = "Vte", name = "PtyFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Pty)

{- |
Allocates a new pseudo-terminal.

You can later use @/fork()/@ or the 'GI.GLib.Functions.spawnAsync' family of functions
to start a process on the PTY.

If using @/fork()/@, you MUST call 'GI.Vte.Objects.Pty.ptyChildSetup' in the child.

If using 'GI.GLib.Functions.spawnAsync' and friends, you MUST either use
'GI.Vte.Objects.Pty.ptyChildSetup' directly as the child setup function, or call
'GI.Vte.Objects.Pty.ptyChildSetup' from your own child setup function supplied.

When using 'GI.Vte.Objects.Terminal.terminalSpawnSync' with a custom child setup
function, 'GI.Vte.Objects.Pty.ptyChildSetup' will be called before the supplied
function; you must not call it again.

Also, you MUST pass the 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' flag.
-}
ptyNewSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    [Vte.Flags.PtyFlags]
    {- ^ /@flags@/: flags from 'GI.Vte.Flags.PtyFlags' -}
    -> Maybe (a)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> m Pty
    {- ^ __Returns:__ a new 'GI.Vte.Objects.Pty.Pty', or 'Nothing' on error with /@error@/ filled in /(Can throw 'Data.GI.Base.GError.GError')/ -}
ptyNewSync flags cancellable = liftIO $ do
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ vte_pty_new_sync flags' maybeCancellable
        checkUnexpectedReturnNULL "ptyNewSync" result
        result' <- (wrapObject Pty) result
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method Pty::child_setup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "pty", argType = TInterface (Name {namespace = "Vte", name = "Pty"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #VtePty", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "vte_pty_child_setup" vte_pty_child_setup :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    IO ()

{- |
FIXMEchpe
-}
ptyChildSetup ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    {- ^ /@pty@/: a 'GI.Vte.Objects.Pty.Pty' -}
    -> m ()
ptyChildSetup pty = liftIO $ do
    pty' <- unsafeManagedPtrCastPtr pty
    vte_pty_child_setup pty'
    touchManagedPtr pty
    return ()

data PtyChildSetupMethodInfo
instance (signature ~ (m ()), MonadIO m, IsPty a) => O.MethodInfo PtyChildSetupMethodInfo a signature where
    overloadedMethod _ = ptyChildSetup

-- method Pty::close
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "pty", argType = TInterface (Name {namespace = "Vte", name = "Pty"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #VtePty", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "vte_pty_close" vte_pty_close :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    IO ()

{-# DEPRECATED ptyClose ["(Since version 0.42)"] #-}
{- |
Since 0.42 this is a no-op.
-}
ptyClose ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    {- ^ /@pty@/: a 'GI.Vte.Objects.Pty.Pty' -}
    -> m ()
ptyClose pty = liftIO $ do
    pty' <- unsafeManagedPtrCastPtr pty
    vte_pty_close pty'
    touchManagedPtr pty
    return ()

data PtyCloseMethodInfo
instance (signature ~ (m ()), MonadIO m, IsPty a) => O.MethodInfo PtyCloseMethodInfo a signature where
    overloadedMethod _ = ptyClose

-- method Pty::get_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "pty", argType = TInterface (Name {namespace = "Vte", name = "Pty"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #VtePty", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "vte_pty_get_fd" vte_pty_get_fd :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    IO Int32

{- |
/No description available in the introspection data./
-}
ptyGetFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    {- ^ /@pty@/: a 'GI.Vte.Objects.Pty.Pty' -}
    -> m Int32
    {- ^ __Returns:__ the file descriptor of the PTY master in /@pty@/. The
  file descriptor belongs to /@pty@/ and must not be closed -}
ptyGetFd pty = liftIO $ do
    pty' <- unsafeManagedPtrCastPtr pty
    result <- vte_pty_get_fd pty'
    touchManagedPtr pty
    return result

data PtyGetFdMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsPty a) => O.MethodInfo PtyGetFdMethodInfo a signature where
    overloadedMethod _ = ptyGetFd

-- method Pty::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "pty", argType = TInterface (Name {namespace = "Vte", name = "Pty"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #VtePty", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rows", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to store the number of rows, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "columns", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location to store the number of columns, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "vte_pty_get_size" vte_pty_get_size :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    Ptr Int32 ->                            -- rows : TBasicType TInt
    Ptr Int32 ->                            -- columns : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Reads the pseudo terminal\'s window size.

If getting the window size failed, /@error@/ will be set to a 'GI.GLib.Enums.IOError'.
-}
ptyGetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    {- ^ /@pty@/: a 'GI.Vte.Objects.Pty.Pty' -}
    -> m (Int32,Int32)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
ptyGetSize pty = liftIO $ do
    pty' <- unsafeManagedPtrCastPtr pty
    rows <- allocMem :: IO (Ptr Int32)
    columns <- allocMem :: IO (Ptr Int32)
    onException (do
        _ <- propagateGError $ vte_pty_get_size pty' rows columns
        rows' <- peek rows
        columns' <- peek columns
        touchManagedPtr pty
        freeMem rows
        freeMem columns
        return (rows', columns')
     ) (do
        freeMem rows
        freeMem columns
     )

data PtyGetSizeMethodInfo
instance (signature ~ (m (Int32,Int32)), MonadIO m, IsPty a) => O.MethodInfo PtyGetSizeMethodInfo a signature where
    overloadedMethod _ = ptyGetSize

-- method Pty::set_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "pty", argType = TInterface (Name {namespace = "Vte", name = "Pty"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #VtePty", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rows", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the desired number of rows", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "columns", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the desired number of columns", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "vte_pty_set_size" vte_pty_set_size :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    Int32 ->                                -- rows : TBasicType TInt
    Int32 ->                                -- columns : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Attempts to resize the pseudo terminal\'s window size.  If successful, the
OS kernel will send @/SIGWINCH/@ to the child process group.

If setting the window size failed, /@error@/ will be set to a 'GI.GLib.Enums.IOError'.
-}
ptySetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    {- ^ /@pty@/: a 'GI.Vte.Objects.Pty.Pty' -}
    -> Int32
    {- ^ /@rows@/: the desired number of rows -}
    -> Int32
    {- ^ /@columns@/: the desired number of columns -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
ptySetSize pty rows columns = liftIO $ do
    pty' <- unsafeManagedPtrCastPtr pty
    onException (do
        _ <- propagateGError $ vte_pty_set_size pty' rows columns
        touchManagedPtr pty
        return ()
     ) (do
        return ()
     )

data PtySetSizeMethodInfo
instance (signature ~ (Int32 -> Int32 -> m ()), MonadIO m, IsPty a) => O.MethodInfo PtySetSizeMethodInfo a signature where
    overloadedMethod _ = ptySetSize

-- method Pty::set_utf8
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "pty", argType = TInterface (Name {namespace = "Vte", name = "Pty"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #VtePty", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "utf8", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether or not the pty is in UTF-8 mode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "vte_pty_set_utf8" vte_pty_set_utf8 :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    CInt ->                                 -- utf8 : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Tells the kernel whether the terminal is UTF-8 or not, in case it can make
use of the info.  Linux 2.6.5 or so defines IUTF8 to make the line
discipline do multibyte backspace correctly.
-}
ptySetUtf8 ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    {- ^ /@pty@/: a 'GI.Vte.Objects.Pty.Pty' -}
    -> Bool
    {- ^ /@utf8@/: whether or not the pty is in UTF-8 mode -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
ptySetUtf8 pty utf8 = liftIO $ do
    pty' <- unsafeManagedPtrCastPtr pty
    let utf8' = (fromIntegral . fromEnum) utf8
    onException (do
        _ <- propagateGError $ vte_pty_set_utf8 pty' utf8'
        touchManagedPtr pty
        return ()
     ) (do
        return ()
     )

data PtySetUtf8MethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsPty a) => O.MethodInfo PtySetUtf8MethodInfo a signature where
    overloadedMethod _ = ptySetUtf8