-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmode.go
64 lines (60 loc) · 1.13 KB
/
mode.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"github.com/charmbracelet/x/ansi"
)
func handleMode(p *ansi.Parser) (string, error) {
var m int
if n, ok := p.Param(0, 0); ok {
m = n
}
mode := modeDesc(m)
cmd := p.Cmd()
private := ""
if cmd.Marker() == '?' {
private = "private "
}
switch cmd.Command() {
case 'p':
// DECRQM - Request Mode
return fmt.Sprintf("Request %smode %q", private, mode), nil
case 'h':
return fmt.Sprintf("Enable %smode %q", private, mode), nil
case 'l':
return fmt.Sprintf("Disable %smode %q", private, mode), nil
}
return "", errUnhandled
}
//nolint:mnd
func modeDesc(mode int) string {
switch mode {
case 1:
return "cursor keys"
case 25:
return "cursor visibility"
case 1000:
return "show mouse"
case 1001:
return "mouse hilite"
case 1002:
return "mouse cell motion"
case 1003:
return "mouse all motion"
case 1004:
return "report focus"
case 1006:
return "mouse SGR ext"
case 1049:
return "altscreen"
case 2004:
return "bracketed paste"
case 2026:
return "synchronized output"
case 2027:
return "grapheme clustering"
case 9001:
return "win32 input"
default:
return "unknown"
}
}