{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A range inside the text of an accessible object.
-- 
-- /Since: 4.14/

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

module GI.Gtk.Structs.AccessibleTextRange
    ( 

-- * Exported types
    AccessibleTextRange(..)                 ,
    newZeroAccessibleTextRange              ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveAccessibleTextRangeMethod        ,
#endif



 -- * Properties


-- ** length #attr:length#
-- | the length of the range, in characters

#if defined(ENABLE_OVERLOADING)
    accessibleTextRange_length              ,
#endif
    getAccessibleTextRangeLength            ,
    setAccessibleTextRangeLength            ,


-- ** start #attr:start#
-- | the start of the range, in characters

#if defined(ENABLE_OVERLOADING)
    accessibleTextRange_start               ,
#endif
    getAccessibleTextRangeStart             ,
    setAccessibleTextRangeStart             ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)

#else

#endif

-- | Memory-managed wrapper type.
newtype AccessibleTextRange = AccessibleTextRange (SP.ManagedPtr AccessibleTextRange)
    deriving (AccessibleTextRange -> AccessibleTextRange -> Bool
(AccessibleTextRange -> AccessibleTextRange -> Bool)
-> (AccessibleTextRange -> AccessibleTextRange -> Bool)
-> Eq AccessibleTextRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AccessibleTextRange -> AccessibleTextRange -> Bool
== :: AccessibleTextRange -> AccessibleTextRange -> Bool
$c/= :: AccessibleTextRange -> AccessibleTextRange -> Bool
/= :: AccessibleTextRange -> AccessibleTextRange -> Bool
Eq)

instance SP.ManagedPtrNewtype AccessibleTextRange where
    toManagedPtr :: AccessibleTextRange -> ManagedPtr AccessibleTextRange
toManagedPtr (AccessibleTextRange ManagedPtr AccessibleTextRange
p) = ManagedPtr AccessibleTextRange
p

instance BoxedPtr AccessibleTextRange where
    boxedPtrCopy :: AccessibleTextRange -> IO AccessibleTextRange
boxedPtrCopy = \AccessibleTextRange
p -> AccessibleTextRange
-> (Ptr AccessibleTextRange -> IO AccessibleTextRange)
-> IO AccessibleTextRange
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr AccessibleTextRange
p (Int -> Ptr AccessibleTextRange -> IO (Ptr AccessibleTextRange)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
16 (Ptr AccessibleTextRange -> IO (Ptr AccessibleTextRange))
-> (Ptr AccessibleTextRange -> IO AccessibleTextRange)
-> Ptr AccessibleTextRange
-> IO AccessibleTextRange
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr AccessibleTextRange -> AccessibleTextRange)
-> Ptr AccessibleTextRange -> IO AccessibleTextRange
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr AccessibleTextRange -> AccessibleTextRange
AccessibleTextRange)
    boxedPtrFree :: AccessibleTextRange -> IO ()
boxedPtrFree = \AccessibleTextRange
x -> AccessibleTextRange -> (Ptr AccessibleTextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr AccessibleTextRange
x Ptr AccessibleTextRange -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr AccessibleTextRange where
    boxedPtrCalloc :: IO (Ptr AccessibleTextRange)
boxedPtrCalloc = Int -> IO (Ptr AccessibleTextRange)
forall a. Int -> IO (Ptr a)
callocBytes Int
16


-- | Construct a `AccessibleTextRange` struct initialized to zero.
newZeroAccessibleTextRange :: MonadIO m => m AccessibleTextRange
newZeroAccessibleTextRange :: forall (m :: * -> *). MonadIO m => m AccessibleTextRange
newZeroAccessibleTextRange = IO AccessibleTextRange -> m AccessibleTextRange
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AccessibleTextRange -> m AccessibleTextRange)
-> IO AccessibleTextRange -> m AccessibleTextRange
forall a b. (a -> b) -> a -> b
$ IO (Ptr AccessibleTextRange)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr AccessibleTextRange)
-> (Ptr AccessibleTextRange -> IO AccessibleTextRange)
-> IO AccessibleTextRange
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr AccessibleTextRange -> AccessibleTextRange)
-> Ptr AccessibleTextRange -> IO AccessibleTextRange
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AccessibleTextRange -> AccessibleTextRange
AccessibleTextRange

