{- |
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.GtkSource.Objects.Region
    ( 

-- * Exported types
    Region(..)                              ,
    IsRegion                                ,
    toRegion                                ,
    noRegion                                ,


 -- * Methods
-- ** addRegion #method:addRegion#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionAddRegionMethodInfo               ,
#endif
    regionAddRegion                         ,


-- ** addSubregion #method:addSubregion#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionAddSubregionMethodInfo            ,
#endif
    regionAddSubregion                      ,


-- ** getBounds #method:getBounds#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionGetBoundsMethodInfo               ,
#endif
    regionGetBounds                         ,


-- ** getBuffer #method:getBuffer#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionGetBufferMethodInfo               ,
#endif
    regionGetBuffer                         ,


-- ** getStartRegionIter #method:getStartRegionIter#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionGetStartRegionIterMethodInfo      ,
#endif
    regionGetStartRegionIter                ,


-- ** intersectRegion #method:intersectRegion#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionIntersectRegionMethodInfo         ,
#endif
    regionIntersectRegion                   ,


-- ** intersectSubregion #method:intersectSubregion#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionIntersectSubregionMethodInfo      ,
#endif
    regionIntersectSubregion                ,


-- ** isEmpty #method:isEmpty#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionIsEmptyMethodInfo                 ,
#endif
    regionIsEmpty                           ,


-- ** new #method:new#
    regionNew                               ,


-- ** subtractRegion #method:subtractRegion#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionSubtractRegionMethodInfo          ,
#endif
    regionSubtractRegion                    ,


-- ** subtractSubregion #method:subtractSubregion#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionSubtractSubregionMethodInfo       ,
#endif
    regionSubtractSubregion                 ,


-- ** toString #method:toString#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionToStringMethodInfo                ,
#endif
    regionToString                          ,




 -- * Properties
-- ** buffer #attr:buffer#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RegionBufferPropertyInfo                ,
#endif
    constructRegionBuffer                   ,
    getRegionBuffer                         ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    regionBuffer                            ,
#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.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.Gtk.Objects.TextBuffer as Gtk.TextBuffer
import qualified GI.Gtk.Structs.TextIter as Gtk.TextIter
import {-# SOURCE #-} qualified GI.GtkSource.Structs.RegionIter as GtkSource.RegionIter

newtype Region = Region (ManagedPtr Region)
foreign import ccall "gtk_source_region_get_type"
    c_gtk_source_region_get_type :: IO GType

instance GObject Region where
    gobjectType _ = c_gtk_source_region_get_type
    

class GObject o => IsRegion o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Region a) =>
    IsRegion a
#endif
instance IsRegion Region
instance GObject.Object.IsObject Region

toRegion :: (MonadIO m, IsRegion o) => o -> m Region
toRegion = liftIO . unsafeCastTo Region

noRegion :: Maybe Region
noRegion = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveRegionMethod (t :: Symbol) (o :: *) :: * where
    ResolveRegionMethod "addRegion" o = RegionAddRegionMethodInfo
    ResolveRegionMethod "addSubregion" o = RegionAddSubregionMethodInfo
    ResolveRegionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveRegionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveRegionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveRegionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveRegionMethod "intersectRegion" o = RegionIntersectRegionMethodInfo
    ResolveRegionMethod "intersectSubregion" o = RegionIntersectSubregionMethodInfo
    ResolveRegionMethod "isEmpty" o = RegionIsEmptyMethodInfo
    ResolveRegionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveRegionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveRegionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveRegionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveRegionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveRegionMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveRegionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveRegionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveRegionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveRegionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveRegionMethod "subtractRegion" o = RegionSubtractRegionMethodInfo
    ResolveRegionMethod "subtractSubregion" o = RegionSubtractSubregionMethodInfo
    ResolveRegionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveRegionMethod "toString" o = RegionToStringMethodInfo
    ResolveRegionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveRegionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveRegionMethod "getBounds" o = RegionGetBoundsMethodInfo
    ResolveRegionMethod "getBuffer" o = RegionGetBufferMethodInfo
    ResolveRegionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveRegionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveRegionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveRegionMethod "getStartRegionIter" o = RegionGetStartRegionIterMethodInfo
    ResolveRegionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveRegionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveRegionMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRegionMethod t Region, O.MethodInfo info Region p) => O.IsLabel t (Region -> 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

-- VVV Prop "buffer"
   -- Type: TInterface (Name {namespace = "Gtk", name = "TextBuffer"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

getRegionBuffer :: (MonadIO m, IsRegion o) => o -> m (Maybe Gtk.TextBuffer.TextBuffer)
getRegionBuffer obj = liftIO $ getObjectPropertyObject obj "buffer" Gtk.TextBuffer.TextBuffer

constructRegionBuffer :: (IsRegion o, Gtk.TextBuffer.IsTextBuffer a) => a -> IO (GValueConstruct o)
constructRegionBuffer val = constructObjectPropertyObject "buffer" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionBufferPropertyInfo
instance AttrInfo RegionBufferPropertyInfo where
    type AttrAllowedOps RegionBufferPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint RegionBufferPropertyInfo = Gtk.TextBuffer.IsTextBuffer
    type AttrBaseTypeConstraint RegionBufferPropertyInfo = IsRegion
    type AttrGetType RegionBufferPropertyInfo = (Maybe Gtk.TextBuffer.TextBuffer)
    type AttrLabel RegionBufferPropertyInfo = "buffer"
    type AttrOrigin RegionBufferPropertyInfo = Region
    attrGet _ = getRegionBuffer
    attrSet _ = undefined
    attrConstruct _ = constructRegionBuffer
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList Region
type instance O.AttributeList Region = RegionAttributeList
type RegionAttributeList = ('[ '("buffer", RegionBufferPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
regionBuffer :: AttrLabelProxy "buffer"
regionBuffer = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList Region = RegionSignalList
type RegionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Region::new
-- method type : Constructor
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gtk", name = "TextBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkTextBuffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Region"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_new" gtk_source_region_new :: 
    Ptr Gtk.TextBuffer.TextBuffer ->        -- buffer : TInterface (Name {namespace = "Gtk", name = "TextBuffer"})
    IO (Ptr Region)

{- |
/No description available in the introspection data./

@since 3.22
-}
regionNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gtk.TextBuffer.IsTextBuffer a) =>
    a
    {- ^ /@buffer@/: a 'GI.Gtk.Objects.TextBuffer.TextBuffer'. -}
    -> m Region
    {- ^ __Returns:__ a new 'GI.GtkSource.Objects.Region.Region' object for /@buffer@/. -}
regionNew buffer = liftIO $ do
    buffer' <- unsafeManagedPtrCastPtr buffer
    result <- gtk_source_region_new buffer'
    checkUnexpectedReturnNULL "regionNew" result
    result' <- (wrapObject Region) result
    touchManagedPtr buffer
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

-- method Region::add_region
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "region_to_add", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GtkSourceRegion to add to @region, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_add_region" gtk_source_region_add_region :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Region ->                           -- region_to_add : TInterface (Name {namespace = "GtkSource", name = "Region"})
    IO ()

{- |
Adds /@regionToAdd@/ to /@region@/. /@regionToAdd@/ is not modified.

@since 3.22
-}
regionAddRegion ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a, IsRegion b) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> Maybe (b)
    {- ^ /@regionToAdd@/: the 'GI.GtkSource.Objects.Region.Region' to add to /@region@/, or 'Nothing'. -}
    -> m ()
regionAddRegion region regionToAdd = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    maybeRegionToAdd <- case regionToAdd of
        Nothing -> return nullPtr
        Just jRegionToAdd -> do
            jRegionToAdd' <- unsafeManagedPtrCastPtr jRegionToAdd
            return jRegionToAdd'
    gtk_source_region_add_region region' maybeRegionToAdd
    touchManagedPtr region
    whenJust regionToAdd touchManagedPtr
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionAddRegionMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsRegion a, IsRegion b) => O.MethodInfo RegionAddRegionMethodInfo a signature where
    overloadedMethod _ = regionAddRegion

#endif

-- method Region::add_subregion
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_add_subregion" gtk_source_region_add_subregion :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Gtk.TextIter.TextIter ->            -- _start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- _end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO ()

{- |
Adds the subregion delimited by /@start_@/ and /@end_@/ to /@region@/.

@since 3.22
-}
regionAddSubregion ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@start_@/: the start of the subregion. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@end_@/: the end of the subregion. -}
    -> m ()
regionAddSubregion region _start _end = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    _start' <- unsafeManagedPtrGetPtr _start
    _end' <- unsafeManagedPtrGetPtr _end
    gtk_source_region_add_subregion region' _start' _end'
    touchManagedPtr region
    touchManagedPtr _start
    touchManagedPtr _end
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionAddSubregionMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Gtk.TextIter.TextIter -> m ()), MonadIO m, IsRegion a) => O.MethodInfo RegionAddSubregionMethodInfo a signature where
    overloadedMethod _ = regionAddSubregion

