termui/README.md

84 lines
3.1 KiB
Markdown
Raw Normal View History

2018-11-29 03:15:29 +00:00
# termui
2018-11-29 03:15:29 +00: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 19:11:22 +00:00
2018-11-29 03:15:29 +00:00
<img src="./_examples/dashboard.gif" alt="demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.)" width="100%">
2018-11-29 03:15:29 +00: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 17:00:00 +00:00
2018-11-29 05:13:29 +00:00
**termui is currently undergoing some API changes so make sure to check the changelog when upgrading**
2015-10-27 19:24:29 +00:00
## Installation
2015-03-15 19:56:38 +00:00
2018-11-29 05:44:42 +00:00
Installing from the master branch is recommended:
2015-03-20 12:24:48 +00:00
2018-09-06 23:55:27 +00:00
```bash
2018-11-29 03:15:29 +00:00
go get -u github.com/gizak/termui@master
2018-09-06 23:55:27 +00:00
```
2015-03-20 12:24:48 +00:00
2015-10-27 19:24:29 +00:00
## Usage
2015-02-08 17:00:00 +00:00
2018-11-29 03:15:29 +00:00
### Hello World
2015-02-08 17:00:00 +00:00
2018-09-06 23:55:27 +00:00
```go
2018-11-29 04:12:36 +00:00
package main
2018-11-29 03:15:29 +00:00
import ui "github.com/gizak/termui"
2015-02-08 17:00:00 +00:00
2018-11-29 03:15:29 +00:00
func main() {
err := ui.Init()
if err != nil {
panic(err)
2015-02-08 17:00:00 +00:00
}
2018-11-29 03:15:29 +00:00
defer ui.Close()
2018-11-29 18:22:51 +00:00
p := ui.NewParagraph("Hello World!")
p.Width = 25
p.Height = 5
2018-11-29 03:15:29 +00:00
ui.Render(p)
2015-10-27 19:29:37 +00:00
2018-11-29 03:15:29 +00:00
for {
e := <-ui.PollEvent()
2018-11-29 18:22:51 +00:00
if e.Type == ui.KeyboardEvent {
2018-11-29 03:15:29 +00:00
return
2015-10-27 19:24:29 +00:00
}
2018-11-29 03:15:29 +00:00
}
}
2015-10-27 19:24:29 +00:00
```
2015-10-27 19:24:29 +00:00
### Widgets
2015-10-27 19:24:29 +00:00
Click image to see the corresponding demo codes.
2018-11-29 03:15:29 +00: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 23:55:27 +00: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 03:15:29 +00: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 23:55:27 +00: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 03:15:29 +00: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 23:55:27 +00: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 17:00:00 +00:00
2018-11-29 03:15:29 +00: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 17:00:00 +00:00
2018-11-29 03:15:29 +00:00
## Uses
2015-02-08 17:00:00 +00:00
2018-11-29 03:15:29 +00:00
- [go-ethereum/monitorcmd](https://github.com/ethereum/go-ethereum/blob/96116758d22ddbff4dbef2050d6b63a7b74502d8/cmd/geth/monitorcmd.go)
2018-11-29 03:15:29 +00:00
## Related Works
2018-11-29 03:15:29 +00: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 19:24:29 +00:00
2015-02-08 17:00:00 +00:00
## License
2018-09-06 23:55:27 +00:00
2015-02-08 17:00:00 +00:00
This library is under the [MIT License](http://opensource.org/licenses/MIT)