{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Vte.Objects.Pty
    ( 
#if defined(ENABLE_OVERLOADING)
    PtySpawnAsyncMethodInfo                 ,
#endif

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


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolvePtyMethod                        ,
#endif


-- ** childSetup #method:childSetup#

#if defined(ENABLE_OVERLOADING)
    PtyChildSetupMethodInfo                 ,
#endif
    ptyChildSetup                           ,


-- ** close #method:close#

#if defined(ENABLE_OVERLOADING)
    PtyCloseMethodInfo                      ,
#endif
    ptyClose                                ,


-- ** getFd #method:getFd#

#if defined(ENABLE_OVERLOADING)
    PtyGetFdMethodInfo                      ,
#endif
    ptyGetFd                                ,


-- ** getSize #method:getSize#

#if defined(ENABLE_OVERLOADING)
    PtyGetSizeMethodInfo                    ,
#endif
    ptyGetSize                              ,


-- ** newForeignSync #method:newForeignSync#

    ptyNewForeignSync                       ,


-- ** newSync #method:newSync#

    ptyNewSync                              ,


-- ** setSize #method:setSize#

#if defined(ENABLE_OVERLOADING)
    PtySetSizeMethodInfo                    ,
#endif
    ptySetSize                              ,


-- ** setUtf8 #method:setUtf8#

#if defined(ENABLE_OVERLOADING)
    PtySetUtf8MethodInfo                    ,
#endif
    ptySetUtf8                              ,


-- ** spawnFinish #method:spawnFinish#

#if defined(ENABLE_OVERLOADING)
    PtySpawnFinishMethodInfo                ,
#endif
    ptySpawnFinish                          ,




 -- * Properties
-- ** fd #attr:fd#
-- | The file descriptor of the PTY master.

#if defined(ENABLE_OVERLOADING)
    PtyFdPropertyInfo                       ,
#endif
    constructPtyFd                          ,
    getPtyFd                                ,
#if defined(ENABLE_OVERLOADING)
    ptyFd                                   ,
#endif


-- ** flags #attr:flags#
-- | Flags.

#if defined(ENABLE_OVERLOADING)
    PtyFlagsPropertyInfo                    ,
#endif
    constructPtyFlags                       ,
    getPtyFlags                             ,
#if defined(ENABLE_OVERLOADING)
    ptyFlags                                ,
#endif




    ) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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 GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
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

-- | Memory-managed wrapper type.
newtype Pty = Pty (ManagedPtr Pty)
    deriving (Pty -> Pty -> Bool
(Pty -> Pty -> Bool) -> (Pty -> Pty -> Bool) -> Eq Pty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pty -> Pty -> Bool
$c/= :: Pty -> Pty -> Bool
== :: Pty -> Pty -> Bool
$c== :: Pty -> Pty -> Bool
Eq)
foreign import ccall "vte_pty_get_type"
    c_vte_pty_get_type :: IO GType

instance GObject Pty where
    gobjectType :: IO GType
gobjectType = IO GType
c_vte_pty_get_type
    

-- | Convert 'Pty' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Pty where
    toGValue :: Pty -> IO GValue
toGValue o :: Pty
o = do
        GType
gtype <- IO GType
c_vte_pty_get_type
        Pty -> (Ptr Pty -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Pty
o (GType -> (GValue -> Ptr Pty -> IO ()) -> Ptr Pty -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Pty -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Pty
fromGValue gv :: GValue
gv = do
        Ptr Pty
ptr <- GValue -> IO (Ptr Pty)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Pty)
        (ManagedPtr Pty -> Pty) -> Ptr Pty -> IO Pty
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Pty -> Pty
Pty Ptr Pty
ptr
        
    

-- | Type class for types which can be safely cast to `Pty`, for instance with `toPty`.
class (GObject o, O.IsDescendantOf Pty o) => IsPty o
instance (GObject o, O.IsDescendantOf Pty o) => IsPty o

instance O.HasParentTypes Pty
type instance O.ParentTypes Pty = '[GObject.Object.Object, Gio.Initable.Initable]

-- | Cast to `Pty`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toPty :: (MonadIO m, IsPty o) => o -> m Pty
toPty :: o -> m Pty
toPty = IO Pty -> m Pty
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Pty -> m Pty) -> (o -> IO Pty) -> o -> m Pty
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Pty -> Pty) -> o -> IO Pty
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Pty -> Pty
Pty

