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

Method set_length

rich/text.py:680–687  ·  view source on GitHub ↗

Set new length of the text, clipping or padding is required.

(self, new_length: int)

Source from the content-addressed store, hash-verified

678 self.right_crop(min(whitespace_count, excess))
679
680 def set_length(self, new_length: int) -> None:
681 """Set new length of the text, clipping or padding is required."""
682 length = len(self)
683 if length != new_length:
684 if length < new_length:
685 self.pad_right(new_length - length)
686 else:
687 self.right_crop(length - new_length)
688
689 def __rich_console__(
690 self, console: "Console", options: "ConsoleOptions"

Callers 2

test_set_lengthFunction · 0.95
fitMethod · 0.80

Calls 2

pad_rightMethod · 0.95
right_cropMethod · 0.95

Tested by 1

test_set_lengthFunction · 0.76