Skip to content

Split Profile into capability groups and add libvt.profiles #37

Done

Description

@tony

Summary

Wave 1 leaf slice of #34: replace flat attributes and peer-named constructors on Profile with frozen, hashable capability dataclasses (Identity, QueryBehavior, ScreenBehavior, InputBehavior, UnicodeBehavior including East Asian ambiguous_width), and place pure host-terminal presets in src/libvt/profiles.py. Landing these peer-neutral axes first unblocks libvt.contrib.tmux.profile in Wave 2 without peer-name branches in Terminal or Screen.

Motivation

  • Profile mixes terminal identification strings, query replies, reset semantics, input flags, and peer-specific fields (tmux_window_rename) in one flat dataclass while Profile.tmux() embeds tmux version rules inside src/libvt/config.py.
  • src/libvt/_ucd.py and src/libvt/screen.py hard-code East Asian Ambiguous (EA=A) codepoints to 1 cell with no profile axis for 2-column CJK legacy layouts (ambiguous_width: Literal[1, 2] = 1).
  • Upstream tmux pane quirks verified in Move tmux to libvt.contrib.tmux and harden pre-0.1 core APIs #34 (RIS in ?1049h keeping alternate_on and saved_grid, silent XTGETTCAP/CSI ? u/DECSTR, enabled DECRQSS, and parameterized DA1) need orthogonal capability fields on Profile so terminal.py never inspects profile names.

Proposal

  • Decompose Profile in src/libvt/config.py into nested @dataclass(frozen=True, slots=True) capability groups (identity: Identity, queries: QueryBehavior, screen: ScreenBehavior, input: InputBehavior, unicode: UnicodeBehavior) using enums, literals, ints, bools, and byte/string tuples only (no callables, preserving hash() and equality).
  • Include ambiguous_width: t.Literal[1, 2] = 1 on UnicodeBehavior and wire char_width / display_width and Screen grapheme-width measurement to consult it while keeping U+FFFD width 1 and Emoji presentation (VS16 / RGI) width 2.
  • Express RIS alternate-screen behavior, DECSTR support, XTGETTCAP / DECRQSS / CSI ? u query replies, and ESC k .. ST title routing (allow_esc_k_title) as generic ScreenBehavior and QueryBehavior fields rather than tmux_*-named booleans.
  • Add src/libvt/profiles.py housing frozen host-terminal presets (XTERM_PROFILE, LINUX_CONSOLE_PROFILE, KITTY_PROFILE, GHOSTTY_PROFILE) built strictly from Profile data, leaving DEFAULT_PROFILE in src/libvt/config.py.

Alternatives

  • Adding a dialect: Literal["xterm", "tmux", ...] field on Profile and branching on it inside src/libvt/terminal.py: rejected because every new peer integration in libvt.contrib.<peer> would require core terminal.py edits instead of composing existing capability fields.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions