feat: Implement poster rendering options with ASCII, Viu, and RichPixels support

This commit is contained in:
sha
2026-01-04 18:35:30 +00:00
parent 9b353a7e7e
commit 442bde73e5
17 changed files with 416 additions and 135 deletions
+29
View File
@@ -0,0 +1,29 @@
"""Custom widget for rendering poster images."""
from textual.widget import Widget
from textual.widgets import Static
from rich.console import RenderableType
from typing import Union
class PosterWidget(Static):
"""Widget optimized for displaying poster images with Rich renderables.
This widget properly handles both string content and Rich renderables
(like Pixels from rich-pixels) without escaping or markup processing.
"""
def __init__(self, *args, **kwargs):
"""Initialize poster widget with markup disabled."""
# Force markup=False to prevent text processing
kwargs['markup'] = False
super().__init__(*args, **kwargs)
def update_poster(self, renderable: Union[str, RenderableType]) -> None:
"""Update poster display with new content.
Args:
renderable: String or Rich Renderable object to display
"""
# Directly update with the renderable - Textual handles Rich renderables natively
self.update(renderable if renderable else "")