    {-# OPTIONS_HADDOCK show-extensions #-}

    -- |
    -- Module      :  Yi.Search.Internal
    -- License     :  GPL-2
    -- Maintainer  :  yi-devel@googlegroups.com
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- Internal use for Yi.Search.

    module Yi.Search.Internal where

    import           Lens.Micro.Platform   ((.=), use)
    import           Yi.Editor    (EditorM, currentRegexA)
    import           Yi.Regex     (SearchExp)

    -- ---------------------------------------------------------------------
    -- Searching and substitutions with regular expressions
    --
    -- The most recent regex is held by the editor. You can get at it with
    -- getRegeE. This is useful to determine if there was a previous
    -- pattern.
    --

    -- | Put regex into regex 'register'
    setRegexE :: SearchExp -> EditorM ()
    setRegexE :: SearchExp -> EditorM ()
    setRegexE SearchExp
    re = (Maybe SearchExp -> Identity (Maybe SearchExp))
    -> Editor -> Identity Editor
    Lens' Editor (Maybe SearchExp)
    currentRegexA ((Maybe SearchExp -> Identity (Maybe SearchExp))
     -> Editor -> Identity Editor)
    -> Maybe SearchExp -> EditorM ()
    forall s (m :: * -> *) a b.
    MonadState s m =>
    ASetter s s a b -> b -> m ()
    .= (SearchExp -> Maybe SearchExp
    forall a. a -> Maybe a
    Just SearchExp
    re)

    -- | Clear the regex 'register'
    resetRegexE :: EditorM ()
    resetRegexE :: EditorM ()
    resetRegexE = (Maybe SearchExp -> Identity (Maybe SearchExp))
    -> Editor -> Identity Editor
    Lens' Editor (Maybe SearchExp)
    currentRegexA ((Maybe SearchExp -> Identity (Maybe SearchExp))
     -> Editor -> Identity Editor)
    -> Maybe SearchExp -> EditorM ()
    forall s (m :: * -> *) a b.
    MonadState s m =>
    ASetter s s a b -> b -> m ()
    .= Maybe SearchExp
    forall a. Maybe a
    Nothing

    -- | Return contents of regex register
    getRegexE :: EditorM (Maybe SearchExp)
    getRegexE :: EditorM (Maybe SearchExp)
    getRegexE = Getting (Maybe SearchExp) Editor (Maybe SearchExp)
    -> EditorM (Maybe SearchExp)
    forall s (m :: * -> *) a. MonadState s m => Getting a s a -> m a
    use Getting (Maybe SearchExp) Editor (Maybe SearchExp)
    Lens' Editor (Maybe SearchExp)
    currentRegexA