Repository navigation
API 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.
SearchOptions, SearchError, compile_pattern, find, expand, replace_all, find_wrapping
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(ValueError)The search text is not a valid pattern.
def compile_pattern(query: str, opts: SearchOptions) -> re.Pattern[str]def find(text: str, pattern: re.Pattern[str], pos: int, *, backward: bool = False) -> re.Match[str] | NoneFirst match at/after pos, or the last one ending at/before pos when backward.
Empty matches are skipped so that repeated searches always move.
def expand(match: re.Match[str], replacement: str, opts: SearchOptions) -> strReplacement text for one match (\1 / \g<name> when regex).
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).
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).
TurboFrame · part of Divengine · GPL-3.0-or-later · report an issue
Tutorial
Examples
The desktop
- The Desktop
- Application Mixins
- Windows and Lists
- Dialogs
- Histories
- Progress
- Themes and Colors
- Glyphs
- Settings and Recent Files
- Command Palette
Editing
Tasks
Languages
Running
Reference
Links