Documentation
¶
Overview ¶
Package cbind provides tcell key event encoding, decoding and handling.
The NewConfiguration example demonstrates how to use cbind.
There are some limitations on reading keyboard input, which is explained in the tcell.EventKey documentation:
Index ¶
Examples ¶
Constants ¶
View Source
const ( LabelCtrl = "ctrl" LabelAlt = "alt" LabelMeta = "meta" LabelShift = "shift" )
Modifier labels
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration processes key events by mapping keys to event handlers.
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration returns a new input configuration.
Example ¶
Example of creating and using an input configuration.
// Create a new input configuration to store the keybinds. c := NewConfiguration() // Set keybind Alt+S. c.SetRune(tcell.ModAlt, 's', func(ev *tcell.EventKey) *tcell.EventKey { // Save return nil }) // Set keybind Alt+O. c.SetRune(tcell.ModAlt, 'o', func(ev *tcell.EventKey) *tcell.EventKey { // Open return nil }) // Set keybind Escape. c.SetKey(tcell.ModNone, tcell.KeyEscape, func(ev *tcell.EventKey) *tcell.EventKey { // Exit return nil }) // Before calling Application.Run, call Application.SetInputCapture: // app.SetInputCapture(c.Capture)
Output:
func (*Configuration) Capture ¶
func (c *Configuration) Capture(ev *tcell.EventKey) *tcell.EventKey
Capture handles key events.
Click to show internal directories.
Click to hide internal directories.