Remove whitespace beyond a certain width at the end of the text. Args: size (int): The desired size of the text.
(self, size: int)
| 664 | self.plain = self.plain.rstrip() |
| 665 | |
| 666 | def rstrip_end(self, size: int) -> None: |
| 667 | """Remove whitespace beyond a certain width at the end of the text. |
| 668 | |
| 669 | Args: |
| 670 | size (int): The desired size of the text. |
| 671 | """ |
| 672 | text_length = len(self) |
| 673 | if text_length > size: |
| 674 | excess = text_length - size |
| 675 | whitespace_match = _re_whitespace.search(self.plain) |
| 676 | if whitespace_match is not None: |
| 677 | whitespace_count = len(whitespace_match.group(0)) |
| 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.""" |