Skip to content

Commit

Permalink
Add module awesome-gocui/keybinding
Browse files Browse the repository at this point in the history
  • Loading branch information
markruler committed Dec 27, 2020
1 parent 5e9380d commit b310bdb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 192 deletions.
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -6,6 +6,7 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/awesome-gocui/gocui v0.6.0
github.com/awesome-gocui/keybinding v1.0.0
github.com/cespare/xxhash v1.1.0
github.com/docker/cli v0.0.0-20190906153656-016a3232168d
github.com/docker/distribution v2.7.1+incompatible // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Expand Up @@ -10,8 +10,11 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/awesome-gocui/gocui v0.5.0/go.mod h1:1QikxFaPhe2frKeKvEwZEIGia3haiOxOUXKinrv17mA=
github.com/awesome-gocui/gocui v0.6.0 h1:hhDJiQC12tEsJNJ+iZBBVaSSLFYo9llFuYpQlL5JZVI=
github.com/awesome-gocui/gocui v0.6.0/go.mod h1:1QikxFaPhe2frKeKvEwZEIGia3haiOxOUXKinrv17mA=
github.com/awesome-gocui/keybinding v1.0.0 h1:CrnjCfEhWpjcqIQUan9IllaXeRGELdwfjeUmY7ljbng=
github.com/awesome-gocui/keybinding v1.0.0/go.mod h1:z0TyCwIhaT97yU+becTse8Dqh2CvYT0FLw0R0uTk0ag=
github.com/awesome-gocui/termbox-go v0.0.0-20190427202837-c0aef3d18bcc h1:wGNpKcHU8Aadr9yOzsT3GEsFLS7HQu8HxQIomnekqf0=
github.com/awesome-gocui/termbox-go v0.0.0-20190427202837-c0aef3d18bcc/go.mod h1:tOy3o5Nf1bA17mnK4W41gD7PS3u4Cv0P0pqFcoWMy8s=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
12 changes: 6 additions & 6 deletions runtime/ui/key/binding.go
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"

"github.com/awesome-gocui/gocui"
"github.com/awesome-gocui/keybinding"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/wagoodman/dive/runtime/ui/format"
// "github.com/wagoodman/keybinding"
)

type BindingInfo struct {
Expand All @@ -20,7 +20,7 @@ type BindingInfo struct {
}

type Binding struct {
key []Key
key []keybinding.Key
displayName string
selectedFn func() bool
actionFn func() error
Expand Down Expand Up @@ -53,11 +53,11 @@ func GenerateBindings(gui *gocui.Gui, influence string, infos []BindingInfo) ([]
}

func NewBinding(gui *gocui.Gui, influence string, key gocui.Key, mod gocui.Modifier, displayName string, actionFn func() error) (*Binding, error) {
return newBinding(gui, influence, []Key{{Value: key, Modifier: mod}}, displayName, actionFn)
return newBinding(gui, influence, []keybinding.Key{{Value: key, Modifier: mod}}, displayName, actionFn)
}

func NewBindingFromConfig(gui *gocui.Gui, influence string, configKeys []string, displayName string, actionFn func() error) (*Binding, error) {
var parsedKeys []Key
var parsedKeys []keybinding.Key
for _, configKey := range configKeys {
bindStr := viper.GetString(configKey)
if bindStr == "" {
Expand All @@ -66,7 +66,7 @@ func NewBindingFromConfig(gui *gocui.Gui, influence string, configKeys []string,
}
logrus.Debugf("parsing keybinding '%s' --> '%s'", configKey, bindStr)

keys, err := ParseAll(bindStr)
keys, err := keybinding.ParseAll(bindStr)
if err != nil {
return nil, err
}
Expand All @@ -83,7 +83,7 @@ func NewBindingFromConfig(gui *gocui.Gui, influence string, configKeys []string,
return newBinding(gui, influence, parsedKeys, displayName, actionFn)
}

func newBinding(gui *gocui.Gui, influence string, keys []Key, displayName string, actionFn func() error) (*Binding, error) {
func newBinding(gui *gocui.Gui, influence string, keys []keybinding.Key, displayName string, actionFn func() error) (*Binding, error) {
binding := &Binding{
key: keys,
displayName: displayName,
Expand Down
186 changes: 0 additions & 186 deletions runtime/ui/key/key.go

This file was deleted.

0 comments on commit b310bdb

Please sign in to comment.