Golang terminal dashboard
Go to file
gizak d6ab2b3d3c Add widgets demos
Fix trim bug in helper.go
Add todos
2015-03-13 13:20:17 -04:00
example Add widgets demos 2015-03-13 13:20:17 -04:00
.gitignore Initial commit 2015-02-03 09:09:27 -05:00
bar.go Add theme support 2015-03-11 16:15:59 -04:00
block.go Add theme support 2015-03-11 16:15:59 -04:00
box_others.go Add workaround for windows console 2015-03-12 16:59:07 +09:00
box_windows.go Add workaround for windows console 2015-03-12 16:59:07 +09:00
box.go Add workaround for windows console 2015-03-12 16:59:07 +09:00
chart_others.go Add workaround for windows console 2015-03-12 16:59:07 +09:00
chart_windows.go Add workaround for windows console 2015-03-12 16:59:07 +09:00
chart.go Merge pull request #2 from mattn/fix-runewidth 2015-03-13 00:24:36 -04:00
gauge.go Add theme support 2015-03-11 16:15:59 -04:00
helper_test.go Add P tag 2015-02-03 14:13:51 -05:00
helper.go Add widgets demos 2015-03-13 13:20:17 -04:00
LICENSE Initial commit 2015-02-03 09:09:27 -05:00
list.go Add theme support 2015-03-11 16:15:59 -04:00
p.go Add widgets demos 2015-03-13 13:20:17 -04:00
point.go Re-construct Point 2015-03-03 13:28:09 -05:00
README.md Add widgets demos 2015-03-13 13:20:17 -04:00
render.go Add theme support 2015-03-11 16:15:59 -04:00
sparkline.go Add widgets demos 2015-03-13 13:20:17 -04:00
theme.go Add theme support 2015-03-11 16:15:59 -04:00

termui

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

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

Demo:

demo

Installation

go get 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

Sparklines

Demo code

sparklines

GoDoc

godoc.

TODO

[1] Float layout

[2] Event system

License

This library is under the MIT License