Go to file
Roi Martin 7ffb37ef13 Add example for mask 2016-04-20 14:34:09 +02:00
_examples Add example for mask 2016-04-20 14:34:09 +02: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 Update delete.go to dynamic.go in readme 2016-04-19 10:35:13 +01:00
attribute.go Full mouse support. Add mouse example. Make golint happy. 2016-01-23 16:07:42 +01:00
doc.go Minor fixes in doc 2016-02-01 15:08:39 +01:00
edit.go Editor refactoring. Add doc. Simplify _examples. 2016-01-30 02:36:10 +01:00
gui.go Do not show cursor when it's out of screen 2016-02-07 16:58:15 +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 example for mask 2016-04-20 14:34:09 +02:00

README.md

GOCUI - Go Console User Interface

GoDoc

Minimalist Go package aimed at creating Console User Interfaces.

Features

  • Minimalist API.
  • Views (the "windows" in the GUI) implement the interface io.ReadWriter.
  • Support for overlapping views.
  • The GUI can be modified at runtime (concurrent-safe).
  • Global and view-level keybindings.
  • Mouse support.
  • Customizable edition mode.

Installation

Execute:

$ go get github.com/jroimartin/gocui

Documentation

Execute:

$ godoc github.com/jroimartin/gocui

Or visit godoc.org to read it online.

Example

package main

import (
	"fmt"
	"log"

	"github.com/jroimartin/gocui"
)

func main() {
	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)
	}

	if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
		log.Panicln(err)
	}
}

func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("hello", maxX/2-7, maxY/2, maxX/2+7, maxY/2+2); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		fmt.Fprintln(v, "Hello world!")
	}
	return nil
}

func quit(g *gocui.Gui, v *gocui.View) error {
	return gocui.ErrQuit
}

Screenshots

_examples/demo.go:

_examples/demo.go

_examples/dynamic.go:

_examples/dynamic.go