forked from genewildish/Mainline
- Fix TerminalDisplay: add screen clear each frame (cursor home + erase down) - Fix CameraStage: use set_canvas_size instead of read-only viewport properties - Fix Glitch effect: preserve visible line lengths, remove cursor positioning - Fix Fade effect: return original line when fade=0 instead of empty string - Fix Noise effect: use input line length instead of terminal_width - Remove HUD effect from all presets (redundant with border FPS display) - Add regression tests for effect dimension stability - Add docs/ARCHITECTURE.md with Mermaid diagrams - Add mise tasks: diagram-ascii, diagram-validate, diagram-check - Move markdown docs to docs/ (ARCHITECTURE, Refactor, hardware specs) - Remove redundant requirements files (use pyproject.toml) - Add *.dot and *.png to .gitignore Closes #25
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
"""
|
|
Null/headless display backend.
|
|
"""
|
|
|
|
import time
|
|
|
|
|
|
class NullDisplay:
|
|
"""Headless/null display - discards all output.
|
|
|
|
This display does nothing - useful for headless benchmarking
|
|
or when no display output is needed. Captures last buffer
|
|
for testing purposes.
|
|
"""
|
|
|
|
width: int = 80
|
|
height: int = 24
|
|
_last_buffer: list[str] | None = None
|
|
|
|
def __init__(self):
|
|
self._last_buffer = None
|
|
|
|
def init(self, width: int, height: int, reuse: bool = False) -> None:
|
|
"""Initialize display with dimensions.
|
|
|
|
Args:
|
|
width: Terminal width in characters
|
|
height: Terminal height in rows
|
|
reuse: Ignored for NullDisplay (no resources to reuse)
|
|
"""
|
|
self.width = width
|
|
self.height = height
|
|
self._last_buffer = None
|
|
|
|
def show(self, buffer: list[str], border: bool = False) -> None:
|
|
from engine.display import get_monitor
|
|
|
|
self._last_buffer = buffer
|
|
monitor = get_monitor()
|
|
if monitor:
|
|
t0 = time.perf_counter()
|
|
chars_in = sum(len(line) for line in buffer)
|
|
elapsed_ms = (time.perf_counter() - t0) * 1000
|
|
monitor.record_effect("null_display", elapsed_ms, chars_in, chars_in)
|
|
|
|
def clear(self) -> None:
|
|
pass
|
|
|
|
def cleanup(self) -> None:
|
|
pass
|
|
|
|
def get_dimensions(self) -> tuple[int, int]:
|
|
"""Get current dimensions.
|
|
|
|
Returns:
|
|
(width, height) in character cells
|
|
"""
|
|
return (self.width, self.height)
|
|
|
|
def is_quit_requested(self) -> bool:
|
|
"""Check if quit was requested (optional protocol method)."""
|
|
return False
|
|
|
|
def clear_quit_request(self) -> None:
|
|
"""Clear quit request (optional protocol method)."""
|
|
pass
|