Socket
Socket
Sign inDemoInstall

code.rocketnine.space/tslocum/cbind

Package Overview
Dependencies
6
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    code.rocketnine.space/tslocum/cbind

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: https://godoc.org/github.com/gdamore/tcell#EventKey


Version published

Readme

Source

!!! cbind has moved to code.rocketnine.space !!!

Please visit https://code.rocketnine.space/tslocum/cbind


cbind

GoDoc Donate

Key event handling library for tcell

Features

  • Set KeyEvent handlers
  • Encode and decode KeyEvents as human-readable strings

Usage

// Create a new input configuration to store the key bindings.
c := NewConfiguration()

// Define save event handler.
handleSave := func(ev *tcell.EventKey) *tcell.EventKey {
    return nil
}

// Define open event handler.
handleOpen := func(ev *tcell.EventKey) *tcell.EventKey {
    return nil
}

// Define exit event handler.
handleExit := func(ev *tcell.EventKey) *tcell.EventKey {
    return nil
}

// Bind Alt+s.
if err := c.Set("Alt+s", handleSave); err != nil {
    log.Fatalf("failed to set keybind: %s", err)
}

// Bind Alt+o.
c.SetRune(tcell.ModAlt, 'o', handleOpen)

// Bind Escape.
c.SetKey(tcell.ModNone, tcell.KeyEscape, handleExit)

// Capture input. This will differ based on the framework in use (if any).
// When using tview or cview, call Application.SetInputCapture before calling
// Application.Run.
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.

FAQs

Last updated on 28 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc