Skip to content

Commit

Permalink
Added character support
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Vriesman <[email protected]>
  • Loading branch information
glvr182 committed Aug 5, 2019
1 parent 98ac2d2 commit 864552b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func must(keyStr string) {
func main() {
fmt.Println("The show calls:")
show("ctrl+a")
show("q")
show("ctrl+b")
show("MouseLeft")
show("ctrl+/, tab")
Expand Down
7 changes: 6 additions & 1 deletion keybinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,19 @@ var supportedKeybindings = map[string]gocui.Key{

// Key contains all relevant information about the key
type Key struct {
Value gocui.Key
Value interface{}
Modifier gocui.Modifier
Tokens []string
}

// Parse turns the input string into an actual Key.
// Returns an error when something goes wrong
func Parse(input string) (Key, error) {

if len(input) == 1 && unicode.IsLetter(rune(input[0])) {
return Key{rune(input[0]), gocui.ModNone, []string{input}}, nil
}

f := func(c rune) bool { return unicode.IsSpace(c) || c == '+' }
tokens := strings.FieldsFunc(input, f)
var normalizedTokens []string
Expand Down

2 comments on commit 864552b

@abitrolly
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to use that? For example in wagoodman/dive#352

@abitrolly
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3

Please sign in to comment.