2018-11-28 20:15:29 -07:00
# termui
2015-03-20 19:11:58 -06:00
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%" >
2015-03-20 19:11:58 -06:00
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
2018-11-28 22:13:29 -07:00
**termui is currently undergoing some API changes so make sure to check the changelog when upgrading**
2015-10-27 13:24:29 -06:00
## Installation
2015-03-15 13:56:38 -06:00
2018-11-28 22:44:42 -07:00
Installing from the master branch is recommended:
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
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 21:12:36 -07:00
package main
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()
2015-03-11 14:15:59 -06:00
2018-11-29 11:22:51 -07:00
p := ui.NewParagraph("Hello World!")
p.Width = 25
p.Height = 5
2018-11-28 20:15:29 -07:00
ui.Render(p)
2015-10-27 13:29:37 -06:00
2018-11-29 16:32:42 -07:00
uiEvents := ui.PollEvents()
2018-11-28 20:15:29 -07:00
for {
2018-11-29 16:32:42 -07:00
e := < -uiEvents
2018-11-29 11:22:51 -07:00
if e.Type == ui.KeyboardEvent {
2018-11-28 20:15:29 -07:00
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-04-27 18:27:11 -06:00
2015-10-27 13:24:29 -06:00
### Widgets
2015-03-13 11:20:17 -06:00
2015-10-27 13:24:29 -06:00
Click image to see the corresponding demo codes.
2015-03-13 11:20:17 -06:00
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 )
2015-03-13 11:20:17 -06:00
2018-11-28 20:15:29 -07:00
## Related Works
2015-03-13 11:20:17 -06:00
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 )