2017-01-14 06:07:43 +00:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
2018-08-17 03:05:56 +00:00
|
|
|
// +build ignore
|
|
|
|
|
2016-11-10 10:46:23 +00:00
|
|
|
package main
|
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
import ui "github.com/gizak/termui"
|
2016-11-10 10:46:23 +00:00
|
|
|
|
|
|
|
func main() {
|
2018-09-07 01:22:04 +00:00
|
|
|
err := ui.Init()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-09-06 21:48:09 +00:00
|
|
|
defer ui.Close()
|
|
|
|
|
2017-01-16 04:17:50 +00:00
|
|
|
rows1 := [][]string{
|
2016-11-23 07:55:22 +00:00
|
|
|
[]string{"header1", "header2", "header3"},
|
2017-01-16 04:17:50 +00:00
|
|
|
[]string{"你好吗", "Go-lang is so cool", "Im working on Ruby"},
|
2016-11-25 08:35:00 +00:00
|
|
|
[]string{"2016", "10", "11"},
|
2016-11-23 07:55:22 +00:00
|
|
|
}
|
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
table1 := ui.NewTable()
|
2017-01-16 04:17:50 +00:00
|
|
|
table1.Rows = rows1
|
2018-09-06 21:48:09 +00:00
|
|
|
table1.FgColor = ui.ColorWhite
|
|
|
|
table1.BgColor = ui.ColorDefault
|
2017-01-16 04:17:50 +00:00
|
|
|
table1.Y = 0
|
|
|
|
table1.X = 0
|
|
|
|
table1.Width = 62
|
|
|
|
table1.Height = 7
|
2016-11-23 07:55:22 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Render(table1)
|
2016-11-10 10:46:23 +00:00
|
|
|
|
2017-01-16 04:17:50 +00:00
|
|
|
rows2 := [][]string{
|
2016-11-10 10:46:23 +00:00
|
|
|
[]string{"header1", "header2", "header3"},
|
2016-11-25 08:35:00 +00:00
|
|
|
[]string{"Foundations", "Go-lang is so cool", "Im working on Ruby"},
|
2016-11-10 10:46:23 +00:00
|
|
|
[]string{"2016", "11", "11"},
|
|
|
|
}
|
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
table2 := ui.NewTable()
|
2017-01-16 04:17:50 +00:00
|
|
|
table2.Rows = rows2
|
2018-09-06 21:48:09 +00:00
|
|
|
table2.FgColor = ui.ColorWhite
|
|
|
|
table2.BgColor = ui.ColorDefault
|
|
|
|
table2.TextAlign = ui.AlignCenter
|
2017-01-16 04:17:50 +00:00
|
|
|
table2.Separator = false
|
|
|
|
table2.Analysis()
|
|
|
|
table2.SetSize()
|
2018-09-06 21:48:09 +00:00
|
|
|
table2.BgColors[2] = ui.ColorRed
|
2017-01-16 04:17:50 +00:00
|
|
|
table2.Y = 10
|
|
|
|
table2.X = 0
|
|
|
|
table2.Border = true
|
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Render(table2)
|
|
|
|
|
2018-09-06 23:36:14 +00:00
|
|
|
ui.Handle("q", func(ui.Event) {
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.StopLoop()
|
2016-11-10 10:46:23 +00:00
|
|
|
})
|
2018-09-06 21:48:09 +00:00
|
|
|
|
|
|
|
ui.Loop()
|
2016-11-10 10:46:23 +00:00
|
|
|
}
|