Open abitrolly opened 4 years ago
To get to the root of the problem, I had to explore the code a bit. keybinding.Key
object is a struct which includes gocui.Key
object.
gocui.Key
is just an alias to termbox.Key
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/keybinding.go#L44
termbox.Key
is uint16
.
https://github.com/nsf/termbox-go/blob/93860e16131719fa9722e7c448dbf8c0e3210a0d/api_common.go#L11
Now termbox.Key
is used in termbox.Event
struct with the interesting comment
type Event struct {
Type EventType // one of Event* constants
Mod Modifier // one of Mod* constants or 0
Key Key // one of Key* constants, invalid if 'Ch' is not 0
Ch rune // a unicode character
...
There is only one event - EventKey
- related to keyboard input. When parsing events, if input stream contains a simple character (not prefixed with escape sequence) , termbox
doesn't assign event.Key
field, and the character goes into event.Ch
.
termbox
examples process event.Key
for key combinations and event.Ch
for letters separately.
gocui.newKeybinding
also accepts key Key, ch rune
as separate parameters.
https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/keybinding.go#L19
keybinding.Key
struct however, has no placeholder for ch rune
. keybinding.Parse
method which should return Key
doesn't handle chars and doesn't map them to any Key
values.
Apparently, single key bindings are not supported, and no error is reported for them.
https://github.com/wagoodman/dive/issues/129#issuecomment-568902936