Skip to content

terminal: 1:1 viewport by default, integer zoom opt-in (readability) - #179

Open
ccclosed wants to merge 3 commits into
devfrom
feat/term-readable-scale
Open

ccclosed wants to merge 3 commits into
devfrom
feat/term-readable-scale

Conversation

@ccclosed

@ccclosed ccclosed commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Terminal readability: 1:1 viewport by default, integer zoom opt-in (no fractional downscale)

User report: /dev/vtfb1 1280×800 was fractionally downscaled (~0.59–0.70) into a small window → tiny smeared text.

Policy (client-side View, no vtfb ABI change)

  • Default 1:1. Window ≥ surface → whole frame centred, no upscale. Window < surface → window-sized 1:1 viewport into the surface (full-size readable text), never fractional downscale.
  • Pan/scroll: wheel pans (Shift/horizontal = X); Ctrl+Shift+arrows by cell, Ctrl+Shift+PageUp/PageDown by page, Ctrl+Shift+Home/End to edges. Plain arrows/PageUp/PageDown still reach the shell (line editing/history/kernel-scrollback not stolen).
  • Integer zoom-out opt-in: --scale 2 / Ctrl+Shift+Z → whole surface at integer divisor (2×/3×…), nearest neighbour, never fractional.
  • Minimum window 320×200 (client::MIN_KERNEL_WINDOW), clamped on --size/configure.
  • Resize: re-clamp scroll offset; window ≥ surface re-centres. Pointer mapping (window_to_surface) follows the same source rect so clicks/selection land on the visible pixel.

Tests / gates

  • cargo test --package pagh-terminal: 209 passed / 0 failed (View unit tests, pan/clamp, resize re-center, integer mode, viewport blit, pointer offset, live KernelFrame regressions). cargo fmt --check clean.
  • Live tools/e2e.py termwindow: PASS (exit 0), BOOTID verified; df/ps/nano(edit+save)/ppkg/fastfetch/sync in the window, no panic.

Evidence

  • readable-live/rendered-compare.png — BEFORE (dev fractional, blurry) vs AFTER (1:1 full-size readable).
  • readable-live/rendered-after-1to1-top.png / -scrolled.png — viewport top / panned to bottom.
  • readable-live/after-fastfetch-live.png, after-nano-live.png, after-df-live.png — real QEMU window.
    (Evidence PNGs untracked, left as review artifacts.)

Docs: TERMINAL.md, docs/terminal-session.md, src/drivers/vt_mouse_abi.rs (doc-comment only).

UPDATE (a7e9214): auto-follow live bottom (lead merge condition)

  • View.follow default on: the 1:1 viewport pins to the live bottom, so the prompt + newest output are visible by default (no manual pan). New generations stay at bottom while following.
  • Manual pan up pauses following (read history without being yanked); pan back to bottom / Ctrl+Shift+End resumes. Resize keeps following at new bottom or preserves a user offset clamped. Integer-zoom mode unchanged (whole surface).
  • Tests 212 passed / 0 failed (follow default, pan-up pauses, bottom/End resumes, new-gen no-yank after pan-up, resize).
  • LIVE proof: readable-live/after-fastfetch-follow.png (default, no pan: fastfetch + pagh:/> prompt + status bar visible), after-df-live.png (df tail + prompt), after-nano-live.png (nano help bar), after-fastfetch-panned-up.png (history, follow paused), after-fastfetch-follow-resumed.png (byte-identical to default after wheel-down). Prompt visible immediately, not off-screen.

The kernel vtfb surface is 1280x800, the default window 900x600, and
fit_placement() squeezed the frame with a fractional factor (900/1280 =
0.70). Nearest-neighbour at a non-integer step puts 8x18 glyph strokes
between window pixels, so kernel-shell text rendered as smeared grey —
the readability defect FIX #1 names.

The policy is now integer-only:

* window >= surface: blit 1:1 centred, no upscale;
* window < surface: downscale by the smallest integer divisor n >= 2
  (2x, 3x, ...) that still fits, centred with theme-coloured letterbox;
  1280x800 in 900x600 is exactly 640x400;
* never crop: the divisor is chosen so the whole frame fits;
* degenerate windows (< 1 px after division) clamp to 1 px instead of
  panicking or dividing by zero.

blit_xrgb() samples through sample_index(), which is plain floor integer
arithmetic and copies exactly one source pixel per destination pixel (no
blend); for an exact factor it reduces to d * n. window_to_surface()
already uses the same layout, so pointer coordinates stay consistent.

