forked from genewildish/Mainline
- Replace estimate_block_height (PIL-based) with estimate_simple_height (word wrap) - Update viewport filter tests to match new height-based filtering (~4 items vs 24) - Fix CI task duplication in mise.toml (remove redundant depends) Closes #38 Closes #36
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""Adapter wrapping Display as a Stage."""
|
|
|
|
from typing import Any
|
|
|
|
from engine.pipeline.core import PipelineContext, Stage
|
|
|
|
|
|
class DisplayStage(Stage):
|
|
"""Adapter wrapping Display as a Stage."""
|
|
|
|
def __init__(self, display, name: str = "terminal"):
|
|
self._display = display
|
|
self.name = name
|
|
self.category = "display"
|
|
self.optional = False
|
|
|
|
@property
|
|
def capabilities(self) -> set[str]:
|
|
return {"display.output"}
|
|
|
|
@property
|
|
def dependencies(self) -> set[str]:
|
|
return {"render.output"} # Display needs rendered content
|
|
|
|
@property
|
|
def inlet_types(self) -> set:
|
|
from engine.pipeline.core import DataType
|
|
|
|
return {DataType.TEXT_BUFFER} # Display consumes rendered text
|
|
|
|
@property
|
|
def outlet_types(self) -> set:
|
|
from engine.pipeline.core import DataType
|
|
|
|
return {DataType.NONE} # Display is a terminal stage (no output)
|
|
|
|
def init(self, ctx: PipelineContext) -> bool:
|
|
w = ctx.params.viewport_width if ctx.params else 80
|
|
h = ctx.params.viewport_height if ctx.params else 24
|
|
result = self._display.init(w, h, reuse=False)
|
|
return result is not False
|
|
|
|
def process(self, data: Any, ctx: PipelineContext) -> Any:
|
|
"""Output data to display."""
|
|
if data is not None:
|
|
self._display.show(data)
|
|
return data
|
|
|
|
def cleanup(self) -> None:
|
|
self._display.cleanup()
|