termui/render.go

26 lines
351 B
Go
Raw Normal View History

2015-02-03 07:07:31 -07:00
package termui
import tm "github.com/nsf/termbox-go"
type Renderer interface {
Buffer() []Point
}
func Init() error {
return tm.Init()
}
2015-02-03 18:56:49 -07:00
func Close() {
2015-02-03 07:07:31 -07:00
tm.Close()
}
2015-02-03 18:56:49 -07:00
func Render(rs ...Renderer) {
for _, r := range rs {
buf := r.Buffer()
for _, v := range buf {
tm.SetCell(v.X, v.Y, v.Code.Ch, v.Code.Fg, v.Code.Bg)
}
2015-02-03 07:07:31 -07:00
}
tm.Flush()
}