-- | A convenience alias for `Nothing` :: `Maybe` `Pty`.
noPty :: Maybe Pty
noPty :: Maybe Pty
noPty = Maybe Pty
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
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 "getv" o = GObject.Object.ObjectGetvMethodInfo
    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 "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePtyMethod "spawnAsync" o = PtySpawnAsyncMethodInfo
    ResolvePtyMethod "spawnFinish" o = PtySpawnFinishMethodInfo
    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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    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) => OL.IsLabel t (Pty -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

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

-- | Get the value of the “@fd@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' pty #fd
-- @
getPtyFd :: (MonadIO m, IsPty o) => o -> m Int32
getPtyFd :: o -> m Int32
getPtyFd obj :: o
obj = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Int32
forall a. GObject a => a -> String -> IO Int32
B.Properties.getObjectPropertyInt32 o
obj "fd"

-- | Construct a `GValueConstruct` with valid value for the “@fd@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructPtyFd :: (IsPty o) => Int32 -> IO (GValueConstruct o)
constructPtyFd :: Int32 -> IO (GValueConstruct o)
constructPtyFd val :: Int32
val = String -> Int32 -> IO (GValueConstruct o)
forall o. String -> Int32 -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyInt32 "fd" Int32
val

#if defined(ENABLE_OVERLOADING)
data PtyFdPropertyInfo
instance AttrInfo PtyFdPropertyInfo where
    type AttrAllowedOps PtyFdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint PtyFdPropertyInfo = IsPty
    type AttrSetTypeConstraint PtyFdPropertyInfo = (~) Int32
    type AttrTransferTypeConstraint PtyFdPropertyInfo = (~) Int32
    type AttrTransferType PtyFdPropertyInfo = Int32
    type AttrGetType PtyFdPropertyInfo = Int32
    type AttrLabel PtyFdPropertyInfo = "fd"
    type AttrOrigin PtyFdPropertyInfo = Pty
    attrGet = getPtyFd
    attrSet = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructPtyFd
    attrClear = undefined
#endif

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

-- | Get the value of the “@flags@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' pty #flags
-- @
getPtyFlags :: (MonadIO m, IsPty o) => o -> m [Vte.Flags.PtyFlags]
getPtyFlags :: o -> m [PtyFlags]
getPtyFlags obj :: o
obj = IO [PtyFlags] -> m [PtyFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [PtyFlags] -> m [PtyFlags]) -> IO [PtyFlags] -> m [PtyFlags]
forall a b. (a -> b) -> a -> b
$ o -> String -> IO [PtyFlags]
forall a b.
(GObject a, IsGFlag b, BoxedFlags b) =>
a -> String -> IO [b]
B.Properties.getObjectPropertyFlags o
obj "flags"

-- | Construct a `GValueConstruct` with valid value for the “@flags@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructPtyFlags :: (IsPty o) => [Vte.Flags.PtyFlags] -> IO (GValueConstruct o)
constructPtyFlags :: [PtyFlags] -> IO (GValueConstruct o)
constructPtyFlags val :: [PtyFlags]
val = String -> [PtyFlags] -> IO (GValueConstruct o)
forall a o.
(IsGFlag a, BoxedFlags a) =>
String -> [a] -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyFlags "flags" [PtyFlags]
val

#if defined(ENABLE_OVERLOADING)
data PtyFlagsPropertyInfo
instance AttrInfo PtyFlagsPropertyInfo where
    type AttrAllowedOps PtyFlagsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint PtyFlagsPropertyInfo = IsPty
    type AttrSetTypeConstraint PtyFlagsPropertyInfo = (~) [Vte.Flags.PtyFlags]
    type AttrTransferTypeConstraint PtyFlagsPropertyInfo = (~) [Vte.Flags.PtyFlags]
    type AttrTransferType PtyFlagsPropertyInfo = [Vte.Flags.PtyFlags]
    type AttrGetType PtyFlagsPropertyInfo = [Vte.Flags.PtyFlags]
    type AttrLabel PtyFlagsPropertyInfo = "flags"
    type AttrOrigin PtyFlagsPropertyInfo = Pty
    attrGet = getPtyFlags
    attrSet = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructPtyFlags
    attrClear = undefined
#endif

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

#if defined(ENABLE_OVERLOADING)
ptyFd :: AttrLabelProxy "fd"
ptyFd = AttrLabelProxy

ptyFlags :: AttrLabelProxy "flags"
ptyFlags = AttrLabelProxy

#endif

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

#endif

-- 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 t'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 t'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 t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m Pty
    -- ^ __Returns:__ a new t'GI.Vte.Objects.Pty.Pty' for /@fd@/, or 'P.Nothing' on error with /@error@/ filled in /(Can throw 'Data.GI.Base.GError.GError')/
ptyNewForeignSync :: Int32 -> Maybe a -> m Pty
ptyNewForeignSync fd :: Int32
fd cancellable :: Maybe a
cancellable = IO Pty -> m Pty
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Pty -> m Pty) -> IO Pty -> m Pty
forall a b. (a -> b) -> a -> b
$ do
    Ptr Cancellable
