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

Method stylize

rich/text.py:457–481  ·  view source on GitHub ↗

Apply a style to the text, or a portion of the text. Args: style (Union[str, Style]): Style instance or style definition to apply. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negati

(
        self,
        style: Union[str, Style],
        start: int = 0,
        end: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

455 return copy_self
456
457 def stylize(
458 self,
459 style: Union[str, Style],
460 start: int = 0,
461 end: Optional[int] = None,
462 ) -> None:
463 """Apply a style to the text, or a portion of the text.
464
465 Args:
466 style (Union[str, Style]): Style instance or style definition to apply.
467 start (int): Start offset (negative indexing is supported). Defaults to 0.
468 end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
469 """
470 if style:
471 length = len(self)
472 if start < 0:
473 start = length + start
474 if end is None:
475 end = length
476 if end < 0:
477 end = length + end
478 if start >= length or end <= start:
479 # Span not in text or not valid
480 return
481 self._spans.append(Span(start, min(length, end), style))
482
483 def stylize_before(
484 self,

Callers 15

test_stylizeFunction · 0.95
test_stylize_beforeFunction · 0.95
test_set_lengthFunction · 0.95
walk_directoryFunction · 0.95
make_filename_textFunction · 0.95
print_calendarFunction · 0.95
apply_metaMethod · 0.95
onMethod · 0.95
_get_signatureMethod · 0.95
highlightMethod · 0.95
highlightMethod · 0.80

Calls 2

SpanClass · 0.85
appendMethod · 0.45

Tested by 4

test_stylizeFunction · 0.76
test_stylize_beforeFunction · 0.76
test_set_lengthFunction · 0.76