Skip to content

Commit f9a5d5a

Browse files
fix: correct DA2 responses for screen and linux term names
Split the combined xterm/screen case in sendDeviceAttributesSecondary so that screen returns ESC[>83;40003;0c and linux echoes the parameter followed by c, matching upstream xterm.js behavior. Fixes #37 Co-authored-by: Ona <no-reply@ona.com>
1 parent 839e942 commit f9a5d5a

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

inputhandler_csi.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,14 @@ func (h *InputHandler) sendDeviceAttributesSecondary(params *Params) bool {
467467
}
468468
tn := h.optionsService.Options.TermName
469469
switch {
470-
case strings.HasPrefix(tn, "xterm"), strings.HasPrefix(tn, "screen"):
470+
case strings.HasPrefix(tn, "xterm"):
471471
h.coreService.TriggerDataEvent("\x1b[>0;276;0c", false, false)
472472
case strings.HasPrefix(tn, "rxvt-unicode"):
473473
h.coreService.TriggerDataEvent("\x1b[>85;95;0c", false, false)
474474
case strings.HasPrefix(tn, "linux"):
475-
// linux console does not respond to DA2
475+
h.coreService.TriggerDataEvent(fmt.Sprintf("%dc", params.Params[0]), false, false)
476+
case strings.HasPrefix(tn, "screen"):
477+
h.coreService.TriggerDataEvent("\x1b[>83;40003;0c", false, false)
476478
}
477479
return true
478480
}

inputhandler_csi_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,9 @@ func TestDeviceAttributes(t *testing.T) {
649649
}{
650650
{"xterm_default", "xterm", "\x1b[>c", "\x1b[>0;276;0c"},
651651
{"xterm-256color", "xterm-256color", "\x1b[>c", "\x1b[>0;276;0c"},
652-
{"screen", "screen", "\x1b[>c", "\x1b[>0;276;0c"},
652+
{"screen", "screen", "\x1b[>c", "\x1b[>83;40003;0c"},
653653
{"rxvt-unicode", "rxvt-unicode", "\x1b[>c", "\x1b[>85;95;0c"},
654-
{"linux_no_response", "linux", "\x1b[>c", ""},
654+
{"linux", "linux", "\x1b[>c", "0c"},
655655
{"non_zero_param_no_response", "xterm", "\x1b[>1c", ""},
656656
}
657657
for _, tc := range tests {

0 commit comments

Comments
 (0)