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

Method fit

rich/text.py:1252–1266  ·  rich/text.py::Text.fit

Fit the text in to given width by chopping in to lines. Args: width (int): Maximum characters in a line. Returns: Lines: Lines container.

(self, width: int)

Source from the content-addressed store, hash-verified

1250 return lines
1251
1252 def fit(self, width: int) -> Lines:
1253 class="st">"""Fit the text in to given width by chopping in to lines.
1254
1255 Args:
1256 width (int): Maximum characters in a line.
1257
1258 Returns:
1259 Lines: Lines container.
1260 class="st">"""
1261 lines: Lines = Lines()
1262 append = lines.append
1263 for line in self.split():
1264 line.set_length(width)
1265 append(line)
1266 return lines
1267
1268 def detect_indentation(self) -> int:
1269 class="st">"""Auto-detect indentation of code.

Callers 14

test_fitFunction · 0.95
test_panel.pyFile · 0.45
test_python_renderFunction · 0.45
test_syntax.pyFile · 0.45
renderFunction · 0.45
test_rich_cast_containerFunction · 0.45
live_progress.pyFile · 0.45
time_fitMethod · 0.45
__rich__Method · 0.45
reportFunction · 0.45

Calls 3

splitMethod · 0.95
LinesClass · 0.85
set_lengthMethod · 0.80

Tested by 5

test_fitFunction · 0.76
test_python_renderFunction · 0.36
renderFunction · 0.36
test_rich_cast_containerFunction · 0.36