yi-core-0.19.4: Yi editor core library

License | GPL-2
Maintainer | yi-devel@googlegroups.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Extensions

- OverloadedStrings
- DeriveDataTypeable
- GeneralizedNewtypeDeriving
- LambdaCase

Yi.Search

Contents

- Batch search-replace
- Incremental Search
- Replace

Description

Search/Replace functions

Synopsis

- setRegexE :: SearchExp -> EditorM ()
- resetRegexE :: EditorM ()
- getRegexE :: EditorM (Maybe SearchExp)
- type SearchMatch = Region
- data SearchResult
  - = PatternFound
  - | PatternNotFound
  - | SearchWrapped
- data SearchOption
  - = IgnoreCase
  - | NoNewLine
  - | QuoteRegex
- doSearch :: Maybe String -> [SearchOption] -> Direction -> EditorM SearchResult
- searchInit :: String -> Direction -> [SearchOption] -> EditorM (SearchExp, Direction)
- continueSearch :: (SearchExp, Direction) -> BufferM SearchResult
- makeSimpleSearch :: YiString -> SearchExp
- searchReplaceRegionB :: YiString -> YiString -> Region -> BufferM Int
- searchReplaceSelectionB :: YiString -> YiString -> BufferM Int
- replaceString :: YiString -> YiString -> BufferM Int
- searchAndRepRegion :: YiString -> YiString -> Bool -> Region -> EditorM Bool
- searchAndRepRegion0 :: SearchExp -> YiString -> Bool -> Region -> BufferM Int
- searchAndRepUnit :: YiString -> YiString -> Bool -> TextUnit -> EditorM Bool
- isearchInitE :: Direction -> EditorM ()
- isearchIsEmpty :: EditorM Bool
- isearchAddE :: Text -> EditorM ()
- isearchPrevE :: EditorM ()
- isearchNextE :: EditorM ()
- isearchWordE :: EditorM ()
- isearchHistory :: Int -> EditorM ()
- isearchDelE :: EditorM ()
- isearchCancelE :: EditorM ()
- isearchFinishE :: EditorM ()
- isearchCancelWithE :: EditorM a -> EditorM ()
- isearchFinishWithE :: EditorM a -> EditorM ()
- qrNext :: Window -> BufferRef -> SearchExp -> EditorM ()
- qrReplaceAll :: Window -> BufferRef -> SearchExp -> YiString -> EditorM ()
- qrReplaceOne :: Window -> BufferRef -> SearchExp -> YiString -> EditorM ()
- qrFinish :: EditorM ()

# Documentation

setRegexE :: SearchExp -> EditorM () Source #

Put regex into regex `register`

resetRegexE :: EditorM () Source #

Clear the regex `register`

getRegexE :: EditorM (Maybe SearchExp) Source #

Return contents of regex register

type SearchMatch = Region Source #

Global searching. Search for regex and move point to that position. `Nothing` means reuse the last regular expression. `Just s` means use `s` as the new regular expression. Direction of search can be specified as either `Backward` or `Forward` (forwards in the buffer). Arguments to modify the compiled regular expression can be supplied as well.

data SearchResult Source #

Constructors

PatternFound |
PatternNotFound |
SearchWrapped |

#### Instances

Instances details

Eq SearchResult Source # |
Instance details Defined in Yi.Search Methods (==) :: SearchResult -> SearchResult -> Bool Source # (/=) :: SearchResult -> SearchResult -> Bool Source #

data SearchOption Source #

Constructors

IgnoreCase | Compile for matching that ignores char case
NoNewLine | Compile for newline-insensitive matching
QuoteRegex | Treat the input not as a regex but as a literal string to search for.

#### Instances

Instances details

Binary SearchOption |
Instance details Defined in Yi.Regex Methods put :: SearchOption -> Put Source # get :: Get SearchOption Source # putList :: [SearchOption] -> Put Source #
Generic SearchOption |

Instance details

Defined in Yi.Regex

Associated Types

type Rep SearchOption |
Instance details Defined in Yi.Regex type Rep SearchOption = D1 ('MetaData "SearchOption" "Yi.Regex" "yi-language-0.19.2-9aqnsb1TqRMA1LJA09MZJx" 'False) (C1 ('MetaCons "IgnoreCase" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoNewLine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "QuoteRegex" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: SearchOption -> Rep SearchOption x Source #

to :: Rep SearchOption x -> SearchOption Source #

Eq SearchOption |
Instance details Defined in Yi.Regex Methods (==) :: SearchOption -> SearchOption -> Bool Source # (/=) :: SearchOption -> SearchOption -> Bool Source #
type Rep SearchOption |
Instance details Defined in Yi.Regex type Rep SearchOption = D1 ('MetaData "SearchOption" "Yi.Regex" "yi-language-0.19.2-9aqnsb1TqRMA1LJA09MZJx" 'False) (C1 ('MetaCons "IgnoreCase" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoNewLine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "QuoteRegex" 'PrefixI 'False) (U1 :: Type -> Type)))

doSearch Source #

Arguments

:: Maybe String | `Nothing` means used previous pattern, if any. Complain otherwise. Use getRegexE to check for previous patterns
-> [SearchOption] | Flags to modify the compiled regex
-> Direction | `Backward` or `Forward`
-> EditorM SearchResult |

searchInit :: String -> Direction -> [SearchOption] -> EditorM (SearchExp, Direction) Source #

Set up a search.

continueSearch :: (SearchExp, Direction) -> BufferM SearchResult Source #

Do a search, placing cursor at first char of pattern, if found. Keymaps may implement their own regex language. How do we provide for this? Also, what's happening with ^ not matching sol?

makeSimpleSearch :: YiString -> SearchExp Source #

Create a SearchExp that matches exactly its argument

# Batch search-replace

searchReplaceRegionB Source #

Arguments

:: YiString | The string to search for
-> YiString | The string to replace it with
-> Region | The region to perform this over
-> BufferM Int |

Search and Replace all within the current region. Note the region is the final argument since we might perform the same search and replace over multiple regions however we are unlikely to perform several search and replaces over the same region since the first such may change the bounds of the region.

searchReplaceSelectionB Source #

Arguments

:: YiString | text to search for
-> YiString | text to replace it with
-> BufferM Int |

Peform a search and replace on the selection

replaceString :: YiString -> YiString -> BufferM Int Source #

Replace a string by another everywhere in the document

searchAndRepRegion :: YiString -> YiString -> Bool -> Region -> EditorM Bool Source #

searchAndRepRegion0 :: SearchExp -> YiString -> Bool -> Region -> BufferM Int Source #

Search and replace in the given region.

If the input boolean is True, then the replace is done globally, otherwise only the first match is replaced. Returns the number of replacements done.

searchAndRepUnit :: YiString -> YiString -> Bool -> TextUnit -> EditorM Bool Source #

Search and replace in the region defined by the given unit. The rest is as in `searchAndRepRegion`.

# Incremental Search

isearchInitE :: Direction -> EditorM () Source #

isearchIsEmpty :: EditorM Bool Source #

isearchAddE :: Text -> EditorM () Source #

isearchPrevE :: EditorM () Source #

isearchNextE :: EditorM () Source #

isearchWordE :: EditorM () Source #

isearchHistory :: Int -> EditorM () Source #

isearchDelE :: EditorM () Source #

isearchCancelE :: EditorM () Source #

Cancel a search. Also see `isearchCancelWithE`.

isearchFinishE :: EditorM () Source #

Successfully finish a search. Also see `isearchFinishWithE`.

isearchCancelWithE :: EditorM a -> EditorM () Source #

Wrapper over `isearchEndWith` that passes through the action and marks the search as unsuccessful (i.e. when the user wants to jump back to where the search started).

isearchFinishWithE :: EditorM a -> EditorM () Source #

Wrapper over `isearchEndWith` that passes through the action and accepts the search as successful (i.e. when the user wants to stay at the result).

# Replace

qrNext :: Window -> BufferRef -> SearchExp -> EditorM () Source #

Find the next match and select it. Point is end, mark is beginning.

qrReplaceAll :: Window -> BufferRef -> SearchExp -> YiString -> EditorM () Source #

Replace all the remaining occurrences.

qrReplaceOne :: Window -> BufferRef -> SearchExp -> YiString -> EditorM () Source #

We replace the currently selected match and then move to the next match.

qrFinish :: EditorM () Source #

Exit from query/replace.