File: mod.go

package info (click to toggle)
golang-github-charmbracelet-x 0.0~git20240809.9ab0ca0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: sh: 55; makefile: 5
file content (70 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download
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
65
66
67
68
69
70
package input

// KeyMod represents modifier keys.
type KeyMod uint16

// Modifier keys.
const (
	Shift KeyMod = 1 << iota
	Alt
	Ctrl
	Meta

	// These modifiers are used with the Kitty protocol.
	// XXX: Meta and Super are swapped in the Kitty protocol,
	// this is to preserve compatibility with XTerm modifiers.

	Hyper
	Super // Windows/Command keys

	// These are key lock states.

	CapsLock
	NumLock
	ScrollLock // Defined in Windows API only
)

// IsShift reports whether the Shift modifier is set.
func (m KeyMod) IsShift() bool {
	return m&Shift != 0
}

// IsAlt reports whether the Alt modifier is set.
func (m KeyMod) IsAlt() bool {
	return m&Alt != 0
}

// IsCtrl reports whether the Ctrl modifier is set.
func (m KeyMod) IsCtrl() bool {
	return m&Ctrl != 0
}

// IsMeta reports whether the Meta modifier is set.
func (m KeyMod) IsMeta() bool {
	return m&Meta != 0
}

// IsHyper reports whether the Hyper modifier is set.
func (m KeyMod) IsHyper() bool {
	return m&Hyper != 0
}

// IsSuper reports whether the Super modifier is set.
func (m KeyMod) IsSuper() bool {
	return m&Super != 0
}

// HasCapsLock reports whether the CapsLock key is enabled.
func (m KeyMod) HasCapsLock() bool {
	return m&CapsLock != 0
}

// HasNumLock reports whether the NumLock key is enabled.
func (m KeyMod) HasNumLock() bool {
	return m&NumLock != 0
}

// HasScrollLock reports whether the ScrollLock key is enabled.
func (m KeyMod) HasScrollLock() bool {
	return m&ScrollLock != 0
}