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

Method extend_style

rich/text.py:572–591  ·  view source on GitHub ↗

Extend the Text given number of spaces where the spaces have the same style as the last character. Args: spaces (int): Number of spaces to add to the Text.

(self, spaces: int)

Source from the content-addressed store, hash-verified

570 return style
571
572 def extend_style(self, spaces: int) -> None:
573 """Extend the Text given number of spaces where the spaces have the same style as the last character.
574
575 Args:
576 spaces (int): Number of spaces to add to the Text.
577 """
578 if spaces <= 0:
579 return
580 spans = self.spans
581 new_spaces = " " * spaces
582 if spans:
583 end_offset = len(self)
584 self._spans[:] = [
585 span.extend(spaces) if span.end >= end_offset else span
586 for span in spans
587 ]
588 self._text.append(new_spaces)
589 self._length += spaces
590 else:
591 self.plain += new_spaces
592
593 def highlight_regex(
594 self,

Callers 2

test_extend_styleFunction · 0.80
expand_tabsMethod · 0.80

Calls 2

extendMethod · 0.45
appendMethod · 0.45

Tested by 1

test_extend_styleFunction · 0.64