#endif

-- method Region::get_bounds
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "iterator to initialize with the start of @region,\n  or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "iterator to initialize with the end of @region,\n  or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_get_bounds" gtk_source_region_get_bounds :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Gtk.TextIter.TextIter ->            -- start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO CInt

{- |
Gets the /@start@/ and /@end@/ bounds of the /@region@/.

@since 3.22
-}
regionGetBounds ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> m ((Bool, Gtk.TextIter.TextIter, Gtk.TextIter.TextIter))
    {- ^ __Returns:__ 'True' if /@start@/ and /@end@/ have been set successfully (if non-'Nothing'),
  or 'False' if the /@region@/ is empty. -}
regionGetBounds region = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    start <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    end <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    result <- gtk_source_region_get_bounds region' start end
    let result' = (/= 0) result
    start' <- (wrapBoxed Gtk.TextIter.TextIter) start
    end' <- (wrapBoxed Gtk.TextIter.TextIter) end
    touchManagedPtr region
    return (result', start', end')

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionGetBoundsMethodInfo
instance (signature ~ (m ((Bool, Gtk.TextIter.TextIter, Gtk.TextIter.TextIter))), MonadIO m, IsRegion a) => O.MethodInfo RegionGetBoundsMethodInfo a signature where
    overloadedMethod _ = regionGetBounds

#endif

-- method Region::get_buffer
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "TextBuffer"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_get_buffer" gtk_source_region_get_buffer :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    IO (Ptr Gtk.TextBuffer.TextBuffer)

{- |
/No description available in the introspection data./

@since 3.22
-}
regionGetBuffer ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> m (Maybe Gtk.TextBuffer.TextBuffer)
    {- ^ __Returns:__ the 'GI.Gtk.Objects.TextBuffer.TextBuffer'. -}
regionGetBuffer region = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    result <- gtk_source_region_get_buffer region'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gtk.TextBuffer.TextBuffer) result'
        return result''
    touchManagedPtr region
    return maybeResult

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionGetBufferMethodInfo
instance (signature ~ (m (Maybe Gtk.TextBuffer.TextBuffer)), MonadIO m, IsRegion a) => O.MethodInfo RegionGetBufferMethodInfo a signature where
    overloadedMethod _ = regionGetBuffer

#endif

-- method Region::get_start_region_iter
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "GtkSource", name = "RegionIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "iterator to initialize to the first subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_get_start_region_iter" gtk_source_region_get_start_region_iter :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr GtkSource.RegionIter.RegionIter ->  -- iter : TInterface (Name {namespace = "GtkSource", name = "RegionIter"})
    IO ()

{- |
Initializes a 'GI.GtkSource.Structs.RegionIter.RegionIter' to the first subregion of /@region@/. If
/@region@/ is empty, /@iter@/ will be initialized to the end iterator.

@since 3.22
-}
regionGetStartRegionIter ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> m (GtkSource.RegionIter.RegionIter)
regionGetStartRegionIter region = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    iter <- callocBytes 24 :: IO (Ptr GtkSource.RegionIter.RegionIter)
    gtk_source_region_get_start_region_iter region' iter
    iter' <- (wrapPtr GtkSource.RegionIter.RegionIter) iter
    touchManagedPtr region
    return iter'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionGetStartRegionIterMethodInfo
instance (signature ~ (m (GtkSource.RegionIter.RegionIter)), MonadIO m, IsRegion a) => O.MethodInfo RegionGetStartRegionIterMethodInfo a signature where
    overloadedMethod _ = regionGetStartRegionIter

#endif

-- method Region::intersect_region
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region1", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "region2", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Region"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_intersect_region" gtk_source_region_intersect_region :: 
    Ptr Region ->                           -- region1 : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Region ->                           -- region2 : TInterface (Name {namespace = "GtkSource", name = "Region"})
    IO (Ptr Region)

{- |
Returns the intersection between /@region1@/ and /@region2@/. /@region1@/ and
/@region2@/ are not modified.

@since 3.22
-}
regionIntersectRegion ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a, IsRegion b) =>
    a
    {- ^ /@region1@/: a 'GI.GtkSource.Objects.Region.Region', or 'Nothing'. -}
    -> Maybe (b)
    {- ^ /@region2@/: a 'GI.GtkSource.Objects.Region.Region', or 'Nothing'. -}
    -> m (Maybe Region)
    {- ^ __Returns:__ the intersection as a 'GI.GtkSource.Objects.Region.Region'
  object. -}
