vendor/github.com/charmbracelet/x/ansi/xterm.go

50 lines · 2016 bytes

 1package ansi
 2
 3import "strconv"
 4
 5// ModifyOtherKeys returns a sequence that sets XTerm modifyOtherKeys mode.
 6// The mode argument specifies the mode to set.
 7//
 8//	0: Disable modifyOtherKeys mode.
 9//	1: Enable modifyOtherKeys mode 1.
10//	2: Enable modifyOtherKeys mode 2.
11//
12//	CSI > 4 ; mode m
13//
14// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
15// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
16func ModifyOtherKeys(mode int) string {
17	return "\x1b[>4;" + strconv.Itoa(mode) + "m"
18}
19
20// DisableModifyOtherKeys disables the modifyOtherKeys mode.
21//
22//	CSI > 4 ; 0 m
23//
24// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
25// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
26const DisableModifyOtherKeys = "\x1b[>4;0m"
27
28// EnableModifyOtherKeys1 enables the modifyOtherKeys mode 1.
29//
30//	CSI > 4 ; 1 m
31//
32// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
33// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
34const EnableModifyOtherKeys1 = "\x1b[>4;1m"
35
36// EnableModifyOtherKeys2 enables the modifyOtherKeys mode 2.
37//
38//	CSI > 4 ; 2 m
39//
40// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
41// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
42const EnableModifyOtherKeys2 = "\x1b[>4;2m"
43
44// RequestModifyOtherKeys requests the modifyOtherKeys mode.
45//
46//	CSI ? 4  m
47//
48// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
49// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
50const RequestModifyOtherKeys = "\x1b[?4m"