forked from genewildish/Mainline
- Add EffectPlugin ABC with @abstractmethod decorators for interface enforcement - Add runtime interface checking in discover_plugins() with issubclass() - Add EffectContext factory with sensible defaults - Standardize Display __init__ (remove redundant init in TerminalDisplay) - Document effect behavior when ticker_height=0 - Evaluate legacy effects: document coexistence, no deprecation needed - Research plugin patterns (VST, Python entry points) - Fix pysixel dependency (removed broken dependency) Test coverage improvements: - Add DisplayRegistry tests - Add MultiDisplay tests - Add SixelDisplay tests - Add controller._get_display tests - Add effects controller command handling tests - Add benchmark regression tests (@pytest.mark.benchmark) - Add pytest marker for benchmark tests in pyproject.toml Documentation updates: - Update AGENTS.md with 56% coverage stats and effect plugin docs - Update README.md with Sixel display mode and benchmark commands - Add new modules to architecture section
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""
|
|
ANSI terminal display backend.
|
|
"""
|
|
|
|
import time
|
|
|
|
|
|
class TerminalDisplay:
|
|
"""ANSI terminal display backend."""
|
|
|
|
width: int = 80
|
|
height: int = 24
|
|
|
|
def init(self, width: int, height: int) -> None:
|
|
from engine.terminal import CURSOR_OFF
|
|
|
|
self.width = width
|
|
self.height = height
|
|
print(CURSOR_OFF, end="", flush=True)
|
|
|
|
def show(self, buffer: list[str]) -> None:
|
|
import sys
|
|
|
|
t0 = time.perf_counter()
|
|
sys.stdout.buffer.write("".join(buffer).encode())
|
|
sys.stdout.flush()
|
|
elapsed_ms = (time.perf_counter() - t0) * 1000
|
|
|
|
from engine.display import get_monitor
|
|
|
|
monitor = get_monitor()
|
|
if monitor:
|
|
chars_in = sum(len(line) for line in buffer)
|
|
monitor.record_effect("terminal_display", elapsed_ms, chars_in, chars_in)
|
|
|
|
def clear(self) -> None:
|
|
from engine.terminal import CLR
|
|
|
|
print(CLR, end="", flush=True)
|
|
|
|
def cleanup(self) -> None:
|
|
from engine.terminal import CURSOR_ON
|
|
|
|
print(CURSOR_ON, end="", flush=True)
|