Skip to content

API turboframe.search

rafageist edited this page Dec 4, 2026 · 4 revisions

turboframe.search

Source: turboframe/search.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

Find / replace over plain text (UI-independent).

Offsets are code-point indexes into the text. Options follow the Turbo Pascal Find and Replace dialogs: case sensitive, whole words only, regular expression, direction and origin.

Contents

SearchOptions, SearchError, compile_pattern, find, expand, replace_all, find_wrapping

class SearchOptions

class SearchOptions
SearchOptions(case_sensitive: bool = False, whole_words: bool = False, regex: bool = False, backward: bool = False, entire_scope: bool = False, prompt: bool = True)

SearchOptions(case_sensitive: 'bool' = False, whole_words: 'bool' = False, regex: 'bool' = False, backward: 'bool' = False, entire_scope: 'bool' = False, prompt: 'bool' = True)

class SearchError

class SearchError(ValueError)

The search text is not a valid pattern.

compile_pattern

def compile_pattern(query: str, opts: SearchOptions) -> re.Pattern[str]

find

def find(text: str, pattern: re.Pattern[str], pos: int, *, backward: bool = False) -> re.Match[str] | None

First match at/after pos, or the last one ending at/before pos when backward.

Empty matches are skipped so that repeated searches always move.

expand

def expand(match: re.Match[str], replacement: str, opts: SearchOptions) -> str

Replacement text for one match (\1 / \g<name> when regex).

replace_all

def replace_all(text: str, pattern: re.Pattern[str], replacement: str, opts: SearchOptions, start: int = 0) -> tuple[str, int]

Replace every non-empty match from start on. Returns (new text, count).

find_wrapping

def find_wrapping(text: str, pattern: re.Pattern[str], pos: int, *, backward: bool = False) -> tuple[re.Match[str] | None, bool]

find, then from the other end of the text: (the match, whether it wrapped).

Clone this wiki locally