{- |
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.SearchContext
    ( 

-- * Exported types
    SearchContext(..)                       ,
    IsSearchContext                         ,
    toSearchContext                         ,
    noSearchContext                         ,


 -- * Methods
-- ** backward #method:backward#
    SearchContextBackwardMethodInfo         ,
    searchContextBackward                   ,


-- ** backward2 #method:backward2#
    SearchContextBackward2MethodInfo        ,
    searchContextBackward2                  ,


-- ** backwardAsync #method:backwardAsync#
    SearchContextBackwardAsyncMethodInfo    ,
    searchContextBackwardAsync              ,


-- ** backwardFinish #method:backwardFinish#
    SearchContextBackwardFinishMethodInfo   ,
    searchContextBackwardFinish             ,


-- ** backwardFinish2 #method:backwardFinish2#
    SearchContextBackwardFinish2MethodInfo  ,
    searchContextBackwardFinish2            ,


-- ** forward #method:forward#
    SearchContextForwardMethodInfo          ,
    searchContextForward                    ,


-- ** forward2 #method:forward2#
    SearchContextForward2MethodInfo         ,
    searchContextForward2                   ,


-- ** forwardAsync #method:forwardAsync#
    SearchContextForwardAsyncMethodInfo     ,
    searchContextForwardAsync               ,


-- ** forwardFinish #method:forwardFinish#
    SearchContextForwardFinishMethodInfo    ,
    searchContextForwardFinish              ,


-- ** forwardFinish2 #method:forwardFinish2#
    SearchContextForwardFinish2MethodInfo   ,
    searchContextForwardFinish2             ,


-- ** getBuffer #method:getBuffer#
    SearchContextGetBufferMethodInfo        ,
    searchContextGetBuffer                  ,


-- ** getHighlight #method:getHighlight#
    SearchContextGetHighlightMethodInfo     ,
    searchContextGetHighlight               ,


-- ** getMatchStyle #method:getMatchStyle#
    SearchContextGetMatchStyleMethodInfo    ,
    searchContextGetMatchStyle              ,


-- ** getOccurrencePosition #method:getOccurrencePosition#
    SearchContextGetOccurrencePositionMethodInfo,
    searchContextGetOccurrencePosition      ,


-- ** getOccurrencesCount #method:getOccurrencesCount#
    SearchContextGetOccurrencesCountMethodInfo,
    searchContextGetOccurrencesCount        ,


-- ** getRegexError #method:getRegexError#
    SearchContextGetRegexErrorMethodInfo    ,
    searchContextGetRegexError              ,


-- ** getSettings #method:getSettings#
    SearchContextGetSettingsMethodInfo      ,
    searchContextGetSettings                ,


-- ** new #method:new#
    searchContextNew                        ,


-- ** replace #method:replace#
    SearchContextReplaceMethodInfo          ,
    searchContextReplace                    ,


-- ** replace2 #method:replace2#
    SearchContextReplace2MethodInfo         ,
    searchContextReplace2                   ,


-- ** replaceAll #method:replaceAll#
    SearchContextReplaceAllMethodInfo       ,
    searchContextReplaceAll                 ,


-- ** setHighlight #method:setHighlight#
    SearchContextSetHighlightMethodInfo     ,
    searchContextSetHighlight               ,


-- ** setMatchStyle #method:setMatchStyle#
    SearchContextSetMatchStyleMethodInfo    ,
    searchContextSetMatchStyle              ,


-- ** setSettings #method:setSettings#
    SearchContextSetSettingsMethodInfo      ,
    searchContextSetSettings                ,




 -- * Properties
-- ** buffer #attr:buffer#
    SearchContextBufferPropertyInfo         ,
    constructSearchContextBuffer            ,
    getSearchContextBuffer                  ,
    searchContextBuffer                     ,


-- ** highlight #attr:highlight#
    SearchContextHighlightPropertyInfo      ,
    constructSearchContextHighlight         ,
    getSearchContextHighlight               ,
    searchContextHighlight                  ,
    setSearchContextHighlight               ,


-- ** matchStyle #attr:matchStyle#
    SearchContextMatchStylePropertyInfo     ,
    clearSearchContextMatchStyle            ,
    constructSearchContextMatchStyle        ,
    getSearchContextMatchStyle              ,
    searchContextMatchStyle                 ,
    setSearchContextMatchStyle              ,


-- ** occurrencesCount #attr:occurrencesCount#
    SearchContextOccurrencesCountPropertyInfo,
    getSearchContextOccurrencesCount        ,
    searchContextOccurrencesCount           ,


-- ** regexError #attr:regexError#
    SearchContextRegexErrorPropertyInfo     ,
    getSearchContextRegexError              ,
    searchContextRegexError                 ,


-- ** settings #attr:settings#
    SearchContextSettingsPropertyInfo       ,
    clearSearchContextSettings              ,
    constructSearchContextSettings          ,
    getSearchContextSettings                ,
    searchContextSettings                   ,
    setSearchContextSettings                ,




    ) where

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

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

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gtk.Structs.TextIter as Gtk.TextIter
import {-# SOURCE #-} qualified GI.GtkSource.Objects.Buffer as GtkSource.Buffer
import {-# SOURCE #-} qualified GI.GtkSource.Objects.SearchSettings as GtkSource.SearchSettings
import {-# SOURCE #-} qualified GI.GtkSource.Objects.Style as GtkSource.Style

newtype SearchContext = SearchContext (ManagedPtr SearchContext)
foreign import ccall "gtk_source_search_context_get_type"
    c_gtk_source_search_context_get_type :: IO GType

instance GObject SearchContext where
    gobjectType _ = c_gtk_source_search_context_get_type
    

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

toSearchContext :: IsSearchContext o => o -> IO SearchContext
toSearchContext = unsafeCastTo SearchContext

noSearchContext :: Maybe SearchContext
noSearchContext = Nothing

type family ResolveSearchContextMethod (t :: Symbol) (o :: *) :: * where
    ResolveSearchContextMethod "backward" o = SearchContextBackwardMethodInfo
    ResolveSearchContextMethod "backward2" o = SearchContextBackward2MethodInfo
    ResolveSearchContextMethod "backwardAsync" o = SearchContextBackwardAsyncMethodInfo
    ResolveSearchContextMethod "backwardFinish" o = SearchContextBackwardFinishMethodInfo
    ResolveSearchContextMethod "backwardFinish2" o = SearchContextBackwardFinish2MethodInfo
    ResolveSearchContextMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSearchContextMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSearchContextMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSearchContextMethod "forward" o = SearchContextForwardMethodInfo
    ResolveSearchContextMethod "forward2" o = SearchContextForward2MethodInfo
    ResolveSearchContextMethod "forwardAsync" o = SearchContextForwardAsyncMethodInfo
    ResolveSearchContextMethod "forwardFinish" o = SearchContextForwardFinishMethodInfo
    ResolveSearchContextMethod "forwardFinish2" o = SearchContextForwardFinish2MethodInfo
    ResolveSearchContextMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSearchContextMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSearchContextMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSearchContextMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSearchContextMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSearchContextMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSearchContextMethod "replace" o = SearchContextReplaceMethodInfo
    ResolveSearchContextMethod "replace2" o = SearchContextReplace2MethodInfo
    ResolveSearchContextMethod "replaceAll" o = SearchContextReplaceAllMethodInfo
    ResolveSearchContextMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveSearchContextMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveSearchContextMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSearchContextMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSearchContextMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSearchContextMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSearchContextMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSearchContextMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSearchContextMethod "getBuffer" o = SearchContextGetBufferMethodInfo
    ResolveSearchContextMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSearchContextMethod "getHighlight" o = SearchContextGetHighlightMethodInfo
    ResolveSearchContextMethod "getMatchStyle" o = SearchContextGetMatchStyleMethodInfo
    ResolveSearchContextMethod "getOccurrencePosition" o = SearchContextGetOccurrencePositionMethodInfo
    ResolveSearchContextMethod "getOccurrencesCount" o = SearchContextGetOccurrencesCountMethodInfo
    ResolveSearchContextMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSearchContextMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSearchContextMethod "getRegexError" o = SearchContextGetRegexErrorMethodInfo
    ResolveSearchContextMethod "getSettings" o = SearchContextGetSettingsMethodInfo
    ResolveSearchContextMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSearchContextMethod "setHighlight" o = SearchContextSetHighlightMethodInfo
    ResolveSearchContextMethod "setMatchStyle" o = SearchContextSetMatchStyleMethodInfo
    ResolveSearchContextMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSearchContextMethod "setSettings" o = SearchContextSetSettingsMethodInfo
    ResolveSearchContextMethod l o = O.MethodResolutionFailed l o

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

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

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

getSearchContextBuffer :: (MonadIO m, IsSearchContext o) => o -> m GtkSource.Buffer.Buffer
getSearchContextBuffer obj = liftIO $ checkUnexpectedNothing "getSearchContextBuffer" $ getObjectPropertyObject obj "buffer" GtkSource.Buffer.Buffer

constructSearchContextBuffer :: (IsSearchContext o, GtkSource.Buffer.IsBuffer a) => a -> IO (GValueConstruct o)
constructSearchContextBuffer val = constructObjectPropertyObject "buffer" (Just val)

data SearchContextBufferPropertyInfo
instance AttrInfo SearchContextBufferPropertyInfo where
    type AttrAllowedOps SearchContextBufferPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SearchContextBufferPropertyInfo = GtkSource.Buffer.IsBuffer
    type AttrBaseTypeConstraint SearchContextBufferPropertyInfo = IsSearchContext
    type AttrGetType SearchContextBufferPropertyInfo = GtkSource.Buffer.Buffer
    type AttrLabel SearchContextBufferPropertyInfo = "buffer"
    type AttrOrigin SearchContextBufferPropertyInfo = SearchContext
    attrGet _ = getSearchContextBuffer
    attrSet _ = undefined
    attrConstruct _ = constructSearchContextBuffer
    attrClear _ = undefined

-- VVV Prop "highlight"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just False)

getSearchContextHighlight :: (MonadIO m, IsSearchContext o) => o -> m Bool
getSearchContextHighlight obj = liftIO $ getObjectPropertyBool obj "highlight"

setSearchContextHighlight :: (MonadIO m, IsSearchContext o) => o -> Bool -> m ()
setSearchContextHighlight obj val = liftIO $ setObjectPropertyBool obj "highlight" val

constructSearchContextHighlight :: (IsSearchContext o) => Bool -> IO (GValueConstruct o)
constructSearchContextHighlight val = constructObjectPropertyBool "highlight" val

data SearchContextHighlightPropertyInfo
instance AttrInfo SearchContextHighlightPropertyInfo where
    type AttrAllowedOps SearchContextHighlightPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SearchContextHighlightPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint SearchContextHighlightPropertyInfo = IsSearchContext
    type AttrGetType SearchContextHighlightPropertyInfo = Bool
    type AttrLabel SearchContextHighlightPropertyInfo = "highlight"
    type AttrOrigin SearchContextHighlightPropertyInfo = SearchContext
    attrGet _ = getSearchContextHighlight
    attrSet _ = setSearchContextHighlight
    attrConstruct _ = constructSearchContextHighlight
    attrClear _ = undefined

-- VVV Prop "match-style"
   -- Type: TInterface (Name {namespace = "GtkSource", name = "Style"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just True)

getSearchContextMatchStyle :: (MonadIO m, IsSearchContext o) => o -> m GtkSource.Style.Style
getSearchContextMatchStyle obj = liftIO $ checkUnexpectedNothing "getSearchContextMatchStyle" $ getObjectPropertyObject obj "match-style" GtkSource.Style.Style

setSearchContextMatchStyle :: (MonadIO m, IsSearchContext o, GtkSource.Style.IsStyle a) => o -> a -> m ()
setSearchContextMatchStyle obj val = liftIO $ setObjectPropertyObject obj "match-style" (Just val)

constructSearchContextMatchStyle :: (IsSearchContext o, GtkSource.Style.IsStyle a) => a -> IO (GValueConstruct o)
constructSearchContextMatchStyle val = constructObjectPropertyObject "match-style" (Just val)

clearSearchContextMatchStyle :: (MonadIO m, IsSearchContext o) => o -> m ()
clearSearchContextMatchStyle obj = liftIO $ setObjectPropertyObject obj "match-style" (Nothing :: Maybe GtkSource.Style.Style)

data SearchContextMatchStylePropertyInfo
instance AttrInfo SearchContextMatchStylePropertyInfo where
    type AttrAllowedOps SearchContextMatchStylePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SearchContextMatchStylePropertyInfo = GtkSource.Style.IsStyle
    type AttrBaseTypeConstraint SearchContextMatchStylePropertyInfo = IsSearchContext
    type AttrGetType SearchContextMatchStylePropertyInfo = GtkSource.Style.Style
    type AttrLabel SearchContextMatchStylePropertyInfo = "match-style"
    type AttrOrigin SearchContextMatchStylePropertyInfo = SearchContext
    attrGet _ = getSearchContextMatchStyle
    attrSet _ = setSearchContextMatchStyle
    attrConstruct _ = constructSearchContextMatchStyle
    attrClear _ = clearSearchContextMatchStyle

-- VVV Prop "occurrences-count"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getSearchContextOccurrencesCount :: (MonadIO m, IsSearchContext o) => o -> m Int32
getSearchContextOccurrencesCount obj = liftIO $ getObjectPropertyInt32 obj "occurrences-count"

data SearchContextOccurrencesCountPropertyInfo
instance AttrInfo SearchContextOccurrencesCountPropertyInfo where
    type AttrAllowedOps SearchContextOccurrencesCountPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint SearchContextOccurrencesCountPropertyInfo = (~) ()
    type AttrBaseTypeConstraint SearchContextOccurrencesCountPropertyInfo = IsSearchContext
    type AttrGetType SearchContextOccurrencesCountPropertyInfo = Int32
    type AttrLabel SearchContextOccurrencesCountPropertyInfo = "occurrences-count"
    type AttrOrigin SearchContextOccurrencesCountPropertyInfo = SearchContext
    attrGet _ = getSearchContextOccurrencesCount
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "regex-error"
   -- Type: TBasicType TPtr
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

getSearchContextRegexError :: (MonadIO m, IsSearchContext o) => o -> m (Ptr ())
getSearchContextRegexError obj = liftIO $ getObjectPropertyPtr obj "regex-error"

data SearchContextRegexErrorPropertyInfo
instance AttrInfo SearchContextRegexErrorPropertyInfo where
    type AttrAllowedOps SearchContextRegexErrorPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint SearchContextRegexErrorPropertyInfo = (~) ()
    type AttrBaseTypeConstraint SearchContextRegexErrorPropertyInfo = IsSearchContext
    type AttrGetType SearchContextRegexErrorPropertyInfo = (Ptr ())
    type AttrLabel SearchContextRegexErrorPropertyInfo = "regex-error"
    type AttrOrigin SearchContextRegexErrorPropertyInfo = SearchContext
    attrGet _ = getSearchContextRegexError
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "settings"
   -- Type: TInterface (Name {namespace = "GtkSource", name = "SearchSettings"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just True)

getSearchContextSettings :: (MonadIO m, IsSearchContext o) => o -> m GtkSource.SearchSettings.SearchSettings
getSearchContextSettings obj = liftIO $ checkUnexpectedNothing "getSearchContextSettings" $ getObjectPropertyObject obj "settings" GtkSource.SearchSettings.SearchSettings

setSearchContextSettings :: (MonadIO m, IsSearchContext o, GtkSource.SearchSettings.IsSearchSettings a) => o -> a -> m ()
setSearchContextSettings obj val = liftIO $ setObjectPropertyObject obj "settings" (Just val)

constructSearchContextSettings :: (IsSearchContext o, GtkSource.SearchSettings.IsSearchSettings a) => a -> IO (GValueConstruct o)
constructSearchContextSettings val = constructObjectPropertyObject "settings" (Just val)

clearSearchContextSettings :: (MonadIO m, IsSearchContext o) => o -> m ()
clearSearchContextSettings obj = liftIO $ setObjectPropertyObject obj "settings" (Nothing :: Maybe GtkSource.SearchSettings.SearchSettings)

data SearchContextSettingsPropertyInfo
instance AttrInfo SearchContextSettingsPropertyInfo where
    type AttrAllowedOps SearchContextSettingsPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SearchContextSettingsPropertyInfo = GtkSource.SearchSettings.IsSearchSettings
    type AttrBaseTypeConstraint SearchContextSettingsPropertyInfo = IsSearchContext
    type AttrGetType SearchContextSettingsPropertyInfo = GtkSource.SearchSettings.SearchSettings
    type AttrLabel SearchContextSettingsPropertyInfo = "settings"
    type AttrOrigin SearchContextSettingsPropertyInfo = SearchContext
    attrGet _ = getSearchContextSettings
    attrSet _ = setSearchContextSettings
    attrConstruct _ = constructSearchContextSettings
    attrClear _ = clearSearchContextSettings

instance O.HasAttributeList SearchContext
type instance O.AttributeList SearchContext = SearchContextAttributeList
type SearchContextAttributeList = ('[ '("buffer", SearchContextBufferPropertyInfo), '("highlight", SearchContextHighlightPropertyInfo), '("matchStyle", SearchContextMatchStylePropertyInfo), '("occurrencesCount", SearchContextOccurrencesCountPropertyInfo), '("regexError", SearchContextRegexErrorPropertyInfo), '("settings", SearchContextSettingsPropertyInfo)] :: [(Symbol, *)])

searchContextBuffer :: AttrLabelProxy "buffer"
searchContextBuffer = AttrLabelProxy

searchContextHighlight :: AttrLabelProxy "highlight"
searchContextHighlight = AttrLabelProxy

searchContextMatchStyle :: AttrLabelProxy "matchStyle"
searchContextMatchStyle = AttrLabelProxy

searchContextOccurrencesCount :: AttrLabelProxy "occurrencesCount"
searchContextOccurrencesCount = AttrLabelProxy

searchContextRegexError :: AttrLabelProxy "regexError"
searchContextRegexError = AttrLabelProxy

searchContextSettings :: AttrLabelProxy "settings"
searchContextSettings = AttrLabelProxy

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

-- method SearchContext::new
-- method type : Constructor
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "GtkSource", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceBuffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "settings", argType = TInterface (Name {namespace = "GtkSource", name = "SearchSettings"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchSettings, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "SearchContext"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_search_context_new" gtk_source_search_context_new :: 
    Ptr GtkSource.Buffer.Buffer ->          -- buffer : TInterface (Name {namespace = "GtkSource", name = "Buffer"})
    Ptr GtkSource.SearchSettings.SearchSettings -> -- settings : TInterface (Name {namespace = "GtkSource", name = "SearchSettings"})
    IO (Ptr SearchContext)

{- |
Creates a new search context, associated with /@buffer@/, and customized with
/@settings@/. If /@settings@/ is 'Nothing', a new 'GI.GtkSource.Objects.SearchSettings.SearchSettings' object will
be created, that you can retrieve with
'GI.GtkSource.Objects.SearchContext.searchContextGetSettings'.

@since 3.10
-}
searchContextNew ::
    (B.CallStack.HasCallStack, MonadIO m, GtkSource.Buffer.IsBuffer a, GtkSource.SearchSettings.IsSearchSettings b) =>
    a
    {- ^ /@buffer@/: a 'GI.GtkSource.Objects.Buffer.Buffer'. -}
    -> Maybe (b)
    {- ^ /@settings@/: a 'GI.GtkSource.Objects.SearchSettings.SearchSettings', or 'Nothing'. -}
    -> m SearchContext
    {- ^ __Returns:__ a new search context. -}
searchContextNew buffer settings = liftIO $ do
    buffer' <- unsafeManagedPtrCastPtr buffer
    maybeSettings <- case settings of
        Nothing -> return nullPtr
        Just jSettings -> do
            jSettings' <- unsafeManagedPtrCastPtr jSettings
            return jSettings'
    result <- gtk_source_search_context_new buffer' maybeSettings
    checkUnexpectedReturnNULL "searchContextNew" result
    result' <- (wrapObject SearchContext) result
    touchManagedPtr buffer
    whenJust settings touchManagedPtr
    return result'

-- method SearchContext::backward
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start of search.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, 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_search_context_backward" gtk_source_search_context_backward :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- iter : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO CInt

{-# DEPRECATED searchContextBackward ["(Since version 3.22)","Use 'GI.GtkSource.Objects.SearchContext.searchContextBackward2' instead."] #-}
{- |
Synchronous backward search. It is recommended to use the asynchronous
functions instead, to not block the user interface. However, if you are sure
that the /@buffer@/ is small, this function is more convenient to use.

@since 3.10
-}
searchContextBackward ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@iter@/: start of search. -}
    -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)
    {- ^ __Returns:__ whether a match was found. -}
searchContextBackward search iter = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    iter' <- unsafeManagedPtrGetPtr iter
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    result <- gtk_source_search_context_backward search' iter' matchStart matchEnd
    let result' = (/= 0) result
    matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
    matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
    touchManagedPtr search
    touchManagedPtr iter
    return (result', matchStart', matchEnd')

data SearchContextBackwardMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextBackwardMethodInfo a signature where
    overloadedMethod _ = searchContextBackward

-- method SearchContext::backward2
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start of search.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "has_wrapped_around", argType = TBasicType TBoolean, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location to know whether the\n  search has wrapped around, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_search_context_backward2" gtk_source_search_context_backward2 :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- iter : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr CInt ->                             -- has_wrapped_around : TBasicType TBoolean
    IO CInt

{- |
Synchronous backward search. It is recommended to use the asynchronous
functions instead, to not block the user interface. However, if you are sure
that the /@buffer@/ is small, this function is more convenient to use.

The difference with 'GI.GtkSource.Objects.SearchContext.searchContextBackward' is that the
/@hasWrappedAround@/ out parameter has been added for convenience.

If the 'GI.GtkSource.Objects.SearchSettings.SearchSettings':@/wrap-around/@ property is 'False', this function
doesn\'t try to wrap around.

The /@hasWrappedAround@/ out parameter is set independently of whether a match
is found. So if this function returns 'False', /@hasWrappedAround@/ will have
the same value as the 'GI.GtkSource.Objects.SearchSettings.SearchSettings':@/wrap-around/@ property.

@since 3.22
-}
searchContextBackward2 ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@iter@/: start of search. -}
    -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)
    {- ^ __Returns:__ whether a match was found. -}
searchContextBackward2 search iter = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    iter' <- unsafeManagedPtrGetPtr iter
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    hasWrappedAround <- allocMem :: IO (Ptr CInt)
    result <- gtk_source_search_context_backward2 search' iter' matchStart matchEnd hasWrappedAround
    let result' = (/= 0) result
    matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
    matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
    hasWrappedAround' <- peek hasWrappedAround
    let hasWrappedAround'' = (/= 0) hasWrappedAround'
    touchManagedPtr search
    touchManagedPtr iter
    freeMem hasWrappedAround
    return (result', matchStart', matchEnd', hasWrappedAround'')

data SearchContextBackward2MethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextBackward2MethodInfo a signature where
    overloadedMethod _ = searchContextBackward2

-- method SearchContext::backward_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start of search.", 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},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the operation is finished.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to the @callback function.", 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_search_context_backward_async" gtk_source_search_context_backward_async :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- iter : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
The asynchronous version of 'GI.GtkSource.Objects.SearchContext.searchContextBackward2'.

See the documentation of 'GI.GtkSource.Objects.SearchContext.searchContextBackward2' for more
details.

See the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' documentation to know how to use this function.

If the operation is cancelled, the /@callback@/ will only be called if
/@cancellable@/ was not 'Nothing'. 'GI.GtkSource.Objects.SearchContext.searchContextBackwardAsync' takes
ownership of /@cancellable@/, so you can unref it after calling this function.

@since 3.10
-}
searchContextBackwardAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@iter@/: start of search. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing'. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the operation is finished. -}
    -> m ()
searchContextBackwardAsync search iter cancellable callback = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    iter' <- unsafeManagedPtrGetPtr iter
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    gtk_source_search_context_backward_async search' iter' maybeCancellable maybeCallback userData
    touchManagedPtr search
    touchManagedPtr iter
    whenJust cancellable touchManagedPtr
    return ()

data SearchContextBackwardAsyncMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSearchContext a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SearchContextBackwardAsyncMethodInfo a signature where
    overloadedMethod _ = searchContextBackwardAsync

-- method SearchContext::backward_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", 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 = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "gtk_source_search_context_backward_finish" gtk_source_search_context_backward_finish :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED searchContextBackwardFinish ["(Since version 3.22)","Use 'GI.GtkSource.Objects.SearchContext.searchContextBackwardFinish2' instead."] #-}
{- |
Finishes a backward search started with
'GI.GtkSource.Objects.SearchContext.searchContextBackwardAsync'.

@since 3.10
-}
searchContextBackwardFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextBackwardFinish search result_ = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result_' <- unsafeManagedPtrCastPtr result_
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    onException (do
        _ <- propagateGError $ gtk_source_search_context_backward_finish search' result_' matchStart matchEnd
        matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
        matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
        touchManagedPtr search
        touchManagedPtr result_
        return (matchStart', matchEnd')
     ) (do
        freeMem matchStart
        freeMem matchEnd
     )

data SearchContextBackwardFinishMethodInfo
instance (signature ~ (b -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)), MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SearchContextBackwardFinishMethodInfo a signature where
    overloadedMethod _ = searchContextBackwardFinish

-- method SearchContext::backward_finish2
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", 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 = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "has_wrapped_around", argType = TBasicType TBoolean, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location to know whether the\n  search has wrapped around, 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 "gtk_source_search_context_backward_finish2" gtk_source_search_context_backward_finish2 :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr CInt ->                             -- has_wrapped_around : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes a backward search started with
'GI.GtkSource.Objects.SearchContext.searchContextBackwardAsync'.

See the documentation of 'GI.GtkSource.Objects.SearchContext.searchContextBackward2' for more
details.

@since 3.22
-}
searchContextBackwardFinish2 ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextBackwardFinish2 search result_ = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result_' <- unsafeManagedPtrCastPtr result_
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    hasWrappedAround <- allocMem :: IO (Ptr CInt)
    onException (do
        _ <- propagateGError $ gtk_source_search_context_backward_finish2 search' result_' matchStart matchEnd hasWrappedAround
        matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
        matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
        hasWrappedAround' <- peek hasWrappedAround
        let hasWrappedAround'' = (/= 0) hasWrappedAround'
        touchManagedPtr search
        touchManagedPtr result_
        freeMem hasWrappedAround
        return (matchStart', matchEnd', hasWrappedAround'')
     ) (do
        freeMem matchStart
        freeMem matchEnd
        freeMem hasWrappedAround
     )

data SearchContextBackwardFinish2MethodInfo
instance (signature ~ (b -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)), MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SearchContextBackwardFinish2MethodInfo a signature where
    overloadedMethod _ = searchContextBackwardFinish2

-- method SearchContext::forward
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start of search.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, 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_search_context_forward" gtk_source_search_context_forward :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- iter : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO CInt

{-# DEPRECATED searchContextForward ["(Since version 3.22)","Use 'GI.GtkSource.Objects.SearchContext.searchContextForward2' instead."] #-}
{- |
Synchronous forward search. It is recommended to use the asynchronous
functions instead, to not block the user interface. However, if you are sure
that the /@buffer@/ is small, this function is more convenient to use.

@since 3.10
-}
searchContextForward ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@iter@/: start of search. -}
    -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)
    {- ^ __Returns:__ whether a match was found. -}
searchContextForward search iter = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    iter' <- unsafeManagedPtrGetPtr iter
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    result <- gtk_source_search_context_forward search' iter' matchStart matchEnd
    let result' = (/= 0) result
    matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
    matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
    touchManagedPtr search
    touchManagedPtr iter
    return (result', matchStart', matchEnd')

data SearchContextForwardMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextForwardMethodInfo a signature where
    overloadedMethod _ = searchContextForward

-- method SearchContext::forward2
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start of search.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "has_wrapped_around", argType = TBasicType TBoolean, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location to know whether the\n  search has wrapped around, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_search_context_forward2" gtk_source_search_context_forward2 :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- iter : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr CInt ->                             -- has_wrapped_around : TBasicType TBoolean
    IO CInt

{- |
Synchronous forward search. It is recommended to use the asynchronous
functions instead, to not block the user interface. However, if you are sure
that the /@buffer@/ is small, this function is more convenient to use.

The difference with 'GI.GtkSource.Objects.SearchContext.searchContextForward' is that the
/@hasWrappedAround@/ out parameter has been added for convenience.

If the 'GI.GtkSource.Objects.SearchSettings.SearchSettings':@/wrap-around/@ property is 'False', this function
doesn\'t try to wrap around.

The /@hasWrappedAround@/ out parameter is set independently of whether a match
is found. So if this function returns 'False', /@hasWrappedAround@/ will have
the same value as the 'GI.GtkSource.Objects.SearchSettings.SearchSettings':@/wrap-around/@ property.

@since 3.22
-}
searchContextForward2 ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@iter@/: start of search. -}
    -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)
    {- ^ __Returns:__ whether a match was found. -}
searchContextForward2 search iter = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    iter' <- unsafeManagedPtrGetPtr iter
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    hasWrappedAround <- allocMem :: IO (Ptr CInt)
    result <- gtk_source_search_context_forward2 search' iter' matchStart matchEnd hasWrappedAround
    let result' = (/= 0) result
    matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
    matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
    hasWrappedAround' <- peek hasWrappedAround
    let hasWrappedAround'' = (/= 0) hasWrappedAround'
    touchManagedPtr search
    touchManagedPtr iter
    freeMem hasWrappedAround
    return (result', matchStart', matchEnd', hasWrappedAround'')

data SearchContextForward2MethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> m (Bool,Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextForward2MethodInfo a signature where
    overloadedMethod _ = searchContextForward2

-- method SearchContext::forward_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iter", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start of search.", 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},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the operation is finished.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to the @callback function.", 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_search_context_forward_async" gtk_source_search_context_forward_async :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- iter : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
The asynchronous version of 'GI.GtkSource.Objects.SearchContext.searchContextForward2'.

See the documentation of 'GI.GtkSource.Objects.SearchContext.searchContextForward2' for more
details.

See the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' documentation to know how to use this function.

If the operation is cancelled, the /@callback@/ will only be called if
/@cancellable@/ was not 'Nothing'. 'GI.GtkSource.Objects.SearchContext.searchContextForwardAsync' takes
ownership of /@cancellable@/, so you can unref it after calling this function.

@since 3.10
-}
searchContextForwardAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@iter@/: start of search. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing'. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the operation is finished. -}
    -> m ()
searchContextForwardAsync search iter cancellable callback = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    iter' <- unsafeManagedPtrGetPtr iter
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    gtk_source_search_context_forward_async search' iter' maybeCancellable maybeCallback userData
    touchManagedPtr search
    touchManagedPtr iter
    whenJust cancellable touchManagedPtr
    return ()

data SearchContextForwardAsyncMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSearchContext a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SearchContextForwardAsyncMethodInfo a signature where
    overloadedMethod _ = searchContextForwardAsync

-- method SearchContext::forward_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", 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 = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "gtk_source_search_context_forward_finish" gtk_source_search_context_forward_finish :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED searchContextForwardFinish ["(Since version 3.22)","Use 'GI.GtkSource.Objects.SearchContext.searchContextForwardFinish2' instead."] #-}
{- |
Finishes a forward search started with
'GI.GtkSource.Objects.SearchContext.searchContextForwardAsync'.

@since 3.10
-}
searchContextForwardFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextForwardFinish search result_ = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result_' <- unsafeManagedPtrCastPtr result_
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    onException (do
        _ <- propagateGError $ gtk_source_search_context_forward_finish search' result_' matchStart matchEnd
        matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
        matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
        touchManagedPtr search
        touchManagedPtr result_
        return (matchStart', matchEnd')
     ) (do
        freeMem matchStart
        freeMem matchEnd
     )

data SearchContextForwardFinishMethodInfo
instance (signature ~ (b -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter)), MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SearchContextForwardFinishMethodInfo a signature where
    overloadedMethod _ = searchContextForwardFinish

-- method SearchContext::forward_finish2
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", 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 = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for start of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of match, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing},Arg {argCName = "has_wrapped_around", argType = TBasicType TBoolean, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location to know whether the\n  search has wrapped around, 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 "gtk_source_search_context_forward_finish2" gtk_source_search_context_forward_finish2 :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr CInt ->                             -- has_wrapped_around : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes a forward search started with
'GI.GtkSource.Objects.SearchContext.searchContextForwardAsync'.

See the documentation of 'GI.GtkSource.Objects.SearchContext.searchContextForward2' for more
details.

@since 3.22
-}
searchContextForwardFinish2 ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextForwardFinish2 search result_ = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result_' <- unsafeManagedPtrCastPtr result_
    matchStart <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    matchEnd <- callocBoxedBytes 80 :: IO (Ptr Gtk.TextIter.TextIter)
    hasWrappedAround <- allocMem :: IO (Ptr CInt)
    onException (do
        _ <- propagateGError $ gtk_source_search_context_forward_finish2 search' result_' matchStart matchEnd hasWrappedAround
        matchStart' <- (wrapBoxed Gtk.TextIter.TextIter) matchStart
        matchEnd' <- (wrapBoxed Gtk.TextIter.TextIter) matchEnd
        hasWrappedAround' <- peek hasWrappedAround
        let hasWrappedAround'' = (/= 0) hasWrappedAround'
        touchManagedPtr search
        touchManagedPtr result_
        freeMem hasWrappedAround
        return (matchStart', matchEnd', hasWrappedAround'')
     ) (do
        freeMem matchStart
        freeMem matchEnd
        freeMem hasWrappedAround
     )

data SearchContextForwardFinish2MethodInfo
instance (signature ~ (b -> m (Gtk.TextIter.TextIter,Gtk.TextIter.TextIter,Bool)), MonadIO m, IsSearchContext a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SearchContextForwardFinish2MethodInfo a signature where
    overloadedMethod _ = searchContextForwardFinish2

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

foreign import ccall "gtk_source_search_context_get_buffer" gtk_source_search_context_get_buffer :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    IO (Ptr GtkSource.Buffer.Buffer)

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

@since 3.10
-}
searchContextGetBuffer ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> m GtkSource.Buffer.Buffer
    {- ^ __Returns:__ the associated buffer. -}
searchContextGetBuffer search = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result <- gtk_source_search_context_get_buffer search'
    checkUnexpectedReturnNULL "searchContextGetBuffer" result
    result' <- (newObject GtkSource.Buffer.Buffer) result
    touchManagedPtr search
    return result'

data SearchContextGetBufferMethodInfo
instance (signature ~ (m GtkSource.Buffer.Buffer), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetBufferMethodInfo a signature where
    overloadedMethod _ = searchContextGetBuffer

-- method SearchContext::get_highlight
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", 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_search_context_get_highlight" gtk_source_search_context_get_highlight :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    IO CInt

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

@since 3.10
-}
searchContextGetHighlight ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> m Bool
    {- ^ __Returns:__ whether to highlight the search occurrences. -}
searchContextGetHighlight search = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result <- gtk_source_search_context_get_highlight search'
    let result' = (/= 0) result
    touchManagedPtr search
    return result'

data SearchContextGetHighlightMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetHighlightMethodInfo a signature where
    overloadedMethod _ = searchContextGetHighlight

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

foreign import ccall "gtk_source_search_context_get_match_style" gtk_source_search_context_get_match_style :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    IO (Ptr GtkSource.Style.Style)

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

@since 3.16
-}
searchContextGetMatchStyle ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> m GtkSource.Style.Style
    {- ^ __Returns:__ the 'GI.GtkSource.Objects.Style.Style' to apply on search matches. -}
searchContextGetMatchStyle search = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result <- gtk_source_search_context_get_match_style search'
    checkUnexpectedReturnNULL "searchContextGetMatchStyle" result
    result' <- (newObject GtkSource.Style.Style) result
    touchManagedPtr search
    return result'

data SearchContextGetMatchStyleMethodInfo
instance (signature ~ (m GtkSource.Style.Style), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetMatchStyleMethodInfo a signature where
    overloadedMethod _ = searchContextGetMatchStyle

-- method SearchContext::get_occurrence_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the occurrence.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the occurrence.", 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 "gtk_source_search_context_get_occurrence_position" gtk_source_search_context_get_occurrence_position :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    IO Int32

{- |
Gets the position of a search occurrence. If the buffer is not already fully
scanned, the position may be unknown, and -1 is returned. If 0 is returned,
it means that this part of the buffer has already been scanned, and that
/@matchStart@/ and /@matchEnd@/ don\'t delimit an occurrence.

@since 3.10
-}
searchContextGetOccurrencePosition ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@matchStart@/: the start of the occurrence. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@matchEnd@/: the end of the occurrence. -}
    -> m Int32
    {- ^ __Returns:__ the position of the search occurrence. The first occurrence has the
position 1 (not 0). Returns 0 if /@matchStart@/ and /@matchEnd@/ don\'t delimit
an occurrence. Returns -1 if the position is not yet known. -}
searchContextGetOccurrencePosition search matchStart matchEnd = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    matchStart' <- unsafeManagedPtrGetPtr matchStart
    matchEnd' <- unsafeManagedPtrGetPtr matchEnd
    result <- gtk_source_search_context_get_occurrence_position search' matchStart' matchEnd'
    touchManagedPtr search
    touchManagedPtr matchStart
    touchManagedPtr matchEnd
    return result

data SearchContextGetOccurrencePositionMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Gtk.TextIter.TextIter -> m Int32), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetOccurrencePositionMethodInfo a signature where
    overloadedMethod _ = searchContextGetOccurrencePosition

