tmuxp.cli.search.highlight_matches
-
Highlight regex matches in text.
Examples#
>>> from tmuxp.cli._colors import ColorMode, Colors>>> colors = Colors(ColorMode.NEVER)>>> pattern = SearchPattern(... fields=("name",),... raw="dev",... regex=re.compile("dev"),... )>>> highlight_matches("development", [pattern], colors=colors)'development'With colors enabled (ALWAYS mode):
>>> colors_on = Colors(ColorMode.ALWAYS)>>> result = highlight_matches("development", [pattern], colors=colors_on)>>> "dev" in resultTrue>>> chr(27) in result # Contains ANSI escapeTrue