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:
|
else:
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def _render_lines(self) -> None:
|
def _render_content(self) -> None:
|
||||||
"""Render all lines."""
|
"""Render all lines."""
|
||||||
width, height = self.content_size
|
width, height = self.content_size
|
||||||
renderable = self.render_styled()
|
renderable = self.render_styled()
|
||||||
@@ -985,14 +985,17 @@ class Widget(DOMNode):
|
|||||||
self._render_cache = RenderCache(self.content_size, lines)
|
self._render_cache = RenderCache(self.content_size, lines)
|
||||||
self._dirty_regions.clear()
|
self._dirty_regions.clear()
|
||||||
|
|
||||||
def _crop_lines(self, lines: Lines, x1, x2) -> Lines:
|
def render_line(self, y: int) -> list[Segment]:
|
||||||
width = self.size.width
|
"""Render a line of content.
|
||||||
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) -> 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]
|
line = self._render_cache.lines[y]
|
||||||
return line
|
return line
|
||||||
|
|
||||||
@@ -1005,9 +1008,6 @@ class Widget(DOMNode):
|
|||||||
Returns:
|
Returns:
|
||||||
Lines: A list of list of segments
|
Lines: A list of list of segments
|
||||||
"""
|
"""
|
||||||
if self._dirty_regions:
|
|
||||||
self._render_lines()
|
|
||||||
|
|
||||||
lines = self._styles_cache.render_widget(self, crop)
|
lines = self._styles_cache.render_widget(self, crop)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|||||||
@@ -499,6 +499,14 @@ class DataTable(ScrollView, Generic[CellType]):
|
|||||||
return segments
|
return segments
|
||||||
|
|
||||||
def render_line(self, y: int) -> list[Segment]:
|
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
|
width, height = self.content_size
|
||||||
scroll_x, scroll_y = self.scroll_offset
|
scroll_x, scroll_y = self.scroll_offset
|
||||||
fixed_top_row_count = sum(
|
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)
|
return self._render_line(y, scroll_x, scroll_x + width, style)
|
||||||
|
|
||||||
def render_lines(self, crop: Region) -> Lines:
|
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)
|
lines = self._styles_cache.render_widget(self, crop)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from rich.segment import Segment
|
from rich.segment import Segment
|
||||||
|
|
||||||
from textual.color import Color
|
from textual.color import Color
|
||||||
|
|||||||
Reference in New Issue
Block a user