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

Method __rich_measure__

rich/panel.py:277–297  ·  view source on GitHub ↗
(
        self, console: "Console", options: "ConsoleOptions"
    )

Source from the content-addressed store, hash-verified

275 yield new_line
276
277 def __rich_measure__(
278 self, console: "Console", options: "ConsoleOptions"
279 ) -> "Measurement":
280 _title = self._title
281 _, right, _, left = Padding.unpack(self.padding)
282 padding = left + right
283 renderables = [self.renderable, _title] if _title else [self.renderable]
284
285 if self.width is None:
286 width = (
287 measure_renderables(
288 console,
289 options.update_width(options.max_width - padding - 2),
290 renderables,
291 ).maximum
292 + padding
293 + 2
294 )
295 else:
296 width = self.width
297 return Measurement(width, width)
298
299
300if __name__ == "__main__": # pragma: no cover

Callers 2

test_console_widthFunction · 0.95
test_fixed_widthFunction · 0.95

Calls 4

measure_renderablesFunction · 0.85
MeasurementClass · 0.85
unpackMethod · 0.80
update_widthMethod · 0.80

Tested by 2

test_console_widthFunction · 0.76
test_fixed_widthFunction · 0.76