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,542 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 (
	ModShift KeyMod = 1 << iota
	ModAlt
	ModCtrl
	ModMeta

	// 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.

	ModHyper
	ModSuper // Windows/Command keys

	// These are key lock states.

	ModCapsLock
	ModNumLock
	ModScrollLock // Defined in Windows API only
)

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

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

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

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

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

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

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

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

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