instance tag ~ 'AttrSet => Constructible AccessibleTextRange tag where
    new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr AccessibleTextRange -> AccessibleTextRange)
-> [AttrOp AccessibleTextRange tag] -> m AccessibleTextRange
new ManagedPtr AccessibleTextRange -> AccessibleTextRange
_ [AttrOp AccessibleTextRange tag]
attrs = do
        AccessibleTextRange
o <- m AccessibleTextRange
forall (m :: * -> *). MonadIO m => m AccessibleTextRange
newZeroAccessibleTextRange
        AccessibleTextRange
-> [AttrOp AccessibleTextRange 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set AccessibleTextRange
o [AttrOp AccessibleTextRange tag]
[AttrOp AccessibleTextRange 'AttrSet]
attrs
        AccessibleTextRange -> m AccessibleTextRange
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return AccessibleTextRange
o


-- | Get the value of the “@start@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' accessibleTextRange #start
-- @
getAccessibleTextRangeStart :: MonadIO m => AccessibleTextRange -> m FCT.CSize
getAccessibleTextRangeStart :: forall (m :: * -> *). MonadIO m => AccessibleTextRange -> m CSize
getAccessibleTextRangeStart AccessibleTextRange
s = IO CSize -> m CSize
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CSize -> m CSize) -> IO CSize -> m CSize
forall a b. (a -> b) -> a -> b
$ AccessibleTextRange
-> (Ptr AccessibleTextRange -> IO CSize) -> IO CSize
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AccessibleTextRange
s ((Ptr AccessibleTextRange -> IO CSize) -> IO CSize)
-> (Ptr AccessibleTextRange -> IO CSize) -> IO CSize
forall a b. (a -> b) -> a -> b
$ \Ptr AccessibleTextRange
ptr -> do
    CSize
val <- Ptr CSize -> IO CSize
forall a. Storable a => Ptr a -> IO a
peek (Ptr AccessibleTextRange
ptr Ptr AccessibleTextRange -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO FCT.CSize
    CSize -> IO CSize
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CSize
val

-- | Set the value of the “@start@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' accessibleTextRange [ #start 'Data.GI.Base.Attributes.:=' value ]
-- @
setAccessibleTextRangeStart :: MonadIO m => AccessibleTextRange -> FCT.CSize -> m ()
setAccessibleTextRangeStart :: forall (m :: * -> *).
MonadIO m =>
AccessibleTextRange -> CSize -> m ()
setAccessibleTextRangeStart AccessibleTextRange
s CSize
val = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AccessibleTextRange -> (Ptr AccessibleTextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AccessibleTextRange
s ((Ptr AccessibleTextRange -> IO ()) -> IO ())
-> (Ptr AccessibleTextRange -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr AccessibleTextRange
ptr -> do
    Ptr CSize -> CSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AccessibleTextRange
ptr Ptr AccessibleTextRange -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (CSize
val :: FCT.CSize)

#if defined(ENABLE_OVERLOADING)
data AccessibleTextRangeStartFieldInfo
instance AttrInfo AccessibleTextRangeStartFieldInfo where
    type AttrBaseTypeConstraint AccessibleTextRangeStartFieldInfo = (~) AccessibleTextRange
    type AttrAllowedOps AccessibleTextRangeStartFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AccessibleTextRangeStartFieldInfo = (~) FCT.CSize
    type AttrTransferTypeConstraint AccessibleTextRangeStartFieldInfo = (~)FCT.CSize
    type AttrTransferType AccessibleTextRangeStartFieldInfo = FCT.CSize
    type AttrGetType AccessibleTextRangeStartFieldInfo = FCT.CSize
    type AttrLabel AccessibleTextRangeStartFieldInfo = "start"
    type AttrOrigin AccessibleTextRangeStartFieldInfo = AccessibleTextRange
    attrGet = getAccessibleTextRangeStart
    attrSet = setAccessibleTextRangeStart
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gtk.Structs.AccessibleTextRange.start"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk-4.0.9/docs/GI-Gtk-Structs-AccessibleTextRange.html#g:attr:start"
        })

accessibleTextRange_start :: AttrLabelProxy "start"
accessibleTextRange_start = AttrLabelProxy

#endif


-- | Get the value of the “@length@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' accessibleTextRange #length
-- @
getAccessibleTextRangeLength :: MonadIO m => AccessibleTextRange -> m FCT.CSize
getAccessibleTextRangeLength :: forall (m :: * -> *). MonadIO m => AccessibleTextRange -> m CSize
getAccessibleTextRangeLength AccessibleTextRange
s = IO CSize -> m CSize
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CSize -> m CSize) -> IO CSize -> m CSize
forall a b. (a -> b) -> a -> b
$ AccessibleTextRange
-> (Ptr AccessibleTextRange -> IO CSize) -> IO CSize
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AccessibleTextRange
s ((Ptr AccessibleTextRange -> IO CSize) -> IO CSize)
-> (Ptr AccessibleTextRange -> IO CSize) -> IO CSize
forall a b. (a -> b) -> a -> b
$ \Ptr AccessibleTextRange
ptr -> do
    CSize
val <- Ptr CSize -> IO CSize
forall a. Storable a => Ptr a -> IO a
peek (Ptr AccessibleTextRange
ptr Ptr AccessibleTextRange -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) :: IO FCT.CSize
    CSize -> IO CSize
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CSize
val

-- | Set the value of the “@length@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' accessibleTextRange [ #length 'Data.GI.Base.Attributes.:=' value ]
-- @
setAccessibleTextRangeLength :: MonadIO m => AccessibleTextRange -> FCT.CSize -> m ()
setAccessibleTextRangeLength :: forall (m :: * -> *).
MonadIO m =>
AccessibleTextRange -> CSize -> m ()
setAccessibleTextRangeLength AccessibleTextRange
s CSize
val = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AccessibleTextRange -> (Ptr AccessibleTextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AccessibleTextRange
s ((Ptr AccessibleTextRange -> IO ()) -> IO ())
-> (Ptr AccessibleTextRange -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr AccessibleTextRange
ptr -> do
    Ptr CSize -> CSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AccessibleTextRange
ptr Ptr AccessibleTextRange -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (CSize
val :: FCT.CSize)

#if defined(ENABLE_OVERLOADING)
data AccessibleTextRangeLengthFieldInfo
instance AttrInfo AccessibleTextRangeLengthFieldInfo where
    type AttrBaseTypeConstraint AccessibleTextRangeLengthFieldInfo = (~) AccessibleTextRange
    type AttrAllowedOps AccessibleTextRangeLengthFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint AccessibleTextRangeLengthFieldInfo = (~) FCT.CSize
    type AttrTransferTypeConstraint AccessibleTextRangeLengthFieldInfo = (~)FCT.CSize
    type AttrTransferType AccessibleTextRangeLengthFieldInfo = FCT.CSize
    type AttrGetType AccessibleTextRangeLengthFieldInfo = FCT.CSize
    type AttrLabel AccessibleTextRangeLengthFieldInfo = "length"
    type AttrOrigin AccessibleTextRangeLengthFieldInfo = AccessibleTextRange
    attrGet = getAccessibleTextRangeLength
    attrSet = setAccessibleTextRangeLength
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gtk.Structs.AccessibleTextRange.length"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk-4.0.9/docs/GI-Gtk-Structs-AccessibleTextRange.html#g:attr:length"
        })

accessibleTextRange_length :: AttrLabelProxy "length"
accessibleTextRange_length = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AccessibleTextRange
type instance O.AttributeList AccessibleTextRange = AccessibleTextRangeAttributeList
type AccessibleTextRangeAttributeList = ('[ '("start", AccessibleTextRangeStartFieldInfo), '("length", AccessibleTextRangeLengthFieldInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveAccessibleTextRangeMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveAccessibleTextRangeMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveAccessibleTextRangeMethod t AccessibleTextRange, O.OverloadedMethod info AccessibleTextRange p) => OL.IsLabel t (AccessibleTextRange -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveAccessibleTextRangeMethod t AccessibleTextRange, O.OverloadedMethod info AccessibleTextRange p, R.HasField t AccessibleTextRange p) => R.HasField t AccessibleTextRange p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveAccessibleTextRangeMethod t AccessibleTextRange, O.OverloadedMethodInfo info AccessibleTextRange) => OL.IsLabel t (O.MethodProxy info AccessibleTextRange) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif