""" Viewport utilities — terminal dimensions and ANSI positioning helpers. No internal dependencies. """ import os def tw() -> int: """Get terminal width (columns).""" try: return os.get_terminal_size().columns except Exception: return 80 def th() -> int: """Get terminal height (lines).""" try: return os.get_terminal_size().lines except Exception: return 24 def move_to(row: int, col: int = 1) -> str: """Generate ANSI escape to move cursor to row, col (1-indexed).""" return f"\033[{row};{col}H" def clear_screen() -> str: """Clear screen and move cursor to home.""" return "\033[2J\033[H" def clear_line() -> str: """Clear current line.""" return "\033[K"