#define ENABLE_OVERLOADING \
(!defined(__HADDOCK_VERSION__))
module GI.Atk.Structs.TextRange
(
TextRange(..) ,
newZeroTextRange ,
noTextRange ,
getTextRangeBounds ,
#if ENABLE_OVERLOADING
textRange_bounds ,
#endif
clearTextRangeContent ,
getTextRangeContent ,
setTextRangeContent ,
#if ENABLE_OVERLOADING
textRange_content ,
#endif
getTextRangeEndOffset ,
setTextRangeEndOffset ,
#if ENABLE_OVERLOADING
textRange_endOffset ,
#endif
getTextRangeStartOffset ,
setTextRangeStartOffset ,
#if ENABLE_OVERLOADING
textRange_startOffset ,
#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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import {-# SOURCE #-} qualified GI.Atk.Structs.TextRectangle as Atk.TextRectangle
newtype = (ManagedPtr TextRange)
foreign import ccall "atk_text_range_get_type" c_atk_text_range_get_type ::
IO GType
instance BoxedObject TextRange where
boxedType :: TextRange -> IO GType
boxedType _ = IO GType
c_atk_text_range_get_type
newZeroTextRange :: MonadIO m => m TextRange
= IO TextRange -> m TextRange
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TextRange -> m TextRange) -> IO TextRange -> m TextRange
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr TextRange)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 32 IO (Ptr TextRange)
-> (Ptr TextRange -> IO TextRange) -> IO TextRange
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TextRange -> TextRange)
-> Ptr TextRange -> IO TextRange
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TextRange -> TextRange
TextRange
instance tag ~ 'AttrSet => Constructible TextRange tag where
new :: (ManagedPtr TextRange -> TextRange)
-> [AttrOp TextRange tag] -> m TextRange
new _ attrs :: [AttrOp TextRange tag]
attrs = do
TextRange
o <- m TextRange
forall (m :: * -> *). MonadIO m => m TextRange
newZeroTextRange
TextRange -> [AttrOp TextRange 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set TextRange
o [AttrOp TextRange tag]
[AttrOp TextRange 'AttrSet]
attrs
TextRange -> m TextRange
forall (m :: * -> *) a. Monad m => a -> m a
return TextRange
o
noTextRange :: Maybe TextRange
= Maybe TextRange
forall a. Maybe a
Nothing
getTextRangeBounds :: MonadIO m => TextRange -> m Atk.TextRectangle.TextRectangle
s :: TextRange
s = IO TextRectangle -> m TextRectangle
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TextRectangle -> m TextRectangle)
-> IO TextRectangle -> m TextRectangle
forall a b. (a -> b) -> a -> b
$ TextRange
-> (Ptr TextRange -> IO TextRectangle) -> IO TextRectangle
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO TextRectangle) -> IO TextRectangle)
-> (Ptr TextRange -> IO TextRectangle) -> IO TextRectangle
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
let val :: Ptr TextRectangle
val = Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr TextRectangle
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: (Ptr Atk.TextRectangle.TextRectangle)
TextRectangle
val' <- ((ManagedPtr TextRectangle -> TextRectangle)
-> Ptr TextRectangle -> IO TextRectangle
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TextRectangle -> TextRectangle
Atk.TextRectangle.TextRectangle) Ptr TextRectangle
val
TextRectangle -> IO TextRectangle
forall (m :: * -> *) a. Monad m => a -> m a
return TextRectangle
val'
#if ENABLE_OVERLOADING
data TextRangeBoundsFieldInfo
instance AttrInfo TextRangeBoundsFieldInfo where
type AttrAllowedOps TextRangeBoundsFieldInfo = '[ 'AttrGet]
type AttrSetTypeConstraint TextRangeBoundsFieldInfo = (~) (Ptr Atk.TextRectangle.TextRectangle)
type AttrBaseTypeConstraint TextRangeBoundsFieldInfo = (~) TextRange
type AttrGetType TextRangeBoundsFieldInfo = Atk.TextRectangle.TextRectangle
type AttrLabel TextRangeBoundsFieldInfo = "bounds"
type AttrOrigin TextRangeBoundsFieldInfo = TextRange
attrGet _ = getTextRangeBounds
attrSet _ = undefined
attrConstruct = undefined
attrClear _ = undefined
textRange_bounds :: AttrLabelProxy "bounds"
textRange_bounds = AttrLabelProxy
#endif
getTextRangeStartOffset :: MonadIO m => TextRange -> m Int32
s :: TextRange
s = 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
$ TextRange -> (Ptr TextRange -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO Int32) -> IO Int32)
-> (Ptr TextRange -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO Int32
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val
setTextRangeStartOffset :: MonadIO m => TextRange -> Int32 -> m ()
s :: TextRange
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRange -> (Ptr TextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO ()) -> IO ())
-> (Ptr TextRange -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (Int32
val :: Int32)
#if ENABLE_OVERLOADING
data TextRangeStartOffsetFieldInfo
instance AttrInfo TextRangeStartOffsetFieldInfo where
type AttrAllowedOps TextRangeStartOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint TextRangeStartOffsetFieldInfo = (~) Int32
type AttrBaseTypeConstraint TextRangeStartOffsetFieldInfo = (~) TextRange
type AttrGetType TextRangeStartOffsetFieldInfo = Int32
type AttrLabel TextRangeStartOffsetFieldInfo = "start_offset"
type AttrOrigin TextRangeStartOffsetFieldInfo = TextRange
attrGet _ = getTextRangeStartOffset
attrSet _ = setTextRangeStartOffset
attrConstruct = undefined
attrClear _ = undefined
textRange_startOffset :: AttrLabelProxy "startOffset"
textRange_startOffset = AttrLabelProxy
#endif
getTextRangeEndOffset :: MonadIO m => TextRange -> m Int32
s :: TextRange
s = 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
$ TextRange -> (Ptr TextRange -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO Int32) -> IO Int32)
-> (Ptr TextRange -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20) :: IO Int32
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val
setTextRangeEndOffset :: MonadIO m => TextRange -> Int32 -> m ()
s :: TextRange
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRange -> (Ptr TextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO ()) -> IO ())
-> (Ptr TextRange -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20) (Int32
val :: Int32)
#if ENABLE_OVERLOADING
data TextRangeEndOffsetFieldInfo
instance AttrInfo TextRangeEndOffsetFieldInfo where
type AttrAllowedOps TextRangeEndOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint TextRangeEndOffsetFieldInfo = (~) Int32
type AttrBaseTypeConstraint TextRangeEndOffsetFieldInfo = (~) TextRange
type AttrGetType TextRangeEndOffsetFieldInfo = Int32
type AttrLabel TextRangeEndOffsetFieldInfo = "end_offset"
type AttrOrigin TextRangeEndOffsetFieldInfo = TextRange
attrGet _ = getTextRangeEndOffset
attrSet _ = setTextRangeEndOffset
attrConstruct = undefined
attrClear _ = undefined
textRange_endOffset :: AttrLabelProxy "endOffset"
textRange_endOffset = AttrLabelProxy
#endif
getTextRangeContent :: MonadIO m => TextRange -> m (Maybe T.Text)
s :: TextRange
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ TextRange -> (Ptr TextRange -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr TextRange -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) :: IO CString
Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result
setTextRangeContent :: MonadIO m => TextRange -> CString -> m ()
s :: TextRange
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRange -> (Ptr TextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO ()) -> IO ())
-> (Ptr TextRange -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) (CString
val :: CString)
clearTextRangeContent :: MonadIO m => TextRange -> m ()
s :: TextRange
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TextRange -> (Ptr TextRange -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TextRange
s ((Ptr TextRange -> IO ()) -> IO ())
-> (Ptr TextRange -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr TextRange
ptr -> do
Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextRange
ptr Ptr TextRange -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24) (CString
forall a. Ptr a
FP.nullPtr :: CString)
#if ENABLE_OVERLOADING
data TextRangeContentFieldInfo
instance AttrInfo TextRangeContentFieldInfo where
type AttrAllowedOps TextRangeContentFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint TextRangeContentFieldInfo = (~) CString
type AttrBaseTypeConstraint TextRangeContentFieldInfo = (~) TextRange
type AttrGetType TextRangeContentFieldInfo = Maybe T.Text
type AttrLabel TextRangeContentFieldInfo = "content"
type AttrOrigin TextRangeContentFieldInfo = TextRange
attrGet _ = getTextRangeContent
attrSet _ = setTextRangeContent
attrConstruct = undefined
attrClear _ = clearTextRangeContent
textRange_content :: AttrLabelProxy "content"
textRange_content = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList TextRange
type instance O.AttributeList TextRange = TextRangeAttributeList
type TextRangeAttributeList = ('[ '("bounds", TextRangeBoundsFieldInfo), '("startOffset", TextRangeStartOffsetFieldInfo), '("endOffset", TextRangeEndOffsetFieldInfo), '("content", TextRangeContentFieldInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
type family ResolveTextRangeMethod (t :: Symbol) (o :: *) :: * where
ResolveTextRangeMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveTextRangeMethod t TextRange, O.MethodInfo info TextRange p) => O.IsLabelProxy t (TextRange -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTextRangeMethod t TextRange, O.MethodInfo info TextRange p) => O.IsLabel t (TextRange -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
#endif