maybeCancellable <- case Maybe a
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO Pty -> IO () -> IO Pty
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pty
result <- (Ptr (Ptr GError) -> IO (Ptr Pty)) -> IO (Ptr Pty)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pty)) -> IO (Ptr Pty))
-> (Ptr (Ptr GError) -> IO (Ptr Pty)) -> IO (Ptr Pty)
forall a b. (a -> b) -> a -> b
$ Int32 -> Ptr Cancellable -> Ptr (Ptr GError) -> IO (Ptr Pty)
vte_pty_new_foreign_sync Int32
fd Ptr Cancellable
maybeCancellable
        Text -> Ptr Pty -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "ptyNewForeignSync" Ptr Pty
result
        Pty
result' <- ((ManagedPtr Pty -> Pty) -> Ptr Pty -> IO Pty
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pty -> Pty
Pty) Ptr Pty
result
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Pty -> IO Pty
forall (m :: * -> *) a. Monad m => a -> m a
return Pty
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- 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 t'GI.Vte.Flags.PtyFlags'
    -> Maybe (a)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m Pty
    -- ^ __Returns:__ a new t'GI.Vte.Objects.Pty.Pty', or 'P.Nothing' on error with /@error@/ filled in /(Can throw 'Data.GI.Base.GError.GError')/
ptyNewSync :: [PtyFlags] -> Maybe a -> m Pty
ptyNewSync flags :: [PtyFlags]
flags cancellable :: Maybe a
cancellable = IO Pty -> m Pty
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Pty -> m Pty) -> IO Pty -> m Pty
forall a b. (a -> b) -> a -> b
$ do
    let flags' :: CUInt
flags' = [PtyFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [PtyFlags]
flags
    Ptr Cancellable
maybeCancellable <- case Maybe a
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: a
jCancellable -> do
            Ptr Cancellable
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO Pty -> IO () -> IO Pty
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pty
result <- (Ptr (Ptr GError) -> IO (Ptr Pty)) -> IO (Ptr Pty)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pty)) -> IO (Ptr Pty))
-> (Ptr (Ptr GError) -> IO (Ptr Pty)) -> IO (Ptr Pty)
forall a b. (a -> b) -> a -> b
$ CUInt -> Ptr Cancellable -> Ptr (Ptr GError) -> IO (Ptr Pty)
vte_pty_new_sync CUInt
flags' Ptr Cancellable
maybeCancellable
        Text -> Ptr Pty -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "ptyNewSync" Ptr Pty
result
        Pty
