2018-11-29 11:15:29 +08:00
# termui
2015-03-21 09:11:58 +08:00
2018-11-29 11:15:29 +08: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-24 03:11:22 +08:00
2018-11-29 11:15:29 +08:00
< img src = "./_examples/dashboard.gif" alt = "demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.)" width = "100%" >
2015-03-21 09:11:58 +08:00
2018-11-29 11:15:29 +08: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-09 01:00:00 +08:00
2015-10-28 03:24:29 +08:00
## Installation
2015-03-16 03:56:38 +08:00
2018-11-29 11:15:29 +08:00
It's recommended to install from the master branch:
2015-03-20 20:24:48 +08:00
2018-09-07 07:55:27 +08:00
```bash
2018-11-29 11:15:29 +08:00
go get -u github.com/gizak/termui@master
2018-09-07 07:55:27 +08:00
```
2015-03-20 20:24:48 +08:00
2018-11-29 12:50:00 +08:00
Note that termui is currently undergoing some API changes so be prepared for things to break if you upgrade.
2015-03-16 03:56:38 +08:00
2015-10-28 03:24:29 +08:00
## Usage
2015-02-09 01:00:00 +08:00
2018-11-29 11:15:29 +08:00
### Hello World
2015-02-09 01:00:00 +08:00
2018-09-07 07:55:27 +08:00
```go
2018-11-29 12:12:36 +08:00
package main
2018-11-29 11:15:29 +08:00
import ui "github.com/gizak/termui"
2015-02-09 01:00:00 +08:00
2018-11-29 11:15:29 +08:00
func main() {
err := ui.Init()
if err != nil {
panic(err)
2015-02-09 01:00:00 +08:00
}
2018-11-29 11:15:29 +08:00
defer ui.Close()
2015-03-12 04:15:59 +08:00
2018-11-29 11:15:29 +08:00
p := ui.NewParagraph("Hello World")
ui.Render(p)
2015-10-28 03:29:37 +08:00
2018-11-29 11:15:29 +08:00
for {
e := < -ui.PollEvent ( )
switch e.ID {
case "q", "< C-c > ":
return
2015-10-28 03:24:29 +08:00
}
2018-11-29 11:15:29 +08:00
}
}
2015-10-28 03:24:29 +08:00
```
2015-04-28 08:27:11 +08:00
2015-10-28 03:24:29 +08:00
### Widgets
2015-03-14 01:20:17 +08:00
2015-10-28 03:24:29 +08:00
Click image to see the corresponding demo codes.
2015-03-14 01:20:17 +08:00
2018-11-29 11:15:29 +08: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-07 07:55:27 +08: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-29 11:15:29 +08: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-07 07:55:27 +08: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-29 11:15:29 +08: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-07 07:55:27 +08: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-09 01:00:00 +08:00
2018-11-29 11:15:29 +08: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-09 01:00:00 +08:00
2018-11-29 11:15:29 +08:00
## Uses
2015-02-09 01:00:00 +08:00
2018-11-29 11:15:29 +08:00
- [go-ethereum/monitorcmd ](https://github.com/ethereum/go-ethereum/blob/96116758d22ddbff4dbef2050d6b63a7b74502d8/cmd/geth/monitorcmd.go )
2015-03-14 01:20:17 +08:00
2018-11-29 11:15:29 +08:00
## Related Works
2015-03-14 01:20:17 +08:00
2018-11-29 11:15:29 +08: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-28 03:24:29 +08:00
2015-02-09 01:00:00 +08:00
## License
2018-09-07 07:55:27 +08:00
2015-02-09 01:00:00 +08:00
This library is under the [MIT License ](http://opensource.org/licenses/MIT )