Skip to content

DECRPM: missing permanently set/reset mode responses #27

@ona-automations

Description

@ona-automations

Problem

requestMode (CSI $ p / CSI ? $ p) returns NOT_RECOGNIZED (Pm=0) for several modes that upstream xterm.js reports as PERMANENTLY_SET (Pm=3) or PERMANENTLY_RESET (Pm=4).

Affected modes:

Mode Type Upstream Response Go Port Response
2 (KAM) ANSI PERMANENTLY_RESET (4) NOT_RECOGNIZED (0)
12 (SRM) ANSI PERMANENTLY_SET (3) NOT_RECOGNIZED (0)
8 (DECARM) DEC private PERMANENTLY_SET (3) NOT_RECOGNIZED (0)
67 (DECBKM) DEC private PERMANENTLY_RESET (4) NOT_RECOGNIZED (0)
1005 (UTF-8 mouse) DEC private PERMANENTLY_RESET (4) NOT_RECOGNIZED (0)
1015 (urxvt mouse) DEC private PERMANENTLY_RESET (4) NOT_RECOGNIZED (0)

Reproduction

term := xterm.New(xterm.WithCols(80), xterm.WithRows(24))
defer term.Dispose()
var resp string
term.OnData(func(data string) { resp += data })

// ANSI mode 2 — should respond with Pm=4 (PERMANENTLY_RESET)
term.WriteString("\x1b[2$p")
// Got: "\x1b[2;0$y" (NOT_RECOGNIZED)
// Want: "\x1b[2;4$y" (PERMANENTLY_RESET)

Fix

In inputhandler_csi.go, add cases to ansiModeSetting and privateModeSetting:

// ansiModeSetting
case 2:
    return 4 // PERMANENTLY_RESET
case 12:
    return 3 // PERMANENTLY_SET

// privateModeSetting
case 8:
    return 3 // PERMANENTLY_SET
case 67:
    return 4 // PERMANENTLY_RESET
case 1005:
    return 4 // PERMANENTLY_RESET
case 1015:
    return 4 // PERMANENTLY_RESET

Upstream Reference

  • File: src/common/InputHandler.ts, method requestMode, lines 2330–2395
  • Commit: 6ba731d73bfbe074e84b57abb62080bed2f4db03

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions