termui/render.go

26 lines
356 B
Go
Raw Normal View History

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