termui/README.md

81 lines
3.1 KiB
Markdown
Raw Normal View History

2018-11-28 20:15:29 -07:00
# termui
2018-11-28 20:15:29 -07:00
[![Build Status](https://travis-ci.org/gizak/termui.svg?branch=master)](https://travis-ci.org/gizak/termui) [![Doc Status](https://godoc.org/github.com/gizak/termui?status.png)](https://godoc.org/github.com/gizak/termui)
2015-06-23 13:11:22 -06:00
2018-11-28 20:15:29 -07:00
<img src="./_examples/dashboard.gif" alt="demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.)" width="100%">
2018-11-28 20:15:29 -07:00
`termui` is a cross-platform, easy-to-compile, and fully-customizable terminal dashboard built on top of [termbox-go](https://github.com/nsf/termbox-go). It is inspired by [blessed-contrib](https://github.com/yaronn/blessed-contrib) and written purely in Go.
2015-02-08 10:00:00 -07:00
2015-10-27 13:24:29 -06:00
## Installation
2015-03-15 13:56:38 -06:00
2018-11-28 20:15:29 -07:00
It's recommended to install from the master branch:
2015-03-20 06:24:48 -06:00
2018-09-06 17:55:27 -06:00
```bash
2018-11-28 20:15:29 -07:00
go get -u github.com/gizak/termui@master
2018-09-06 17:55:27 -06:00
```
2015-03-20 06:24:48 -06:00
2018-11-28 20:15:29 -07:00
Note that termui is currently undergoing major API changes so be prepared for things to break if you upgrade.
2015-03-15 13:56:38 -06:00
2015-10-27 13:24:29 -06:00
## Usage
2015-02-08 10:00:00 -07:00
2018-11-28 20:15:29 -07:00
### Hello World
2015-02-08 10:00:00 -07:00
2018-09-06 17:55:27 -06:00
```go
2018-11-28 20:15:29 -07:00
import ui "github.com/gizak/termui"
2015-02-08 10:00:00 -07:00
2018-11-28 20:15:29 -07:00
func main() {
err := ui.Init()
if err != nil {
panic(err)
2015-02-08 10:00:00 -07:00
}
2018-11-28 20:15:29 -07:00
defer ui.Close()
2018-11-28 20:15:29 -07:00
p := ui.NewParagraph("Hello World")
ui.Render(p)
2015-10-27 13:29:37 -06:00
2018-11-28 20:15:29 -07:00
for {
e := <-ui.PollEvent()
switch e.ID {
case "q", "<C-c>":
return
2015-10-27 13:24:29 -06:00
}
2018-11-28 20:15:29 -07:00
}
}
2015-10-27 13:24:29 -06:00
```
2015-10-27 13:24:29 -06:00
### Widgets
2015-10-27 13:24:29 -06:00
Click image to see the corresponding demo codes.
2018-11-28 20:15:29 -07:00
[<img src="./_examples/barchart.png" alt="barchart" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/barchart.go)
2018-09-06 17:55:27 -06:00
[<img src="./_examples/gauge.png" alt="gauge" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/gauge.go)
[<img src="./_examples/linechart.png" alt="linechart" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/linechart.go)
2018-11-28 20:15:29 -07:00
[<img src="./_examples/list.png" alt="list" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/list.go)
[<img src="./_examples/paragraph.png" alt="paragraph" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/par.go)
2018-09-06 17:55:27 -06:00
[<img src="./_examples/sparklines.png" alt="sparklines" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/sparklines.go)
2018-11-28 20:15:29 -07:00
[<img src="./_examples/stackedbarchart.png" alt="stackedbarchart" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/mbarchart.go)
2018-09-06 17:55:27 -06:00
[<img src="./_examples/table.png" alt="table" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/table.go)
2015-02-08 10:00:00 -07:00
2018-11-28 20:15:29 -07:00
### Examples
Examples can be found in [\_examples](./_examples). Run with `go run _examples/...` or run all of them consecutively with `./scripts/run_examples.py`.
## Documentation
- [godoc](https://godoc.org/github.com/gizak/termui) for code documentation
- [wiki](https://github.com/gizak/termui/wiki) for general information
2015-02-08 10:00:00 -07:00
2018-11-28 20:15:29 -07:00
## Uses
2015-02-08 10:00:00 -07:00
2018-11-28 20:15:29 -07:00
- [go-ethereum/monitorcmd](https://github.com/ethereum/go-ethereum/blob/96116758d22ddbff4dbef2050d6b63a7b74502d8/cmd/geth/monitorcmd.go)
2018-11-28 20:15:29 -07:00
## Related Works
2018-11-28 20:15:29 -07:00
- [blessed-contrib](https://github.com/yaronn/blessed-contrib)
- [tui-rs](https://github.com/fdehau/tui-rs)
- [gocui](https://github.com/jroimartin/gocui)
2015-10-27 13:24:29 -06:00
2015-02-08 10:00:00 -07:00
## License
2018-09-06 17:55:27 -06:00
2015-02-08 10:00:00 -07:00
This library is under the [MIT License](http://opensource.org/licenses/MIT)