result' <- ((ManagedPtr Pty -> Pty) -> Ptr Pty -> IO Pty
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pty -> Pty
Pty) Ptr Pty
result
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
cancellable a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Pty -> IO Pty
forall (m :: * -> *) a. Monad m => a -> m a
return Pty
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- 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 t'GI.Vte.Objects.Pty.Pty'
    -> m ()
ptyChildSetup :: a -> m ()
ptyChildSetup pty :: a
pty = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    Ptr Pty -> IO ()
vte_pty_child_setup Ptr Pty
pty'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 t'GI.Vte.Objects.Pty.Pty'
    -> m ()
ptyClose :: a -> m ()
ptyClose pty :: a
pty = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    Ptr Pty -> IO ()
vte_pty_close Ptr Pty
pty'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 t'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 :: a -> m Int32
ptyGetFd pty :: a
pty = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    Int32
result <- Ptr Pty -> IO Int32
vte_pty_get_fd Ptr Pty
pty'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

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

#endif

-- 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 t'GI.GLib.Enums.IOError'.
ptyGetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    -- ^ /@pty@/: a t'GI.Vte.Objects.Pty.Pty'
    -> m ((Int32, Int32))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
ptyGetSize :: a -> m (Int32, Int32)
ptyGetSize pty :: a
pty = IO (Int32, Int32) -> m (Int32, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, Int32) -> m (Int32, Int32))
-> IO (Int32, Int32) -> m (Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    Ptr Int32
rows <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
columns <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    IO (Int32, Int32) -> IO () -> IO (Int32, Int32)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Pty -> Ptr Int32 -> Ptr Int32 -> Ptr (Ptr GError) -> IO CInt
vte_pty_get_size Ptr Pty
pty' Ptr Int32
rows Ptr Int32
columns
        Int32
rows' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
rows
        Int32
columns' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
columns
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
rows
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
columns
        (Int32, Int32) -> IO (Int32, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int32
rows', Int32
columns')
     ) (do
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
rows
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
columns
     )

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

#endif

-- 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 t'GI.GLib.Enums.IOError'.
ptySetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a) =>
    a
    -- ^ /@pty@/: a t'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 :: a -> Int32 -> Int32 -> m ()
ptySetSize pty :: a
pty rows :: Int32
rows columns :: Int32
columns = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Pty -> Int32 -> Int32 -> Ptr (Ptr GError) -> IO CInt
vte_pty_set_size Ptr Pty
pty' Int32
rows Int32
columns
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

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

#endif

-- 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 t'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 :: a -> Bool -> m ()
ptySetUtf8 pty :: a
pty utf8 :: Bool
utf8 = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    let utf8' :: CInt
utf8' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
utf8
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Pty -> CInt -> Ptr (Ptr GError) -> IO CInt
vte_pty_set_utf8 Ptr Pty
pty' CInt
utf8'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

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

#endif

