2018-11-28 20:15:29 -07:00
# termui
2015-03-20 19:11:58 -06:00
2019-01-23 21:12:10 -07:00
< img src = "./_assets/dashboard1.gif" alt = "demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.)" width = "100%" >
2015-06-23 13:11:22 -06:00
2019-01-23 21:12:10 -07:00
termui is a cross-platform and fully-customizable terminal dashboard and widget library 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.
2018-11-28 22:13:29 -07:00
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
2019-01-23 21:12:10 -07:00
**Note**: termui is currently undergoing API changes so make sure to check the changelog when upgrading.
If you upgrade and notice something is missing or don't like a change, revert the upgrade and open an issue.
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
2019-01-23 21:12:10 -07:00
import (
"log"
ui "github.com/gizak/termui"
"github.com/gizak/termui/widgets"
)
2015-02-08 10:00:00 -07:00
2018-11-28 20:15:29 -07:00
func main() {
2019-01-23 21:12:10 -07:00
if err := ui.Init(); err != nil {
log.Fatalf("failed to initialize termui: %v", 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
2019-01-23 21:12:10 -07:00
p := widgets.NewParagraph()
p.Text = "Hello World!"
p.SetRect(0, 0, 25, 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-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
2019-01-23 21:12:10 -07:00
[<img src="./_assets/barchart.png" alt="barchart" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/barchart.go )
[<img src="./_assets/gauge.png" alt="gauge" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/gauge.go )
[<img src="./_assets/linechart.png" alt="linechart" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/linechart.go )
[<img src="./_assets/list.png" alt="list" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/list.go )
[<img src="./_assets/paragraph.png" alt="paragraph" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/paragraph.go )
[<img src="./_assets/sparkline.png" alt="sparkline" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/sparkline.go )
[<img src="./_assets/stacked_barchart.png" alt="stacked_barchart" type="image/png" width="45%"> ](https://github.com/gizak/termui/blob/master/_examples/stacked_barchart.go )
[<img src="./_assets/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
2019-01-23 21:12:10 -07:00
Examples can be found in [\_examples ](./_examples ). Run an example with `go run _examples/{example}.go` or run all of them consecutively with `make run-examples` .
2018-11-28 20:15:29 -07:00
2019-01-23 21:12:10 -07:00
### Documentation
2018-11-28 20:15:29 -07:00
2019-01-23 21:12:10 -07:00
- [wiki ](https://github.com/gizak/termui/wiki )
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
2019-01-23 21:12:10 -07:00
- [cjbassi/gotop ](https://github.com/cjbassi/gotop )
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
2019-01-23 21:12:10 -07:00
[MIT ](http://opensource.org/licenses/MIT )