regionIntersectRegion region1 region2 = liftIO $ do
    region1' <- unsafeManagedPtrCastPtr region1
    maybeRegion2 <- case region2 of
        Nothing -> return nullPtr
        Just jRegion2 -> do
            jRegion2' <- unsafeManagedPtrCastPtr jRegion2
            return jRegion2'
    result <- gtk_source_region_intersect_region region1' maybeRegion2
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Region) result'
        return result''
    touchManagedPtr region1
    whenJust region2 touchManagedPtr
    return maybeResult

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionIntersectRegionMethodInfo
instance (signature ~ (Maybe (b) -> m (Maybe Region)), MonadIO m, IsRegion a, IsRegion b) => O.MethodInfo RegionIntersectRegionMethodInfo a signature where
    overloadedMethod _ = regionIntersectRegion

#endif

-- method Region::intersect_subregion
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Region"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_intersect_subregion" gtk_source_region_intersect_subregion :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Gtk.TextIter.TextIter ->            -- _start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- _end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO (Ptr Region)

{- |
Returns the intersection between /@region@/ and the subregion delimited by
/@start_@/ and /@end_@/. /@region@/ is not modified.

@since 3.22
-}
regionIntersectSubregion ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@start_@/: the start of the subregion. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@end_@/: the end of the subregion. -}
    -> m (Maybe Region)
    {- ^ __Returns:__ the intersection as a new
  'GI.GtkSource.Objects.Region.Region'. -}
