libvt.modes

ANSI standard and DEC private terminal mode definitions.

class libvt.modes.DecrpmValue
class libvt.modes.DecrpmValue

Bases: IntEnum

DECRPM status codes returned in CSI ? Ps ; Pm $ y replies.

class libvt.modes.Mode
class libvt.modes.Mode

Bases: IntEnum

ANSI standard modes and DEC private modes (0x8000 | code).

class libvt.modes.ModeState
class libvt.modes.ModeState

Bases: object

Mutable set of active ANSI and DEC private modes.

libvt.modes.is_private_mode_supported(mode, profile)
function[source]
function[source]
libvt.modes.is_private_mode_supported(mode, profile)

Return True when DEC private mode is supported by profile.

Parameters:
  • mode (Mode) – DEC private mode candidate.

  • profile (Profile) – Active terminal profile.

Returns:

True when private_mode_unsupported_status() returns None.

Return type:

bool

Examples

>>> from libvt.config import DEFAULT_PROFILE, Profile, ScreenBehavior
>>> from libvt.modes import Mode, is_private_mode_supported
>>> is_private_mode_supported(Mode.DECLRMM, DEFAULT_PROFILE)
True
>>> is_private_mode_supported(
...     Mode.DECLRMM, Profile(screen=ScreenBehavior(declrmm_enabled=False))
... )
False
libvt.modes.private_mode_unsupported_status(mode, screen)
function[source]
function[source]
libvt.modes.private_mode_unsupported_status(mode, screen)

Return forced DECRPM status when mode is unsupported, else None.

Single source of truth for profile-gated DEC private modes across ModeState.set_mode() interception, DECSET/DECRST, XTSAVE/XTRESTORE, and DECRQM queries.

Parameters:
  • mode (Mode) – DEC private mode to evaluate.

  • screen (ScreenBehavior) – Active profile screen behavior configuration.

Returns:

DecrpmValue.PERMANENTLY_RESET or DecrpmValue.NOT_RECOGNIZED when screen disables mode, otherwise None.

Return type:

DecrpmValue | None

References

Examples

>>> from libvt.config import DeccolmBehavior, ScreenBehavior
>>> from libvt.modes import DecrpmValue, Mode, private_mode_unsupported_status
>>> private_mode_unsupported_status(
...     Mode.DECCOLM, ScreenBehavior(deccolm=DeccolmBehavior.CLEAR_ONLY)
... )
<DecrpmValue.PERMANENTLY_RESET: 4>
>>> private_mode_unsupported_status(Mode.DECLRMM, ScreenBehavior()) is None
True