[PR #8469] Refactor DEC/ANSI modes to avoid duplication when we add SM/RM #27208

Closed
opened 2026-01-31 09:20:39 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/8469

State: closed
Merged: Yes


I was about to add SetAnsiMode/ResetAnsiMode for SM and RM when I
realized that we probably don't need yet another enum of mode types, set and
reset functions, and a mode helper for ANSI standard modes when we already have
one for DEC Private modes.

This commit:

  1. Changes the enum PrivateModeParams to just be ModeParams
  2. Differentiates ANSI Standard modes (IRM, KAM, SRM, ...) from DEC
    Private modes (DECCOLM, DECCKM, ...) using a flag bit set in the enum
    value.
  3. Introduces a helper class for constructing these values much like
    VTID. That helper takes a bitmask and applies it to an input to
    produce the final enum value.
  4. Dispatches all mode set/reset through a common Set/Reset and
    _ModeHelper that uses the existing enum values.

[1] These modes are in separate namespaces with some overlap. We want to
differentiate them at dispatch time to ensure that \e[2h and \e[?2h are
given different treatment, and ensure that \e[1000h doesn't activate xterm
mouse mode.

Fixes #8457.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/8469 **State:** closed **Merged:** Yes --- I was about to add `SetAnsiMode`/`ResetAnsiMode` for `SM` and `RM` when I realized that we probably don't need yet another enum of mode types, set and reset functions, and a mode helper for ANSI standard modes when we already have one for DEC Private modes. This commit: 1. Changes the enum `PrivateModeParams` to just be `ModeParams` 2. Differentiates ANSI Standard modes (IRM, KAM, SRM, ...) from DEC Private modes (DECCOLM, DECCKM, ...) using a flag bit set in the enum value. 3. Introduces a helper class for constructing these values much like `VTID`. That helper takes a bitmask and applies it to an input to produce the final enum value. 4. Dispatches all mode set/reset through a common Set/Reset and `_ModeHelper` that uses the existing enum values. [1] These modes are in separate namespaces with some overlap. We want to differentiate them at dispatch time to ensure that `\e[2h` and `\e[?2h` are given different treatment, and ensure that `\e[1000h` doesn't activate xterm mouse mode. Fixes #8457.
claunia added the pull-request label 2026-01-31 09:20:39 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27208