regionIntersectSubregion region _start _end = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    _start' <- unsafeManagedPtrGetPtr _start
    _end' <- unsafeManagedPtrGetPtr _end
    result <- gtk_source_region_intersect_subregion region' _start' _end'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Region) result'
        return result''
    touchManagedPtr region
    touchManagedPtr _start
    touchManagedPtr _end
    return maybeResult

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionIntersectSubregionMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Gtk.TextIter.TextIter -> m (Maybe Region)), MonadIO m, IsRegion a) => O.MethodInfo RegionIntersectSubregionMethodInfo a signature where
    overloadedMethod _ = regionIntersectSubregion

#endif

-- method Region::is_empty
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_is_empty" gtk_source_region_is_empty :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    IO CInt

{- |
Returns whether the /@region@/ is empty. A 'Nothing' /@region@/ is considered empty.

@since 3.22
-}
regionIsEmpty ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region', or 'Nothing'. -}
    -> m Bool
    {- ^ __Returns:__ whether the /@region@/ is empty. -}
regionIsEmpty region = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    result <- gtk_source_region_is_empty region'
    let result' = (/= 0) result
    touchManagedPtr region
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionIsEmptyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsRegion a) => O.MethodInfo RegionIsEmptyMethodInfo a signature where
    overloadedMethod _ = regionIsEmpty

