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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.