From 425741d93ec80bd2af584fd89466c23cacd7212c Mon Sep 17 00:00:00 2001 From: "Roi Martin (@nibble_ds)" Date: Mon, 6 Jan 2014 01:23:18 +0100 Subject: [PATCH] Update demos with keybindings --- _demos/demo1.go | 8 ++++++++ _demos/demo3.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/_demos/demo1.go b/_demos/demo1.go index ac69be9..eacff36 100644 --- a/_demos/demo1.go +++ b/_demos/demo1.go @@ -38,6 +38,10 @@ func layout(g *gocui.Gui) error { return nil } +func quit(g *gocui.Gui, v *gocui.View) error { + return gocui.ErrorQuit +} + func main() { var err error @@ -49,6 +53,10 @@ func main() { g.Layout = layout + if err := g.SetKeybinding("", gocui.KeyCtrlC, 0, quit); err != nil { + log.Panicln(err) + } + err = g.MainLoop() if err != nil && err != gocui.ErrorQuit { log.Panicln(err) diff --git a/_demos/demo3.go b/_demos/demo3.go index 3b70df6..94efa6c 100644 --- a/_demos/demo3.go +++ b/_demos/demo3.go @@ -20,6 +20,10 @@ func layout(g *gocui.Gui) error { return nil } +func quit(g *gocui.Gui, v *gocui.View) error { + return gocui.ErrorQuit +} + func main() { var err error @@ -31,6 +35,10 @@ func main() { g.Layout = layout + if err := g.SetKeybinding("", gocui.KeyCtrlC, 0, quit); err != nil { + log.Panicln(err) + } + err = g.MainLoop() if err != nil && err != gocui.ErrorQuit { log.Panicln(err)