Skip to content

feat(terminal): report text-area size via XTWINOPS (CSI 14/18 t)#67

Draft
roramirez wants to merge 1 commit into
mainfrom
feat/xtwinops-size-report
Draft

feat(terminal): report text-area size via XTWINOPS (CSI 14/18 t)#67
roramirez wants to merge 1 commit into
mainfrom
feat/xtwinops-size-report

Conversation

@roramirez

Copy link
Copy Markdown
Owner

Summary

Implements the XTWINOPS text-area size reports:

  • CSI 18 tCSI 8 ; rows ; cols t (size in character cells).
  • CSI 14 tCSI 4 ; height ; width t (size in pixels).

fzf and tmux query these to compute layouts and preview windows. Cell size in cells was already known to the parser; the pixel report additionally needs the cell pixel size, which is carried from the main thread.

Changes

  • src/terminal/parser.rs: new 't' CSI arm delegating to handle_xtwinops, which replies for 14/18 and ignores other window operations. Also collapses the DECSET/DECRST (h/l) arms of handle_dec_private_modes into ('h' | 'l', …) patterns (same behavior, fewer lines).
  • src/terminal/grid.rs: add Grid.cell_px: (u32, u32), mirrored from FontMetrics on resize.
  • src/drain.rs: extend the non-blocking resize signal to (cols, rows, cell_w_px, cell_h_px) via a new PendingResize type alias; apply the cell size onto the grid at both resize-application sites.
  • src/pane_ops.rs, src/app_state.rs: use the PendingResize alias; populate the cell size from entry.metrics when signaling a resize.
  • Tests: xtwinops_reports_text_area_size (cells, pixels, and an unsupported op); update the pending_resize tuple in pane_ops_test.rs / drain_test.rs.
  • CHANGELOG.md: entry under [Unreleased] / Added.

How to test

  • cargo test (see xtwinops_reports_text_area_size; full suite green).
  • In a running mmterm session: printf '\033[18t' replies \033[8;<rows>;<cols>t; printf '\033[14t' replies with the pixel size.

Checks

  • cargo fmt
  • cargo clippy --locked -- -D warnings
  • cargo test (1204 passed)
  • [~] km score --trend origin/main --fail-if-worse — grade B+ (passes .kimun.toml fail_below = B); trend is -0.01 at the rounding floor, from the unavoidable indented plumbing added inside the parser event loop. Offset as far as reasonable by simplifying the DEC private-mode setter; further clawback would require gratuitous refactoring of unrelated code.
  • CHANGELOG.md updated

Reply to CSI 18 t with the text-area size in cells (CSI 8 ; rows ; cols t)
and to CSI 14 t with the size in pixels (CSI 4 ; height ; width t). fzf
and tmux use these to compute layouts.

Cell pixel size is carried to the parser thread by extending the
pending-resize signal and mirrored onto the grid as `cell_px`. Collapse
the DECSET/DECRST arms into `h | l` patterns while in the file.
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