Golang terminal dashboard
Go to file
2015-08-04 12:14:56 -04:00
example Fix https://github.com/gizak/termui/issues/43 2015-05-05 10:55:35 -04:00
.gitignore Initial commit 2015-02-03 09:09:27 -05:00
.travis.yml Update travis config 2015-03-20 13:06:29 -04:00
bar.go Fix an OutofIndex Panic on empty bargraphs and introduce SetMax() 2015-04-15 16:50:49 -04:00
block_test.go Fix #23 by implementing Block.InnerBounds() and associated test. 2015-04-09 10:19:43 +08:00
block.go Fix https://github.com/gizak/termui/issues/18 2015-04-09 16:40:49 -04:00
box_others.go Add build tags for examples 2015-03-20 16:21:50 -04:00
box_windows.go Add build tags for examples 2015-03-20 16:21:50 -04:00
box.go Fix https://github.com/gizak/termui/issues/10 2015-03-25 18:04:15 -04:00
canvas_test.go Add braille canvas 2015-03-26 18:11:41 -04:00
canvas.go Add braille canvas 2015-03-26 18:11:41 -04:00
chart_others.go Add build tags for examples 2015-03-20 16:21:50 -04:00
chart_windows.go Add build tags for examples 2015-03-20 16:21:50 -04:00
chart.go Fix https://github.com/gizak/termui/issues/9 2015-04-10 10:40:57 -04:00
doc.go Add docs 2015-03-24 17:16:43 -04:00
events_test.go Fixes unsafe pointer madness. 2015-04-15 13:49:31 +02:00
events.go Fix 'termbox.Event has no field or method N' 2015-08-04 12:14:56 -04:00
gauge.go Fixed a bug which would render the background color of the label in the gauge widget incorrectly. 2015-04-23 12:19:21 +02:00
grid_test.go Fix Grid test 2015-05-05 11:19:08 -04:00
grid.go Fix https://github.com/gizak/termui/issues/42 2015-05-05 11:08:45 -04:00
helper_test.go Fix https://github.com/gizak/termui/issues/10 2015-03-25 18:04:15 -04:00
helper.go Implement Multi-colored/Stacked barGraph 2015-04-17 18:03:22 -04:00
LICENSE Initial commit 2015-02-03 09:09:27 -05:00
list.go Fix https://github.com/gizak/termui/issues/18 2015-04-09 16:40:49 -04:00
mbar.go Add Code to display Y-Axis Scale 2015-04-27 20:28:25 -04:00
p.go Fix https://github.com/gizak/termui/issues/18 2015-04-09 16:40:49 -04:00
point.go Add docs 2015-03-24 17:16:43 -04:00
README.md Fix 'termbox.Event has no field or method N' 2015-08-04 12:14:56 -04:00
render.go Fix https://github.com/gizak/termui/issues/43 2015-05-05 10:55:35 -04:00
sparkline.go Make sparkline to use last N datapoints 2015-04-26 17:35:57 +03:00
theme.go Implement Multi-colored/Stacked barGraph 2015-04-17 18:03:22 -04:00

termui Build Status Doc Status

Update 23/06/2015

Pull requests and master branch are freezing, waiting for merging from refactoring branch.

Notice

termui comes with ABSOLUTELY NO WARRANTY, and there is a breaking change coming up (see refactoring branch) which will change the Bufferer interface and many others. These changes reduce calculation overhead and introduce a new drawing buffer with better capacibilities. We will step into the next stage (call it beta) after merging these changes.

Introduction

Go terminal dashboard. Inspired by blessed-contrib, but purely in Go.

Cross-platform, easy to compile, and fully-customizable.

Demo: (cast under osx 10.10; Terminal.app; Menlo Regular 12pt.)

demo

Grid layout:

Expressive syntax, using 12 columns grid system

	import ui "github.com/gizak/termui"
	// init and create widgets...

	// build
	ui.Body.AddRows(
		ui.NewRow(
			ui.NewCol(6, 0, widget0),
			ui.NewCol(6, 0, widget1)),
		ui.NewRow(
			ui.NewCol(3, 0, widget2),
			ui.NewCol(3, 0, widget30, widget31, widget32),
			ui.NewCol(6, 0, widget4)))

	// calculate layout
	ui.Body.Align()

	ui.Render(ui.Body)

demo code:

grid

Installation

go get -u github.com/gizak/termui

Usage

Each component's layout is a bit like HTML block (box model), which has border and padding.

The Border property can be chosen to hide or display (with its border label), when it comes to display, the label takes 1 padding space (i.e. in css: padding: 1;, innerHeight and innerWidth therefore shrunk by 1).

	import ui "github.com/gizak/termui" // <- ui shortcut, optional

	func main() {
		err := ui.Init()
		if err != nil {
			panic(err)
		}
		defer ui.Close()

		p := ui.NewPar(":PRESS q TO QUIT DEMO")
		p.Height = 3
		p.Width = 50
		p.TextFgColor = ui.ColorWhite
		p.Border.Label = "Text Box"
		p.Border.FgColor = ui.ColorCyan

		g := ui.NewGauge()
		g.Percent = 50
		g.Width = 50
		g.Height = 3
		g.Y = 11
		g.Border.Label = "Gauge"
		g.BarColor = ui.ColorRed
		g.Border.FgColor = ui.ColorWhite
		g.Border.LabelFgColor = ui.ColorCyan

		ui.Render(p, g)

		// event handler...
	}

Note that components can be overlapped (I'd rather call this a feature...), Render(rs ...Renderer) renders its args from left to right (i.e. each component's weight is arising from left to right).

Themes

All colors in all components can be changed at any time, while there provides some predefined color schemes:

// for now there are only two themes: default and helloworld
termui.UseTheme("helloworld")

// create components...

The default theme's settings depend on the user's terminal color scheme, which is saying if your terminal default font color is white and background is white, it will be like:

default

The helloworld color scheme drops in some colors!

helloworld

Widgets

Par

demo code

par

List

demo code

list

Gauge

demo code

gauge

Line Chart

demo code

linechart

Bar Chart

demo code

barchart

Mult-Bar / Stacked-Bar Chart

demo code

barchart

Sparklines

demo code

sparklines

GoDoc

godoc

TODO

  • Grid layout
  • Event system
  • Canvas widget
  • Refine APIs
  • Focusable widgets

License

This library is under the MIT License