Skip to content

screen(feat[viewport]): Add viewport and display (#59) - #62

Open
tony wants to merge 1 commit into
feat/deccolm-cp437-docsfrom
feat/display-lines-viewport
Open

tony wants to merge 1 commit into
feat/deccolm-cp437-docsfrom
feat/display-lines-viewport

Conversation

@tony

@tony tony commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Closes #59 (depends on #61)

Summary

  • Add RowView.display_text and display_lines for column-padded rectangular screen export.
  • Replace wide glyphs split across sub-slice boundaries with single-column spaces.
  • Add Snapshot.viewport(offset=0) for stateless row-offset scrollback paging over immutable snapshots.
  • Expand docs/topics/migrating-from-pyte.md with a pyte 0.8.2 compatibility matrix and doctests.

Changes

Screen and snapshot views

  • src/libvt/screen.py: add RowView.display_text and RegionView.display_lines / Screen.display_lines, padding trailing blanks to exact slice width in terminal columns while replacing wide leads or trailing spacers clipped at slice edges with " ".
  • src/libvt/terminal.py: add Snapshot.display_lines, Terminal.display_lines, and Snapshot.viewport(offset=0) returning an immutable (rows, cols) RegionView clamped to len(history) on primary snapshots (thawing historical FrozenRow entries whose width differs from Snapshot.cols), pinned to the active viewport on alternate-screen snapshots, and raising ValueError on negative offset or TypeError on bool.

Tests and documentation

  • tests/test_pyte_compat.py: cover wide-character, ZWJ emoji, and combining-mark display_lines, sub-slice clipping, primary and alternate Snapshot.viewport() paging, snapshot immutability across subsequent feed() calls, and chunked-stream parity.
  • docs/topics/migrating-from-pyte.md and CHANGES: document pyte (0.8.2 baseline) API mappings, intentional omissions, and runnable migration doctests.

Design decisions

  • Expose a stateless Snapshot.viewport(offset=0) primitive rather than a stateful HistoryScreen cursor on Terminal so history inspection cannot mutate live terminal rows or contend with concurrent feed() calls.
  • Keep alternate-screen Snapshot.viewport(offset) isolated to the alternate viewport rather than blending primary scrollback above full-screen TUI buffers.

Test plan

  • Validate display_lines padding and wide-boundary clipping across CJK, ZWJ emoji, and combining marks in tests/test_pyte_compat.py
  • Validate Snapshot.viewport() clamping, negative/bool rejection, alt-screen isolation, and post-feed immutability in tests/test_pyte_compat.py
  • Execute all docs/topics/migrating-from-pyte.md doctests via pytest and verify cross-references via just build-docs
  • Pass ruff format, ruff check, ty check, pytest, and just build-docs

why: Callers migrating from pyte.Screen.display and HistoryScreen need
full-width rectangular row export and stateless scrollback paging over
immutable snapshots without mutating live terminal state.

what:
- Add RowView.display_text and display_lines on RegionView, Screen,
  Snapshot, and Terminal with wide-glyph boundary clipping
- Add Snapshot.viewport(offset=0) returning a clamped (rows, cols)
  RegionView over retained primary history without alt-screen blending
- Expand docs/topics/migrating-from-pyte.md with a pyte 0.8.2 matrix,
  documented omissions, and runnable doctests
@tony
tony changed the base branch from master to feat/deccolm-cp437-docs November 29, 2026 02:33

This branch was successfully deployed

1 active deployment
docs — c8ae6397 Deployed Nov 29, 2026 by tony via build (3.14) #128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add display_lines, Snapshot.viewport(), and pyte migration docs

1 participant