The OpenD Programming Language

Selection.find

Does a custom search through the text.

struct Selection
find
(
scope const(char)[] delegate
(
scope return const(char)[] buffer
)
predicate
,,)

Parameters

predicate const(char)[] delegate
(
scope return const(char)[] buffer
)

a search filter. It passes you back a slice of your buffer filled with text at the current search position. You pass the slice of this buffer that matched your search, or null if there was no match here. You MUST return either null or a slice of the buffer that was passed to you. If you return an empty slice of of the buffer (buffer[0..0] for example), it cancels the search.

The window buffer will try to move one code unit at a time. It may straddle code point boundaries - you need to account for this in your predicate.

searchBackward bool

determines the direction of the search. If true, it searches from the start of current selection backward to the beginning of the document. If false, it searches from the end of current selection forward to the end of the document.

Return Value

an object representing the search results and letting you manipulate the selection based upon it

Meta