Documentation
¶
Overview ¶
Package ttymap is a utility to map keypresses (runes) to callbacks for CLI applications. The rune pressed is sent to the callback, but can be ignored.
Example ¶
var (
runeP rune
runeQ rune
)
z := New()
go z.Run() // launch it async
// closer stops Gnome and Vinz Clortho
closer := func(r rune) {
// close(someChan) or something.Stop() to shut your app down
z.Close() // Stupid important that this gets called, but waiting for a defer is generally late.
}
pause := func(r rune) {
// pause your app?
}
z.Upsert(runeP, pause) // toggles pause status
z.Upsert(runeQ, closer) // closes all the things
// start your app up
// z.Run() // blocks
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TtyMap ¶
type TtyMap struct {
// contains filtered or unexported fields
}
TtyMap is cool, eh?
func (*TtyMap) Close ¶
func (z *TtyMap) Close()
Close will signal the Run() loop to end, and close the TTY. You must create a New() if you want to continue mapping the keypresses.
func (*TtyMap) Remove ¶
Remove will delete the key denoted by the specified rune if it exists. This function is safe to call across goros. This function is safe to call if one is uncertain if the rune has been Upsertted previously.
Click to show internal directories.
Click to hide internal directories.