mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
batch update fix, and optimization
This commit is contained in:
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.12.1] - 2023-02-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix for batch updates
|
||||
|
||||
## [0.12.0] - 2023-02-24
|
||||
|
||||
### Added
|
||||
|
||||
@@ -8,10 +8,10 @@ from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
from ._border import get_box, render_row
|
||||
from .filter import LineFilter
|
||||
from ._opacity import _apply_opacity
|
||||
from ._segment_tools import line_pad, line_trim
|
||||
from .color import Color
|
||||
from .filter import LineFilter
|
||||
from .geometry import Region, Size, Spacing
|
||||
from .renderables.text_opacity import TextOpacity
|
||||
from .renderables.tint import Tint
|
||||
@@ -120,13 +120,12 @@ class StylesCache:
|
||||
)
|
||||
if widget.auto_links:
|
||||
hover_style = widget.hover_style
|
||||
link_hover_style = widget.link_hover_style
|
||||
if (
|
||||
link_hover_style
|
||||
and hover_style._link_id
|
||||
hover_style._link_id
|
||||
and hover_style._meta
|
||||
and "@click" in hover_style.meta
|
||||
):
|
||||
link_hover_style = widget.link_hover_style
|
||||
if link_hover_style:
|
||||
strips = [
|
||||
strip.style_links(hover_style.link_id, link_hover_style)
|
||||
|
||||
@@ -460,10 +460,6 @@ class App(Generic[ReturnType], DOMNode):
|
||||
self._batch_count -= 1
|
||||
assert self._batch_count >= 0, "This won't happen if you use `batch_update`"
|
||||
if not self._batch_count:
|
||||
try:
|
||||
self.screen.check_idle()
|
||||
except ScreenStackError:
|
||||
pass
|
||||
self.check_idle()
|
||||
|
||||
def animate(
|
||||
|
||||
@@ -9,8 +9,8 @@ from rich.segment import Segment
|
||||
from rich.style import Style, StyleType
|
||||
|
||||
from ._cache import FIFOCache
|
||||
from .filter import LineFilter
|
||||
from ._segment_tools import index_to_cell_position
|
||||
from .filter import LineFilter
|
||||
|
||||
|
||||
@rich.repr.auto
|
||||
@@ -29,6 +29,7 @@ class Strip:
|
||||
"_cell_length",
|
||||
"_divide_cache",
|
||||
"_crop_cache",
|
||||
"_link_ids",
|
||||
]
|
||||
|
||||
def __init__(
|
||||
@@ -38,6 +39,7 @@ class Strip:
|
||||
self._cell_length = cell_length
|
||||
self._divide_cache: FIFOCache[tuple[int, ...], list[Strip]] = FIFOCache(4)
|
||||
self._crop_cache: FIFOCache[tuple[int, int], Strip] = FIFOCache(4)
|
||||
self._link_ids: set[str] | None = None
|
||||
|
||||
def __rich_repr__(self) -> rich.repr.Result:
|
||||
yield self._segments
|
||||
@@ -48,6 +50,15 @@ class Strip:
|
||||
"""Segment text."""
|
||||
return "".join(segment.text for segment in self._segments)
|
||||
|
||||
@property
|
||||
def link_ids(self) -> set[str]:
|
||||
"""A set of the link ids in this Strip."""
|
||||
if self._link_ids is None:
|
||||
self._link_ids = {
|
||||
style._link_id for _, style, _ in self._segments if style is not None
|
||||
}
|
||||
return self._link_ids
|
||||
|
||||
@classmethod
|
||||
def blank(cls, cell_length: int, style: StyleType | None = None) -> Strip:
|
||||
"""Create a blank strip.
|
||||
@@ -230,19 +241,18 @@ class Strip:
|
||||
Returns:
|
||||
New strip (or same Strip if no changes).
|
||||
"""
|
||||
|
||||
_Segment = Segment
|
||||
if not any(
|
||||
segment.style._link_id == link_id
|
||||
for segment in self._segments
|
||||
if segment.style
|
||||
):
|
||||
if link_id not in self.link_ids:
|
||||
return self
|
||||
segments = [
|
||||
_Segment(
|
||||
text,
|
||||
(
|
||||
(style + link_style if style is not None else None)
|
||||
if (style and not style._null and style._link_id == link_id)
|
||||
else style,
|
||||
else style
|
||||
),
|
||||
control,
|
||||
)
|
||||
for text, style, control in self._segments
|
||||
|
||||
Reference in New Issue
Block a user