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

Method right_crop

rich/text.py:1185–1199  ·  view source on GitHub ↗

Remove a number of characters from the end of the text.

(self, amount: int = 1)

Source from the content-addressed store, hash-verified

1183 return new_lines
1184
1185 def right_crop(self, amount: int = 1) -> None:
1186 """Remove a number of characters from the end of the text."""
1187 max_offset = len(self.plain) - amount
1188 _Span = Span
1189 self._spans[:] = [
1190 (
1191 span
1192 if span.end < max_offset
1193 else _Span(span.start, min(max_offset, span.end), span.style)
1194 )
1195 for span in self._spans
1196 if span.start < max_offset
1197 ]
1198 self._text = [self.plain[:-amount]]
1199 self._length -= amount
1200
1201 def wrap(
1202 self,

Callers 4

test_right_cropFunction · 0.95
remove_suffixMethod · 0.95
rstrip_endMethod · 0.95
set_lengthMethod · 0.95

Calls

no outgoing calls

Tested by 1

test_right_cropFunction · 0.76