Tests: unit placement/blit tests (1:1, 2x/3x/4x, never upscale, never
crop, no blend) plus a live KernelFrame regression that draws 1280x800
into a 900x600 window and checks the 640x400 centred placement and the
letterbox. cargo test --package pagh-terminal: 195 passed, 0 failed.

Evidence: 1280x800 rendered through the shipping blit at integer 2x and
1:1, with a 4x pixel-block zoom (0 blended pixels). TERMINAL.md and
docs/terminal-session.md document the policy change.
The kernel vtfb surface is always the boot screen (1280x800); the window is
smaller (panel + decorations). The previous policy downscaled the whole frame
— first fractionally (0.70, smeared text), then by an integer divisor (crisp
but half-size 640x400). Neither gives the user full-size readable text.

Presentation is now client-side `View` state, no vtfb ABI change:

* default: 1:1 pixels. Window >= surface -> whole frame centred, no upscale.
  Window < surface -> a window-sized 1:1 viewport into the surface; wheel
  pans it (Shift/horizontal axis for x), Ctrl+Shift+arrows/PageUp/PageDown
  pan by cell/page, Ctrl+Shift+Home/End jump. Plain arrows/PageUp/PageDown
  still reach the shell, so line editing/history/kernel-scrollback are not
  stolen. The wheel only pans the viewport while one exists; when the whole
  frame fits it keeps its kernel-scrollback meaning.
* opt-in integer zoom-out (--scale 2, Ctrl+Shift+Z): whole surface at an
  integer divisor (2x/3x/...), nearest neighbour, never fractional. This is
  the old readability fix, now an overview mode instead of the default.
* minimum kernel-session content size 320x200 (client::MIN_KERNEL_WINDOW):
  --size and configure are clamped so the 1:1 viewport never becomes a sliver.
* resize: set_window() re-clamps the scroll offset to the new geometry (grown
  window gives back overflow, window >= surface resets to centred). draw also
  re-clamps against the actual canvas, and respawn re-clamps after a new
  session geometry.
* pointer mapping (window_to_surface) follows the same source rect (src_x/
  src_y + view size), so clicks/selection land on the visible surface pixel.

Tests: View unit tests (1:1 default, pan/clamp, per-axis centring, resize
re-center, integer mode, viewport blit, pointer offset, pan-key/toggle
bindings), a client minimum-size test, a --scale parse test, and live
KernelFrame regressions (full-size default draw, pan to (200,100), edge
clamp, Home/End, resize to 1400x900 re-centres and letterboxes).  Existing
integer-downscale tests are kept for the optional mode.

cargo test --package pagh-terminal: 209 passed, 0 failed.
The previous 1:1 default anchored the viewport at the top-left. With a
1280x800 surface in a 900x600 window that hides the live prompt as soon as
output exceeds 600 px — the live fastfetch case showed the palette and prompt
below the view. A terminal must follow the newest output by default.

View now carries a `follow` flag (default on):

* while following, the 1:1 viewport is pinned to the bottom edge
  (`effective_scroll` returns max y), so new shell output and the prompt are
  always visible with no manual pan; horizontal stays clamped as before.
* panning up (wheel up, Ctrl+Shift+Up/PageUp/Home) clears `follow` and keeps
  the user's offset: new generations do not yank them out of history.
* returning to the bottom (wheel down to the edge, Ctrl+Shift+End) re-enables
  following. Ctrl+Shift+End keeps the horizontal offset and only goes to the
  bottom, instead of jumping to the bottom-right corner.
* resize/respawn: re-clamp. Following stays at the new bottom; a user-panned
  offset is preserved and clamped. A window that fits the surface makes
  following a no-op (offset 0, centred).
* integer zoom mode is unchanged: whole surface, no scroll/follow.
* startup is now bottom-anchored, so the pointer geometry computed before the
  first draw already matches the visible viewport.

Tests: View follow semantics (default bottom, pan-up disables, bottom/End
resumes, horizontal pan keeps follow, whole-frame no-op, resize keeps a user
offset or the bottom), plus KernelFrame regressions driven by a MockFb that
publishes a new generation per poll: default draw at src_y=200, new generation
while following keeps the bottom, pan-up survives a new generation, End
resumes. Help text documents the behaviour.

cargo test --package pagh-terminal: 212 passed, 0 failed.
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.

1 participant