feature: support table (#1)
This commit is contained in:
34
_example/table.go
Normal file
34
_example/table.go
Normal file
@@ -0,0 +1,34 @@
|
||||
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()
|
||||
}
|
||||
BIN
_example/table.png
Normal file
BIN
_example/table.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Reference in New Issue
Block a user