MCPcopy
hub / github.com/Textualize/rich / stylize_range

Method stylize_range

rich/syntax.py:555–574  ·  view source on GitHub ↗

Adds a custom style on a part of the code, that will be applied to the syntax display when it's rendered. Line numbers are 1-based, while column indexes are 0-based. Args: style (StyleType): The style to apply. start (Tuple[int, int]): The start of t

(
        self,
        style: StyleType,
        start: SyntaxPosition,
        end: SyntaxPosition,
        style_before: bool = False,
    )

Source from the content-addressed store, hash-verified

553 return text
554
555 def stylize_range(
556 self,
557 style: StyleType,
558 start: SyntaxPosition,
559 end: SyntaxPosition,
560 style_before: bool = False,
561 ) -> None:
562 """
563 Adds a custom style on a part of the code, that will be applied to the syntax display when it's rendered.
564 Line numbers are 1-based, while column indexes are 0-based.
565
566 Args:
567 style (StyleType): The style to apply.
568 start (Tuple[int, int]): The start of the range, in the form `[line number, column index]`.
569 end (Tuple[int, int]): The end of the range, in the form `[line number, column index]`.
570 style_before (bool): Apply the style before any existing styles.
571 """
572 self._stylized_ranges.append(
573 _SyntaxHighlightRange(style, start, end, style_before)
574 )
575
576 def _get_line_numbers_color(self, blend: float = 0.3) -> Color:
577 background_style = self._theme.get_background_style() + self.background_style

Callers 2

_render_stackMethod · 0.95

Calls 2

appendMethod · 0.45

Tested by 1