termui/_example/table.go

35 lines
643 B
Go
Raw Normal View History

2016-11-10 03:46:23 -07:00
package main
import "termui"
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
rows := [][]string{
[]string{"header1", "header2", "header3"},
[]string{"I love Veronica", "Go-lang is so cool", "Im working on Ruby"},
[]string{"2016", "11", "11"},
}
table := termui.NewTable()
table.Rows = rows
table.FgColor = termui.ColorWhite
table.BgColor = termui.ColorDefault
table.TextAlign = "center"
table.Analysis()
table.SetSize()
table.Y = 0
table.X = 0
table.Border = true
termui.Render(table)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}