Update README

This commit is contained in:
gizak 2015-02-08 12:00:00 -05:00
parent 92a301a247
commit 74d3a0a37a
3 changed files with 64 additions and 1 deletions

View File

@ -1,2 +1,62 @@
# termui
Go terminal rich user interface
Go terminal dashboard, inspired by [blessed-contrib](https://github.com/yaronn/blessed-contrib), but purely in Go.
Cross-platform, easy to compile, and fully-customizable.
__Demo:__
<img src="https://github.com/gizak/termui/tree/master/example/screencast.gif" alt="demo" width="800">
## Installation
go get github.com/gizak/termui
## Usage
Each component's layout is a bit like HTML block, which has border and padding. The `Border` property can be chosen to hide or display (with its border label), when it comes to display, in this case the space it takes is counted as padding space (i.e. `PaddingTop=PaddingBottom=PaddingLeft=PaddingRight=1`).
`````go
import ui "github.com/gizak/termui" // <- ui shortcut, optional
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
p := ui.NewP(":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 as a feature...), `Render(Renderer...)` renders its args from left to right (i.e. each component's weight is arising from left to right).
## Widgets
_APIs are subject to change, docs will be added after 2 or 3 commits_
## GoDoc
[godoc](https://godoc.org/github.com/gizak/termui).
## License
This library is under the [MIT License](http://opensource.org/licenses/MIT)

View File

@ -266,6 +266,9 @@ func (lc *LineChart) plotAxes() []Point {
func (lc *LineChart) Buffer() []Point {
ps := lc.Block.Buffer()
if lc.Data == nil || len(lc.Data) == 0 {
return ps
}
lc.calcLayout()
ps = append(ps, lc.plotAxes()...)

BIN
example/screencast.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB