Please visit https://code.rocketnine.space/tslocum/cbind
cbind
Key event handling library for tcell
Features
- Set
KeyEvent
handlers - Encode and decode
KeyEvent
s as human-readable strings
Usage
c := NewConfiguration()
handleSave := func(ev *tcell.EventKey) *tcell.EventKey {
return nil
}
handleOpen := func(ev *tcell.EventKey) *tcell.EventKey {
return nil
}
handleExit := func(ev *tcell.EventKey) *tcell.EventKey {
return nil
}
if err := c.Set("Alt+s", handleSave); err != nil {
log.Fatalf("failed to set keybind: %s", err)
}
c.SetRune(tcell.ModAlt, 'o', handleOpen)
c.SetKey(tcell.ModNone, tcell.KeyEscape, handleExit)
app.SetInputCapture(c.Capture)
Documentation
Documentation is available via gdooc.
The utility program whichkeybind
is available to determine and validate key combinations.
go get code.rocketnine.space/tslocum/cbind/whichkeybind
Support
Please share issues and suggestions here.