termui/README.md

83 lines
2.3 KiB
Markdown
Raw Normal View History

2015-02-03 07:09:27 -07:00
# termui
2015-02-08 10:07:18 -07:00
Go terminal dashboard. Inspired by [blessed-contrib](https://github.com/yaronn/blessed-contrib), but purely in Go.
2015-02-08 10:00:00 -07:00
Cross-platform, easy to compile, and fully-customizable.
__Demo:__
2015-02-08 10:08:48 -07:00
<img src="./example/screencast.gif" alt="demo" width="600">
2015-02-08 10:00:00 -07:00
## 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.
2015-02-08 10:07:18 -07:00
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).
2015-02-08 10:00:00 -07:00
`````go
import ui "github.com/gizak/termui" // <- ui shortcut, optional
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
2015-03-11 14:51:18 -06:00
p := ui.NewPar(":PRESS q TO QUIT DEMO")
2015-02-08 10:00:00 -07:00
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
2015-03-11 14:22:55 -06:00
_All_ colors in _all_ components _can_ be changed at _any_ time, while there provides some predefined color schemes:
2015-03-11 14:22:55 -06:00
```go
// 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:
2015-03-11 14:22:55 -06:00
<img src="./example/themedefault.tiff" alt="default" type="image/tiff" width="600">
The `helloworld` color scheme drops in some colors!
2015-03-11 14:22:55 -06:00
<img src="./example/themehelloworld.tiff" alt="helloworld" type="image/tiff" width="600">
2015-02-08 10:00:00 -07:00
## Widgets
_APIs are subject to change, docs will be added after 1 or 2 commits_
2015-02-08 10:00:00 -07:00
## GoDoc
[godoc](https://godoc.org/github.com/gizak/termui).
## License
This library is under the [MIT License](http://opensource.org/licenses/MIT)