Go to file
Roi Martin (@nibble_ds) 46b1452e71 Simplify demo2. Add Gui.CurrentView(). Fix keybindings 2014-01-27 22:41:58 +01:00
_demos Simplify demo2. Add Gui.CurrentView(). Fix keybindings 2014-01-27 22:41:58 +01:00
.gitignore Initial commit 2013-12-27 21:36:26 +01:00
AUTHORS Add LICENSE/AUTHORS headers and files 2014-01-14 20:11:12 +01:00
LICENSE Add LICENSE/AUTHORS headers and files 2014-01-14 20:11:12 +01:00
README.md Update README.md 2014-01-19 17:42:51 +01:00
attribute.go Add API documentation 2014-01-19 17:03:52 +01:00
doc.go Add example to documentation 2014-01-19 17:23:11 +01:00
edit.go Refactoring of edit functions 2014-01-23 21:26:53 +01:00
gui.go Simplify demo2. Add Gui.CurrentView(). Fix keybindings 2014-01-27 22:41:58 +01:00
keybinding.go Add API documentation 2014-01-19 17:03:52 +01:00
view.go Fix View.Word() 2014-01-23 23:42:52 +01:00

README.md

GOCUI - Go Console User Interface

Minimalist Go library aimed at creating Console User Interfaces.

Installation

go get github.com/jroimartin/gocui

Documentation

godoc github.com/jroimartin/gocui

Example

func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("center", maxX/2-10, maxY/2, maxX/2+10, maxY/2+2); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		fmt.Fprintln(v, "This is an example")
	}
	return nil
}
func quit(g *gocui.Gui, v *gocui.View) error {
	return gocui.ErrorQuit
}
func main() {
	var err error
	g := gocui.NewGui()
	if err := g.Init(); err != nil {
		log.Panicln(err)
	}
	defer g.Close()
	g.SetLayout(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)
	}
}