Go to file
Roi Martin b5f65e10ad Minor refactoring 2016-01-26 00:48:12 +01:00
_examples Minor refactoring 2016-01-26 00:48:12 +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 Fix typo in LICENSE 2014-12-25 11:58:41 +01:00
README.md Full mouse support. Add mouse example. Make golint happy. 2016-01-23 16:07:42 +01:00
attribute.go Full mouse support. Add mouse example. Make golint happy. 2016-01-23 16:07:42 +01:00
doc.go Full mouse support. Add mouse example. Make golint happy. 2016-01-23 16:07:42 +01:00
edit.go Full mouse support. Add mouse example. Make golint happy. 2016-01-23 16:07:42 +01:00
gui.go Minor refactoring 2016-01-26 00:48:12 +01:00
keybinding.go Add Gui.Execute to safely update the GUI from goroutines. 2016-01-26 00:06:54 +01:00
view.go Add method View.ViewBuffer 2015-08-16 18:08:34 +02:00

README.md

GOCUI - Go Console User Interface

Minimalist Go package aimed at creating Console User Interfaces.

Features

  • Minimalist API.
  • Views (the "windows" in the GUI) implement the interface io.Writer.
  • Support for overlapping views.
  • The GUI can be modified at runtime.
  • Global and view-level keybindings.
  • Edit mode.

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.ErrUnknownView {
			return err
		}
		fmt.Fprintln(v, "This is an example")
	}
	return nil
}
func quit(g *gocui.Gui, v *gocui.View) error {
	return gocui.ErrQuit
}
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, gocui.ModNone, quit); err != nil {
		log.Panicln(err)
	}
	err = g.MainLoop()
	if err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}

Screenshots

_examples/demo.go:

_examples/demo.go

_examples/delete.go:

_examples/delete.go

Installation

go get github.com/jroimartin/gocui

Documentation

godoc github.com/jroimartin/gocui