#endif

-- method Region::subtract_region
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "region_to_subtract", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GtkSourceRegion to subtract from\n  @region, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_subtract_region" gtk_source_region_subtract_region :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Region ->                           -- region_to_subtract : TInterface (Name {namespace = "GtkSource", name = "Region"})
    IO ()

{- |
Subtracts /@regionToSubtract@/ from /@region@/. /@regionToSubtract@/ is not
modified.

@since 3.22
-}
regionSubtractRegion ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a, IsRegion b) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> Maybe (b)
    {- ^ /@regionToSubtract@/: the 'GI.GtkSource.Objects.Region.Region' to subtract from
  /@region@/, or 'Nothing'. -}
    -> m ()
regionSubtractRegion region regionToSubtract = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    maybeRegionToSubtract <- case regionToSubtract of
        Nothing -> return nullPtr
        Just jRegionToSubtract -> do
            jRegionToSubtract' <- unsafeManagedPtrCastPtr jRegionToSubtract
            return jRegionToSubtract'
    gtk_source_region_subtract_region region' maybeRegionToSubtract
    touchManagedPtr region
    whenJust regionToSubtract touchManagedPtr
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionSubtractRegionMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsRegion a, IsRegion b) => O.MethodInfo RegionSubtractRegionMethodInfo a signature where
    overloadedMethod _ = regionSubtractRegion

#endif

-- method Region::subtract_subregion
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the subregion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_subtract_subregion" gtk_source_region_subtract_subregion :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    Ptr Gtk.TextIter.TextIter ->            -- _start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- _end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO ()

{- |
Subtracts the subregion delimited by /@start_@/ and /@end_@/ from /@region@/.

@since 3.22
-}
regionSubtractSubregion ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@start_@/: the start of the subregion. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@end_@/: the end of the subregion. -}
    -> m ()
regionSubtractSubregion region _start _end = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    _start' <- unsafeManagedPtrGetPtr _start
    _end' <- unsafeManagedPtrGetPtr _end
    gtk_source_region_subtract_subregion region' _start' _end'
    touchManagedPtr region
    touchManagedPtr _start
    touchManagedPtr _end
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionSubtractSubregionMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Gtk.TextIter.TextIter -> m ()), MonadIO m, IsRegion a) => O.MethodInfo RegionSubtractSubregionMethodInfo a signature where
    overloadedMethod _ = regionSubtractSubregion

#endif

-- method Region::to_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "region", argType = TInterface (Name {namespace = "GtkSource", name = "Region"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceRegion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_region_to_string" gtk_source_region_to_string :: 
    Ptr Region ->                           -- region : TInterface (Name {namespace = "GtkSource", name = "Region"})
    IO CString

{- |
Gets a string represention of /@region@/, for debugging purposes.

The returned string contains the character offsets of the subregions. It
doesn\'t include a newline character at the end of the string.

@since 3.22
-}
regionToString ::
    (B.CallStack.HasCallStack, MonadIO m, IsRegion a) =>
    a
    {- ^ /@region@/: a 'GI.GtkSource.Objects.Region.Region'. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ a string represention of /@region@/. Free
  with 'GI.GLib.Functions.free' when no longer needed. -}
regionToString region = liftIO $ do
    region' <- unsafeManagedPtrCastPtr region
    result <- gtk_source_region_to_string region'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        freeMem result'
        return result''
    touchManagedPtr region
    return maybeResult

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RegionToStringMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRegion a) => O.MethodInfo RegionToStringMethodInfo a signature where
    overloadedMethod _ = regionToString

#endif