termui/README.md

83 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
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()
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:51:43 -07:00
for e := range ui.PollEvents() {
2018-11-29 11:22:51 -07:00
if e.Type == ui.KeyboardEvent {
2018-11-29 16:51:43 -07:00
break
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)
2019-01-18 10:30:22 -07:00
[<img src="./_examples/paragraph.png" alt="paragraph" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/paragraph.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)
2019-01-18 10:30:22 -07:00
[<img src="./_examples/stackedbarchart.png" alt="stackedbarchart" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_examples/stackedbarchart.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)