2017-01-14 14:07:43 +08: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 11:05:56 +08:00
|
|
|
// +build ignore
|
|
|
|
|
2016-11-10 18:46:23 +08:00
|
|
|
package main
|
|
|
|
|
2019-01-24 12:12:10 +08:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2019-03-07 18:50:20 +08:00
|
|
|
ui "github.com/gizak/termui/v3"
|
|
|
|
"github.com/gizak/termui/v3/widgets"
|
2019-01-24 12:12:10 +08:00
|
|
|
)
|
2016-11-10 18:46:23 +08:00
|
|
|
|
|
|
|
func main() {
|
2019-01-24 12:12:10 +08:00
|
|
|
if err := ui.Init(); err != nil {
|
|
|
|
log.Fatalf("failed to initialize termui: %v", err)
|
2018-09-07 09:22:04 +08:00
|
|
|
}
|
2018-09-07 05:48:09 +08:00
|
|
|
defer ui.Close()
|
|
|
|
|
2019-01-24 12:12:10 +08:00
|
|
|
table1 := widgets.NewTable()
|
|
|
|
table1.Rows = [][]string{
|
2016-11-23 15:55:22 +08:00
|
|
|
[]string{"header1", "header2", "header3"},
|
2017-01-16 12:17:50 +08:00
|
|
|
[]string{"你好吗", "Go-lang is so cool", "Im working on Ruby"},
|
2016-11-25 16:35:00 +08:00
|
|
|
[]string{"2016", "10", "11"},
|
2016-11-23 15:55:22 +08:00
|
|
|
}
|
2019-01-24 12:12:10 +08:00
|
|
|
table1.TextStyle = ui.NewStyle(ui.ColorWhite)
|
|
|
|
table1.SetRect(0, 0, 60, 10)
|
2016-11-23 15:55:22 +08:00
|
|
|
|
2018-09-07 05:48:09 +08:00
|
|
|
ui.Render(table1)
|
2016-11-10 18:46:23 +08:00
|
|
|
|
2019-01-24 12:12:10 +08:00
|
|
|
table2 := widgets.NewTable()
|
|
|
|
table2.Rows = [][]string{
|
2016-11-10 18:46:23 +08:00
|
|
|
[]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"},
|
|
|
|
}
|
2019-01-24 12:12:10 +08:00
|
|
|
table2.TextStyle = ui.NewStyle(ui.ColorWhite)
|
2019-02-24 09:15:42 +08:00
|
|
|
table2.TextAlignment = ui.AlignCenter
|
2019-01-24 12:12:10 +08:00
|
|
|
table2.RowSeparator = false
|
|
|
|
table2.SetRect(0, 10, 20, 20)
|
2017-01-16 12:17:50 +08:00
|
|
|
|
2018-09-07 05:48:09 +08:00
|
|
|
ui.Render(table2)
|
|
|
|
|
2019-02-02 01:24:33 +08:00
|
|
|
table3 := widgets.NewTable()
|
|
|
|
table3.Rows = [][]string{
|
|
|
|
[]string{"header1", "header2", "header3"},
|
|
|
|
[]string{"AAA", "BBB", "CCC"},
|
|
|
|
[]string{"DDD", "EEE", "FFF"},
|
|
|
|
[]string{"GGG", "HHH", "III"},
|
|
|
|
}
|
|
|
|
table3.TextStyle = ui.NewStyle(ui.ColorWhite)
|
|
|
|
table3.RowSeparator = true
|
|
|
|
table3.BorderStyle = ui.NewStyle(ui.ColorGreen)
|
|
|
|
table3.SetRect(0, 30, 70, 20)
|
2019-02-02 02:12:22 +08:00
|
|
|
table3.FillRow = true
|
2019-02-02 01:24:33 +08:00
|
|
|
table3.RowStyles[0] = ui.NewStyle(ui.ColorWhite, ui.ColorBlack, ui.ModifierBold)
|
2019-02-02 02:24:46 +08:00
|
|
|
table3.RowStyles[2] = ui.NewStyle(ui.ColorWhite, ui.ColorRed, ui.ModifierBold)
|
2019-02-02 01:24:33 +08:00
|
|
|
table3.RowStyles[3] = ui.NewStyle(ui.ColorYellow)
|
|
|
|
|
|
|
|
ui.Render(table3)
|
|
|
|
|
2018-11-30 07:32:42 +08:00
|
|
|
uiEvents := ui.PollEvents()
|
2018-11-29 10:19:34 +08:00
|
|
|
for {
|
2018-11-30 07:32:42 +08:00
|
|
|
e := <-uiEvents
|
2018-11-29 10:19:34 +08:00
|
|
|
switch e.ID {
|
|
|
|
case "q", "<C-c>":
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2016-11-10 18:46:23 +08:00
|
|
|
}
|