mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
docstrings
This commit is contained in:
@@ -974,7 +974,7 @@ class Widget(DOMNode):
|
||||
else:
|
||||
self.refresh()
|
||||
|
||||
def _render_lines(self) -> None:
|
||||
def _render_content(self) -> None:
|
||||
"""Render all lines."""
|
||||
width, height = self.content_size
|
||||
renderable = self.render_styled()
|
||||
@@ -985,14 +985,17 @@ class Widget(DOMNode):
|
||||
self._render_cache = RenderCache(self.content_size, lines)
|
||||
self._dirty_regions.clear()
|
||||
|
||||
def _crop_lines(self, lines: Lines, x1, x2) -> Lines:
|
||||
width = self.size.width
|
||||
if (x1, x2) != (0, width):
|
||||
_line_crop = line_crop
|
||||
lines = [_line_crop(line, x1, x2, width) for line in lines]
|
||||
return lines
|
||||
def render_line(self, y: int) -> list[Segment]:
|
||||
"""Render a line of content.
|
||||
|
||||
def render_line(self, y) -> list[Segment]:
|
||||
Args:
|
||||
y (int): Y Coordinate of line.
|
||||
|
||||
Returns:
|
||||
list[Segment]: A rendered line.
|
||||
"""
|
||||
if self._dirty_regions:
|
||||
self._render_content()
|
||||
line = self._render_cache.lines[y]
|
||||
return line
|
||||
|
||||
@@ -1005,9 +1008,6 @@ class Widget(DOMNode):
|
||||
Returns:
|
||||
Lines: A list of list of segments
|
||||
"""
|
||||
if self._dirty_regions:
|
||||
self._render_lines()
|
||||
|
||||
lines = self._styles_cache.render_widget(self, crop)
|
||||
return lines
|
||||
|
||||
|
||||
@@ -499,6 +499,14 @@ class DataTable(ScrollView, Generic[CellType]):
|
||||
return segments
|
||||
|
||||
def render_line(self, y: int) -> list[Segment]:
|
||||
"""Render a line of content.
|
||||
|
||||
Args:
|
||||
y (int): Y Coordinate of line.
|
||||
|
||||
Returns:
|
||||
list[Segment]: A rendered line.
|
||||
"""
|
||||
width, height = self.content_size
|
||||
scroll_x, scroll_y = self.scroll_offset
|
||||
fixed_top_row_count = sum(
|
||||
@@ -515,6 +523,14 @@ class DataTable(ScrollView, Generic[CellType]):
|
||||
return self._render_line(y, scroll_x, scroll_x + width, style)
|
||||
|
||||
def render_lines(self, crop: Region) -> Lines:
|
||||
"""Render the widget in to lines.
|
||||
|
||||
Args:
|
||||
crop (Region): Region within visible area to.
|
||||
|
||||
Returns:
|
||||
Lines: A list of list of segments
|
||||
"""
|
||||
lines = self._styles_cache.render_widget(self, crop)
|
||||
return lines
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from rich.segment import Segment
|
||||
|
||||
from textual.color import Color
|
||||
|
||||
Reference in New Issue
Block a user