-- XXX Could not generate method Pty::spawn_async
-- Error was : Bad introspection data: "ScopeTypeNotified without destructor! Callable\n  { returnType = Nothing\n  , returnMayBeNull = False\n  , returnTransfer = TransferNothing\n  , returnDocumentation =\n      Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n  , args =\n      [ Arg\n          { argCName = \"pty\"\n          , argType = TInterface Name { namespace = \"Vte\" , name = \"Pty\" }\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #VtePty\" , sinceVersion = Nothing }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"working_directory\"\n          , argType = TBasicType TUTF8\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just\n                      \"the name of a directory the command should start\\n  in, or %NULL to use the current working directory\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"argv\"\n          , argType = TCArray True (-1) (-1) (TBasicType TFileName)\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"child's argument vector\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"envv\"\n          , argType = TCArray True (-1) (-1) (TBasicType TFileName)\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just\n                      \"a list of environment\\n  variables to be added to the environment before starting the process, or %NULL\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"spawn_flags\"\n          , argType =\n              TInterface Name { namespace = \"GLib\" , name = \"SpawnFlags\" }\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"flags from #GSpawnFlags\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"child_setup\"\n          , argType =\n              TInterface\n                Name { namespace = \"GLib\" , name = \"SpawnChildSetupFunc\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just\n                      \"an extra child setup function to run in the child just before exec(), or %NULL\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeNotified\n          , argClosure = 6\n          , argDestroy = 7\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"child_setup_data\"\n          , argType = TBasicType TPtr\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"user data for @child_setup, or %NULL\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeNotified\n          , argClosure = 5\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"child_setup_data_destroy\"\n          , argType =\n              TInterface Name { namespace = \"GLib\" , name = \"DestroyNotify\" }\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just \"a #GDestroyNotify for @child_setup_data, or %NULL\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeAsync\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"timeout\"\n          , argType = TBasicType TInt\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just \"a timeout value in ms, or -1 to wait indefinitely\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"cancellable\"\n          , argType =\n              TInterface Name { namespace = \"Gio\" , name = \"Cancellable\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GCancellable, or %NULL\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"callback\"\n          , argType =\n              TInterface Name { namespace = \"Gio\" , name = \"AsyncReadyCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n          , argScope = ScopeTypeAsync\n          , argClosure = 11\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"user_data\"\n          , argType = TBasicType TPtr\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      ]\n  , skipReturn = False\n  , callableThrows = False\n  , callableDeprecated = Nothing\n  , callableDocumentation =\n      Documentation\n        { rawDocText =\n            Just\n              \"Starts the specified command under the pseudo-terminal @pty.\\nThe @argv and @envv lists should be %NULL-terminated.\\nThe \\\"TERM\\\" environment variable is automatically set to a default value,\\nbut can be overridden from @envv.\\n@pty_flags controls logging the session to the specified system log files.\\n\\nNote that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to @spawn_flags.\\n\\nNote that all open file descriptors will be closed in the child. If you want\\nto keep some file descriptor open for use in the child process, you need to\\nuse a child setup function that unsets the FD_CLOEXEC flag on that file\\ndescriptor.\\n\\nSee vte_pty_new(), g_spawn_async() and vte_terminal_watch_child() for more information.\"\n        , sinceVersion = Just \"0.48\"\n        }\n  }"
#if defined(ENABLE_OVERLOADING)
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data PtySpawnAsyncMethodInfo
instance (p ~ (), o ~ O.UnsupportedMethodError "spawnAsync" Pty) => O.MethodInfo PtySpawnAsyncMethodInfo o p where
    overloadedMethod = undefined
#endif

-- method Pty::spawn_finish
-- 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 = "result"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GAsyncResult" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "child_pid"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a location to store the child PID, 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_spawn_finish" vte_pty_spawn_finish :: 
    Ptr Pty ->                              -- pty : TInterface (Name {namespace = "Vte", name = "Pty"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Int32 ->                            -- child_pid : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | /No description available in the introspection data./
-- 
-- /Since: 0.48/
ptySpawnFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsPty a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@pty@/: a t'GI.Vte.Objects.Pty.Pty'
    -> b
    -- ^ /@result@/: a t'GI.Gio.Interfaces.AsyncResult.AsyncResult'
    -> m (Int32)
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
ptySpawnFinish :: a -> b -> m Int32
ptySpawnFinish pty :: a
pty result_ :: b
result_ = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pty
pty' <- a -> IO (Ptr Pty)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
pty
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    Ptr Int32
childPid <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    IO Int32 -> IO () -> IO Int32
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Pty
-> Ptr AsyncResult -> Ptr Int32 -> Ptr (Ptr GError) -> IO CInt
vte_pty_spawn_finish Ptr Pty
pty' Ptr AsyncResult
result_' Ptr Int32
childPid
        Int32
childPid' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
childPid
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
pty
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
childPid
        Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
childPid'
     ) (do
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
childPid
     )

#if defined(ENABLE_OVERLOADING)
data PtySpawnFinishMethodInfo
instance (signature ~ (b -> m (Int32)), MonadIO m, IsPty a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo PtySpawnFinishMethodInfo a signature where
    overloadedMethod = ptySpawnFinish

#endif