-- method SearchContext::get_occurrences_count
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", 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 "gtk_source_search_context_get_occurrences_count" gtk_source_search_context_get_occurrences_count :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    IO Int32

{- |
Gets the total number of search occurrences. If the buffer is not already
fully scanned, the total number of occurrences is unknown, and -1 is
returned.

@since 3.10
-}
searchContextGetOccurrencesCount ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> m Int32
    {- ^ __Returns:__ the total number of search occurrences, or -1 if unknown. -}
searchContextGetOccurrencesCount search = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result <- gtk_source_search_context_get_occurrences_count search'
    touchManagedPtr search
    return result

data SearchContextGetOccurrencesCountMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetOccurrencesCountMethodInfo a signature where
    overloadedMethod _ = searchContextGetOccurrencesCount

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

foreign import ccall "gtk_source_search_context_get_regex_error" gtk_source_search_context_get_regex_error :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    IO (Ptr GError)

{- |
Regular expression patterns must follow certain rules. If
'GI.GtkSource.Objects.SearchSettings.SearchSettings':@/search-text/@ breaks a rule, the error can be retrieved
with this function. The error domain is @/G_REGEX_ERROR/@.

Free the return value with 'GI.GLib.Structs.Error.errorFree'.

@since 3.10
-}
searchContextGetRegexError ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> m (Maybe GError)
    {- ^ __Returns:__ the 'GError', or 'Nothing' if the pattern is valid. -}
