2016-11-10 18:46:23 +08:00
|
|
|
package main
|
|
|
|
|
2016-11-29 12:21:02 +08:00
|
|
|
import "github.com/gizak/termui"
|
2016-11-10 18:46:23 +08:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
err := termui.Init()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer termui.Close()
|
2016-11-23 15:55:22 +08:00
|
|
|
rows_1 := [][]string{
|
|
|
|
[]string{"header1", "header2", "header3"},
|
2016-11-25 16:35:00 +08:00
|
|
|
[]string{"孙嘉你好吗", "Go-lang is so cool", "Im working on Ruby"},
|
|
|
|
[]string{"2016", "10", "11"},
|
2016-11-23 15:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
table_1 := termui.NewTable()
|
|
|
|
table_1.Rows = rows_1
|
|
|
|
table_1.FgColor = termui.ColorWhite
|
|
|
|
table_1.BgColor = termui.ColorDefault
|
|
|
|
table_1.Y = 0
|
|
|
|
table_1.X = 0
|
|
|
|
table_1.Width = 62
|
|
|
|
table_1.Height = 7
|
|
|
|
|
|
|
|
termui.Render(table_1)
|
2016-11-10 18:46:23 +08:00
|
|
|
|
|
|
|
rows := [][]string{
|
|
|
|
[]string{"header1", "header2", "header3"},
|
2016-11-25 16:35:00 +08:00
|
|
|
[]string{"Foundations", "Go-lang is so cool", "Im working on Ruby"},
|
2016-11-10 18:46:23 +08:00
|
|
|
[]string{"2016", "11", "11"},
|
|
|
|
}
|
|
|
|
|
|
|
|
table := termui.NewTable()
|
|
|
|
table.Rows = rows
|
|
|
|
table.FgColor = termui.ColorWhite
|
|
|
|
table.BgColor = termui.ColorDefault
|
2016-11-29 12:21:02 +08:00
|
|
|
table.TextAlign = termui.AlignCenter
|
2017-01-14 14:04:00 +08:00
|
|
|
table.Separator = false
|
2016-11-10 18:46:23 +08:00
|
|
|
table.Analysis()
|
|
|
|
table.SetSize()
|
2016-11-23 15:55:22 +08:00
|
|
|
table.BgColors[2] = termui.ColorRed
|
|
|
|
table.Y = 20
|
2016-11-10 18:46:23 +08:00
|
|
|
table.X = 0
|
|
|
|
table.Border = true
|
|
|
|
|
|
|
|
termui.Render(table)
|
|
|
|
termui.Handle("/sys/kbd/q", func(termui.Event) {
|
|
|
|
termui.StopLoop()
|
|
|
|
})
|
|
|
|
termui.Loop()
|
|
|
|
}
|