Skip to content

Commit 3bbf4da

Browse files
feat: add DECSET/DECRST handlers for modes 2031 and 9001
Add case branches for color scheme updates (mode 2031) and win32 input mode (mode 9001) in setModePrivate and resetModePrivate. The DecPrivateModes fields already existed but were never set. Fixes #7 Co-authored-by: Ona <no-reply@ona.com>
1 parent d092e6b commit 3bbf4da

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

inputhandler_csi.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@ func (h *InputHandler) setModePrivate(params *Params) bool {
641641
h.coreService.DecPrivateModes.BracketedPasteMode = true
642642
case 2026:
643643
h.coreService.DecPrivateModes.SynchronizedOutput = true
644+
case 2031:
645+
h.coreService.DecPrivateModes.ColorSchemeUpdates = true
646+
case 9001:
647+
h.coreService.DecPrivateModes.Win32InputMode = true
644648
}
645649
}
646650
return true
@@ -689,6 +693,10 @@ func (h *InputHandler) resetModePrivate(params *Params) bool {
689693
case 2026:
690694
h.coreService.DecPrivateModes.SynchronizedOutput = false
691695
h.OnRequestRefreshRowsEmitter.Fire(RowRange{})
696+
case 2031:
697+
h.coreService.DecPrivateModes.ColorSchemeUpdates = false
698+
case 9001:
699+
h.coreService.DecPrivateModes.Win32InputMode = false
692700
}
693701
}
694702
return true

inputhandler_csi_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,3 +703,63 @@ func TestSelectProtected(t *testing.T) {
703703
})
704704
}
705705
}
706+
707+
func TestSetResetModeColorSchemeAndWin32(t *testing.T) {
708+
t.Parallel()
709+
type Expectation struct {
710+
ColorSchemeUpdates bool
711+
Win32InputMode bool
712+
}
713+
tests := []struct {
714+
Name string
715+
Input string
716+
Expected Expectation
717+
}{
718+
{
719+
Name: "DECSET_color_scheme_updates",
720+
Input: "\x1b[?2031h",
721+
Expected: Expectation{ColorSchemeUpdates: true},
722+
},
723+
{
724+
Name: "DECRST_color_scheme_updates",
725+
Input: "\x1b[?2031h\x1b[?2031l",
726+
Expected: Expectation{ColorSchemeUpdates: false},
727+
},
728+
{
729+
Name: "DECSET_win32_input_mode",
730+
Input: "\x1b[?9001h",
731+
Expected: Expectation{Win32InputMode: true},
732+
},
733+
{
734+
Name: "DECRST_win32_input_mode",
735+
Input: "\x1b[?9001h\x1b[?9001l",
736+
Expected: Expectation{Win32InputMode: false},
737+
},
738+
{
739+
Name: "DECSET_both_modes",
740+
Input: "\x1b[?2031h\x1b[?9001h",
741+
Expected: Expectation{ColorSchemeUpdates: true, Win32InputMode: true},
742+
},
743+
{
744+
Name: "DECRST_both_modes",
745+
Input: "\x1b[?2031h\x1b[?9001h\x1b[?2031l\x1b[?9001l",
746+
Expected: Expectation{ColorSchemeUpdates: false, Win32InputMode: false},
747+
},
748+
}
749+
for _, tc := range tests {
750+
t.Run(tc.Name, func(t *testing.T) {
751+
t.Parallel()
752+
h := newTestInputHandler(80, 24)
753+
h.ParseString(tc.Input)
754+
got := Expectation{
755+
ColorSchemeUpdates: h.coreService.DecPrivateModes.ColorSchemeUpdates,
756+
Win32InputMode: h.coreService.DecPrivateModes.Win32InputMode,
757+
}
758+
if diff := cmp.Diff(tc.Expected, got); diff != "" {
759+
t.Errorf("mismatch (-want +got):\n%s", diff)
760+
}
761+
})
762+
}
763+
}
764+
765+

0 commit comments

Comments
 (0)