searchContextGetRegexError search = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result <- gtk_source_search_context_get_regex_error search'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed GError) result'
        return result''
    touchManagedPtr search
    return maybeResult

data SearchContextGetRegexErrorMethodInfo
instance (signature ~ (m (Maybe GError)), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetRegexErrorMethodInfo a signature where
    overloadedMethod _ = searchContextGetRegexError

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

foreign import ccall "gtk_source_search_context_get_settings" gtk_source_search_context_get_settings :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    IO (Ptr GtkSource.SearchSettings.SearchSettings)

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

@since 3.10
-}
searchContextGetSettings ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> m GtkSource.SearchSettings.SearchSettings
    {- ^ __Returns:__ the search settings. -}
searchContextGetSettings search = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    result <- gtk_source_search_context_get_settings search'
    checkUnexpectedReturnNULL "searchContextGetSettings" result
    result' <- (newObject GtkSource.SearchSettings.SearchSettings) result
    touchManagedPtr search
    return result'

data SearchContextGetSettingsMethodInfo
instance (signature ~ (m GtkSource.SearchSettings.SearchSettings), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextGetSettingsMethodInfo a signature where
    overloadedMethod _ = searchContextGetSettings

-- method SearchContext::replace
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the match to replace.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the match to replace.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "replace", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the replacement text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "replace_length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @replace in bytes, or -1.", 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 "gtk_source_search_context_replace" gtk_source_search_context_replace :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    CString ->                              -- replace : TBasicType TUTF8
    Int32 ->                                -- replace_length : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED searchContextReplace ["(Since version 3.22)","Use 'GI.GtkSource.Objects.SearchContext.searchContextReplace2' instead."] #-}
{- |
Replaces a search match by another text. If /@matchStart@/ and /@matchEnd@/
doesn\'t correspond to a search match, 'False' is returned.

For a regular expression replacement, you can check if /@replace@/ is valid by
calling 'GI.GLib.Functions.regexCheckReplacement'. The /@replace@/ text can contain
backreferences; read the 'GI.GLib.Structs.Regex.regexReplace' documentation for more details.

@since 3.10
-}
searchContextReplace ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@matchStart@/: the start of the match to replace. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@matchEnd@/: the end of the match to replace. -}
    -> T.Text
    {- ^ /@replace@/: the replacement text. -}
    -> Int32
    {- ^ /@replaceLength@/: the length of /@replace@/ in bytes, or -1. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextReplace search matchStart matchEnd replace replaceLength = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    matchStart' <- unsafeManagedPtrGetPtr matchStart
    matchEnd' <- unsafeManagedPtrGetPtr matchEnd
    replace' <- textToCString replace
    onException (do
        _ <- propagateGError $ gtk_source_search_context_replace search' matchStart' matchEnd' replace' replaceLength
        touchManagedPtr search
        touchManagedPtr matchStart
        touchManagedPtr matchEnd
        freeMem replace'
        return ()
     ) (do
        freeMem replace'
     )

data SearchContextReplaceMethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Gtk.TextIter.TextIter -> T.Text -> Int32 -> m ()), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextReplaceMethodInfo a signature where
    overloadedMethod _ = searchContextReplace

-- method SearchContext::replace2
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_start", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the match to replace.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_end", argType = TInterface (Name {namespace = "Gtk", name = "TextIter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the match to replace.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "replace", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the replacement text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "replace_length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @replace in bytes, or -1.", 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 "gtk_source_search_context_replace2" gtk_source_search_context_replace2 :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr Gtk.TextIter.TextIter ->            -- match_start : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    Ptr Gtk.TextIter.TextIter ->            -- match_end : TInterface (Name {namespace = "Gtk", name = "TextIter"})
    CString ->                              -- replace : TBasicType TUTF8
    Int32 ->                                -- replace_length : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Replaces a search match by another text. If /@matchStart@/ and /@matchEnd@/
doesn\'t correspond to a search match, 'False' is returned.

Unlike with 'GI.GtkSource.Objects.SearchContext.searchContextReplace', the /@matchStart@/ and
/@matchEnd@/ iters are revalidated to point to the replacement text boundaries.

For a regular expression replacement, you can check if /@replace@/ is valid by
calling 'GI.GLib.Functions.regexCheckReplacement'. The /@replace@/ text can contain
backreferences; read the 'GI.GLib.Structs.Regex.regexReplace' documentation for more details.

@since 3.22
-}
searchContextReplace2 ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@matchStart@/: the start of the match to replace. -}
    -> Gtk.TextIter.TextIter
    {- ^ /@matchEnd@/: the end of the match to replace. -}
    -> T.Text
    {- ^ /@replace@/: the replacement text. -}
    -> Int32
    {- ^ /@replaceLength@/: the length of /@replace@/ in bytes, or -1. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextReplace2 search matchStart matchEnd replace replaceLength = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    matchStart' <- unsafeManagedPtrGetPtr matchStart
    matchEnd' <- unsafeManagedPtrGetPtr matchEnd
    replace' <- textToCString replace
    onException (do
        _ <- propagateGError $ gtk_source_search_context_replace2 search' matchStart' matchEnd' replace' replaceLength
        touchManagedPtr search
        touchManagedPtr matchStart
        touchManagedPtr matchEnd
        freeMem replace'
        return ()
     ) (do
        freeMem replace'
     )

data SearchContextReplace2MethodInfo
instance (signature ~ (Gtk.TextIter.TextIter -> Gtk.TextIter.TextIter -> T.Text -> Int32 -> m ()), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextReplace2MethodInfo a signature where
    overloadedMethod _ = searchContextReplace2

-- method SearchContext::replace_all
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "replace", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the replacement text.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "replace_length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @replace in bytes, or -1.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : True
-- Skip return : False

foreign import ccall "gtk_source_search_context_replace_all" gtk_source_search_context_replace_all :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    CString ->                              -- replace : TBasicType TUTF8
    Int32 ->                                -- replace_length : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO Word32

{- |
Replaces all search matches by another text. It is a synchronous function, so
it can block the user interface.

For a regular expression replacement, you can check if /@replace@/ is valid by
calling 'GI.GLib.Functions.regexCheckReplacement'. The /@replace@/ text can contain
backreferences; read the 'GI.GLib.Structs.Regex.regexReplace' documentation for more details.

@since 3.10
-}
searchContextReplaceAll ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> T.Text
    {- ^ /@replace@/: the replacement text. -}
    -> Int32
    {- ^ /@replaceLength@/: the length of /@replace@/ in bytes, or -1. -}
    -> m Word32
    {- ^ __Returns:__ the number of replaced matches. /(Can throw 'Data.GI.Base.GError.GError')/ -}
searchContextReplaceAll search replace replaceLength = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    replace' <- textToCString replace
    onException (do
        result <- propagateGError $ gtk_source_search_context_replace_all search' replace' replaceLength
        touchManagedPtr search
        freeMem replace'
        return result
     ) (do
        freeMem replace'
     )

data SearchContextReplaceAllMethodInfo
instance (signature ~ (T.Text -> Int32 -> m Word32), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextReplaceAllMethodInfo a signature where
    overloadedMethod _ = searchContextReplaceAll

-- method SearchContext::set_highlight
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "highlight", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the setting.", 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_search_context_set_highlight" gtk_source_search_context_set_highlight :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    CInt ->                                 -- highlight : TBasicType TBoolean
    IO ()

{- |
Enables or disables the search occurrences highlighting.

@since 3.10
-}
searchContextSetHighlight ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Bool
    {- ^ /@highlight@/: the setting. -}
    -> m ()
searchContextSetHighlight search highlight = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    let highlight' = (fromIntegral . fromEnum) highlight
    gtk_source_search_context_set_highlight search' highlight'
    touchManagedPtr search
    return ()

data SearchContextSetHighlightMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsSearchContext a) => O.MethodInfo SearchContextSetHighlightMethodInfo a signature where
    overloadedMethod _ = searchContextSetHighlight

-- method SearchContext::set_match_style
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "match_style", argType = TInterface (Name {namespace = "GtkSource", name = "Style"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GtkSourceStyle, 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_search_context_set_match_style" gtk_source_search_context_set_match_style :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr GtkSource.Style.Style ->            -- match_style : TInterface (Name {namespace = "GtkSource", name = "Style"})
    IO ()

{- |
Set the style to apply on search matches. If /@matchStyle@/ is 'Nothing', default
theme\'s scheme \'match-style\' will be used.
To enable or disable the search highlighting, use
'GI.GtkSource.Objects.SearchContext.searchContextSetHighlight'.

@since 3.16
-}
searchContextSetMatchStyle ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, GtkSource.Style.IsStyle b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Maybe (b)
    {- ^ /@matchStyle@/: a 'GI.GtkSource.Objects.Style.Style', or 'Nothing'. -}
    -> m ()
searchContextSetMatchStyle search matchStyle = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    maybeMatchStyle <- case matchStyle of
        Nothing -> return nullPtr
        Just jMatchStyle -> do
            jMatchStyle' <- unsafeManagedPtrCastPtr jMatchStyle
            return jMatchStyle'
    gtk_source_search_context_set_match_style search' maybeMatchStyle
    touchManagedPtr search
    whenJust matchStyle touchManagedPtr
    return ()

data SearchContextSetMatchStyleMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSearchContext a, GtkSource.Style.IsStyle b) => O.MethodInfo SearchContextSetMatchStyleMethodInfo a signature where
    overloadedMethod _ = searchContextSetMatchStyle

-- method SearchContext::set_settings
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "search", argType = TInterface (Name {namespace = "GtkSource", name = "SearchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkSourceSearchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "settings", argType = TInterface (Name {namespace = "GtkSource", name = "SearchSettings"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the new #GtkSourceSearchSettings, 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_search_context_set_settings" gtk_source_search_context_set_settings :: 
    Ptr SearchContext ->                    -- search : TInterface (Name {namespace = "GtkSource", name = "SearchContext"})
    Ptr GtkSource.SearchSettings.SearchSettings -> -- settings : TInterface (Name {namespace = "GtkSource", name = "SearchSettings"})
    IO ()

{- |
Associate a 'GI.GtkSource.Objects.SearchSettings.SearchSettings' with the search context. If /@settings@/ is
'Nothing', a new one will be created.

The search context holds a reference to /@settings@/.

@since 3.10
-}
searchContextSetSettings ::
    (B.CallStack.HasCallStack, MonadIO m, IsSearchContext a, GtkSource.SearchSettings.IsSearchSettings b) =>
    a
    {- ^ /@search@/: a 'GI.GtkSource.Objects.SearchContext.SearchContext'. -}
    -> Maybe (b)
    {- ^ /@settings@/: the new 'GI.GtkSource.Objects.SearchSettings.SearchSettings', or 'Nothing'. -}
    -> m ()
searchContextSetSettings search settings = liftIO $ do
    search' <- unsafeManagedPtrCastPtr search
    maybeSettings <- case settings of
        Nothing -> return nullPtr
        Just jSettings -> do
            jSettings' <- unsafeManagedPtrCastPtr jSettings
            return jSettings'
    gtk_source_search_context_set_settings search' maybeSettings
    touchManagedPtr search
    whenJust settings touchManagedPtr
    return ()

data SearchContextSetSettingsMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSearchContext a, GtkSource.SearchSettings.IsSearchSettings b) => O.MethodInfo SearchContextSetSettingsMethodInfo a signature where
    overloadedMethod _ = searchContextSetSettings