mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge branch 'main' into scroll-sensitivity
This commit is contained in:
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Programmatically setting `overflow_x`/`overflow_y` refreshes the layout correctly https://github.com/Textualize/textual/issues/1616
|
- Programmatically setting `overflow_x`/`overflow_y` refreshes the layout correctly https://github.com/Textualize/textual/issues/1616
|
||||||
- Fixed double-paste into `Input` https://github.com/Textualize/textual/issues/1657
|
- Fixed double-paste into `Input` https://github.com/Textualize/textual/issues/1657
|
||||||
- Added a workaround for an apparent Windows Terminal paste issue https://github.com/Textualize/textual/issues/1661
|
- Added a workaround for an apparent Windows Terminal paste issue https://github.com/Textualize/textual/issues/1661
|
||||||
|
- Fixes issue with renderable width calculation https://github.com/Textualize/textual/issues/1685
|
||||||
|
|
||||||
## [0.10.1] - 2023-01-20
|
## [0.10.1] - 2023-01-20
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,20 @@ from rich.console import Console, RenderableType
|
|||||||
from rich.protocol import rich_cast
|
from rich.protocol import rich_cast
|
||||||
|
|
||||||
|
|
||||||
def measure(console: Console, renderable: RenderableType, default: int) -> int:
|
def measure(
|
||||||
|
console: Console,
|
||||||
|
renderable: RenderableType,
|
||||||
|
default: int,
|
||||||
|
*,
|
||||||
|
container_width: int | None = None
|
||||||
|
) -> int:
|
||||||
"""Measure a rich renderable.
|
"""Measure a rich renderable.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
console: A console object.
|
console: A console object.
|
||||||
renderable: Rich renderable.
|
renderable: Rich renderable.
|
||||||
default: Default width to use if renderable does not expose dimensions.
|
default: Default width to use if renderable does not expose dimensions.
|
||||||
|
container_width: Width of container or None to use console width.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Width in cells
|
Width in cells
|
||||||
@@ -17,6 +24,13 @@ def measure(console: Console, renderable: RenderableType, default: int) -> int:
|
|||||||
renderable = rich_cast(renderable)
|
renderable = rich_cast(renderable)
|
||||||
get_console_width = getattr(renderable, "__rich_measure__", None)
|
get_console_width = getattr(renderable, "__rich_measure__", None)
|
||||||
if get_console_width is not None:
|
if get_console_width is not None:
|
||||||
render_width = get_console_width(console, console.options).maximum
|
render_width = get_console_width(
|
||||||
|
console,
|
||||||
|
(
|
||||||
|
console.options
|
||||||
|
if container_width is None
|
||||||
|
else console.options.update_width(container_width)
|
||||||
|
),
|
||||||
|
).maximum
|
||||||
width = max(0, render_width)
|
width = max(0, render_width)
|
||||||
return width
|
return width
|
||||||
|
|||||||
@@ -795,7 +795,9 @@ class Widget(DOMNode):
|
|||||||
console = self.app.console
|
console = self.app.console
|
||||||
renderable = self._render()
|
renderable = self._render()
|
||||||
|
|
||||||
width = measure(console, renderable, container.width)
|
width = measure(
|
||||||
|
console, renderable, container.width, container_width=container.width
|
||||||
|
)
|
||||||
if self.expand:
|
if self.expand:
|
||||||
width = max(container.width, width)
|
width = max(container.width, width)
|
||||||
if self.shrink:
|
if self.shrink:
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -193,3 +193,8 @@ def test_demo(snap_compare):
|
|||||||
press=["down", "down", "down", "_", "_", "_"],
|
press=["down", "down", "down", "_", "_", "_"],
|
||||||
terminal_size=(100, 30),
|
terminal_size=(100, 30),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_label_wrap(snap_compare):
|
||||||
|
"""Test Label wrapping with a Panel"""
|
||||||
|
assert snap_compare("snapshot_apps/label_wrap.py")
|
||||||
|
|||||||
Reference in New Issue
Block a user