Skip to content

Commit

Permalink
fix(input): rename keyMod modifier functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jun 3, 2024
1 parent e5176ed commit f37319a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions input/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,22 @@ func (k KeyUpEvent) String() string {
// "shift+ctrl+alt+a".
func (k Key) String() string {
var s string
if k.Mod.IsCtrl() && k.Sym != KeyLeftCtrl && k.Sym != KeyRightCtrl {
if k.Mod.HasCtrl() && k.Sym != KeyLeftCtrl && k.Sym != KeyRightCtrl {
s += "ctrl+"
}
if k.Mod.IsAlt() && k.Sym != KeyLeftAlt && k.Sym != KeyRightAlt {
if k.Mod.HasAlt() && k.Sym != KeyLeftAlt && k.Sym != KeyRightAlt {
s += "alt+"
}
if k.Mod.IsShift() && k.Sym != KeyLeftShift && k.Sym != KeyRightShift {
if k.Mod.HasShift() && k.Sym != KeyLeftShift && k.Sym != KeyRightShift {
s += "shift+"
}
if k.Mod.IsMeta() && k.Sym != KeyLeftMeta && k.Sym != KeyRightMeta {
if k.Mod.HasMeta() && k.Sym != KeyLeftMeta && k.Sym != KeyRightMeta {
s += "meta+"
}
if k.Mod.IsHyper() && k.Sym != KeyLeftHyper && k.Sym != KeyRightHyper {
if k.Mod.HasHyper() && k.Sym != KeyLeftHyper && k.Sym != KeyRightHyper {
s += "hyper+"
}
if k.Mod.IsSuper() && k.Sym != KeyLeftSuper && k.Sym != KeyRightSuper {
if k.Mod.HasSuper() && k.Sym != KeyLeftSuper && k.Sym != KeyRightSuper {
s += "super+"
}

Expand Down
24 changes: 12 additions & 12 deletions input/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@ const (
ScrollLock // Defined in Windows API only
)

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

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

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

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

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

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

Expand Down
6 changes: 3 additions & 3 deletions input/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ type Mouse struct {

// String implements fmt.Stringer.
func (m Mouse) String() (s string) {
if m.Mod.IsCtrl() {
if m.Mod.HasCtrl() {
s += "ctrl+"
}
if m.Mod.IsAlt() {
if m.Mod.HasAlt() {
s += "alt+"
}
if m.Mod.IsShift() {
if m.Mod.HasShift() {
s += "shift+"
}

Expand Down
2 changes: 1 addition & 1 deletion input/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func ParseSequence(buf []byte) (n int, e Event) {
return parseApc(buf)
default:
n, e := ParseSequence(buf[1:])
if k, ok := e.(KeyDownEvent); ok && !k.Mod.IsAlt() {
if k, ok := e.(KeyDownEvent); ok && !k.Mod.HasAlt() {
k.Mod |= Alt
return n + 1, k
}
Expand Down

0 comments on commit f37319a

Please sign in to comment.