Skip to content

Commit

Permalink
Better keybinding matching
Browse files Browse the repository at this point in the history
  • Loading branch information
mjarkk committed Nov 23, 2019
1 parent 85bbede commit 080bc82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions _examples/keybinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"log"

"github.com/awesome-gocui/gocui"
"github.com/gdamore/tcell"
)

// layout generates the view
Expand Down Expand Up @@ -31,7 +32,7 @@ func quit(_ *gocui.Gui, _ *gocui.View) error {

func main() {
// Create a gui
g, err := gocui.NewGui(gocui.OutputNormal, false)
g, err := gocui.NewGui(false)
if err != nil {
log.Panicln(err)
}
Expand All @@ -55,13 +56,13 @@ func main() {

// We can blacklist a keybinding.
// This allows us to prevent setting the keybinding.
if err := g.BlacklistKeybinding(gocui.KeyCtrlC); err != nil {
if err := g.BlacklistKeybinding(tcell.KeyCtrlC); err != nil {
log.Panic(err)
}

// If for some reason you want to whitelist the keybinding,
// you can allow it again by calling g.WhitelistKeybinding.
if err := g.WhitelistKeybinding(gocui.KeyCtrlC); err != nil {
if err := g.WhitelistKeybinding(tcell.KeyCtrlC); err != nil {
log.Panic(err)
}

Expand Down
3 changes: 2 additions & 1 deletion keybinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func Parse(input string) (interface{}, tcell.ModMask, error) {
exist := false
var key tcell.Key
for mapKey, name := range tcell.KeyNames {
if name == strings.Join(cleaned, "") {
if name == strings.Join(cleaned, "-") {
key = mapKey
exist = true
break
}
}
Expand Down

0 comments on commit 080bc82

Please sign in to comment.