Skip to content

Commit c81715e

Browse files
authored
Merge pull request #103 from jesseduffield/remove-blacklist
Remove Gui.blacklist
2 parents 944dab3 + 15d569c commit c81715e

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

gui.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"context"
99
standardErrors "errors"
1010
"runtime"
11-
"slices"
1211
"strings"
1312
"sync"
1413
"time"
@@ -25,15 +24,6 @@ type OutputMode int
2524
const DOUBLE_CLICK_THRESHOLD = 500 * time.Millisecond
2625

2726
var (
28-
// ErrAlreadyBlacklisted is returned when the keybinding is already blacklisted.
29-
ErrAlreadyBlacklisted = standardErrors.New("keybind already blacklisted")
30-
31-
// ErrBlacklisted is returned when the keybinding being parsed / used is blacklisted.
32-
ErrBlacklisted = standardErrors.New("keybind blacklisted")
33-
34-
// ErrNotBlacklisted is returned when a keybinding being whitelisted is not blacklisted.
35-
ErrNotBlacklisted = standardErrors.New("keybind not blacklisted")
36-
3727
// ErrNoSuchKeybind is returned when the keybinding being parsed does not exist.
3828
ErrNoSuchKeybind = standardErrors.New("no such keybind")
3929

@@ -155,7 +145,6 @@ type Gui struct {
155145
maxX, maxY int
156146
outputMode OutputMode
157147
stop chan struct{}
158-
blacklist []Key
159148

160149
// BgColor and FgColor allow to configure the background and foreground
161150
// colors of the GUI.
@@ -573,10 +562,6 @@ func (g *Gui) SetKeybinding(viewname string, key any, mod Modifier, handler func
573562
return err
574563
}
575564

576-
if g.isBlacklisted(k) {
577-
return ErrBlacklisted
578-
}
579-
580565
kb = newKeybinding(viewname, k, ch, mod, handler)
581566
g.keybindings = append(g.keybindings, kb)
582567
return nil
@@ -632,26 +617,6 @@ func (g *Gui) SetViewClickBinding(binding *ViewMouseBinding) error {
632617
return nil
633618
}
634619

635-
// BlackListKeybinding adds a keybinding to the blacklist
636-
func (g *Gui) BlacklistKeybinding(k Key) error {
637-
if slices.Contains(g.blacklist, k) {
638-
return ErrAlreadyBlacklisted
639-
}
640-
g.blacklist = append(g.blacklist, k)
641-
return nil
642-
}
643-
644-
// WhiteListKeybinding removes a keybinding from the blacklist
645-
func (g *Gui) WhitelistKeybinding(k Key) error {
646-
for i, j := range g.blacklist {
647-
if j == k {
648-
g.blacklist = append(g.blacklist[:i], g.blacklist[i+1:]...)
649-
return nil
650-
}
651-
}
652-
return ErrNotBlacklisted
653-
}
654-
655620
func (g *Gui) SetFocusHandler(handler func(bool) error) {
656621
g.focusHandler = handler
657622
}
@@ -1616,10 +1581,6 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) error {
16161581

16171582
// execKeybinding executes a given keybinding
16181583
func (g *Gui) execKeybinding(v *View, kb *keybinding) error {
1619-
if g.isBlacklisted(kb.key) {
1620-
return nil
1621-
}
1622-
16231584
if err := kb.handler(g, v); err != nil {
16241585
return err
16251586
}
@@ -1665,11 +1626,6 @@ func (g *Gui) StartTicking(ctx context.Context) {
16651626
}()
16661627
}
16671628

1668-
// isBlacklisted reports whether the key is blacklisted
1669-
func (g *Gui) isBlacklisted(k Key) bool {
1670-
return slices.Contains(g.blacklist, k)
1671-
}
1672-
16731629
func (g *Gui) Suspend() error {
16741630
g.suspendedMutex.Lock()
16751631
defer g.suspendedMutex.Unlock()

0 commit comments

Comments
 (0)