Skip to content

textual.fuzzy

Fuzzy matcher.

This class is used by the command palette to match search terms.

Matcher

Matcher(query, *, match_style=None, case_sensitive=False)

A fuzzy matcher.

Parameters:

Name Type Description Default

query

str

A query as typed in by the user.

required

match_style

Style | None

The style to use to highlight matched portions of a string.

None

case_sensitive

bool

Should matching be case sensitive?

False

case_sensitive property

case_sensitive

Is this matcher case sensitive?

match_style property

match_style

The style that will be used to highlight hits in the matched text.

query property

query

The query string to look for.

query_pattern property

query_pattern

The regular expression pattern built from the query.

highlight

highlight(candidate)

Highlight the candidate with the fuzzy match.

Parameters:

Name Type Description Default

candidate

str

The candidate string to match against the query.

required

Returns:

Type Description
Text

A [rich.text.Text][Text] object with highlighted matches.

match

match(candidate)

Match the candidate against the query.

Parameters:

Name Type Description Default

candidate

str

Candidate string to match against the query.

required

Returns:

Type Description
float

Strength of the match from 0 to 1.