2017-01-13 23:07:43 -07:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2016-01-26 18:45:18 -07:00
|
|
|
// Use of this source code is governed by a MIT license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
2015-06-16 15:16:37 -06:00
|
|
|
// +build ignore
|
|
|
|
|
2015-05-25 12:55:34 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-09-06 15:48:09 -06:00
|
|
|
ui "github.com/gizak/termui"
|
2015-10-20 19:45:28 -06:00
|
|
|
"github.com/gizak/termui/extra"
|
2015-05-25 12:55:34 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-09-06 19:22:04 -06:00
|
|
|
err := ui.Init()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-09-06 15:48:09 -06:00
|
|
|
defer ui.Close()
|
2015-05-25 12:55:34 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
header := ui.NewPar("Press q to quit, Press j or k to switch tabs")
|
2015-05-25 12:55:34 -06:00
|
|
|
header.Height = 1
|
|
|
|
header.Width = 50
|
2016-11-02 23:41:47 -06:00
|
|
|
header.Border = false
|
2018-09-06 15:48:09 -06:00
|
|
|
header.TextBgColor = ui.ColorBlue
|
2015-05-25 12:55:34 -06:00
|
|
|
|
2015-10-20 19:45:28 -06:00
|
|
|
tab1 := extra.NewTab("pierwszy")
|
2018-09-06 15:48:09 -06:00
|
|
|
par2 := ui.NewPar("Press q to quit\nPress j or k to switch tabs\n")
|
2015-05-25 12:55:34 -06:00
|
|
|
par2.Height = 5
|
|
|
|
par2.Width = 37
|
|
|
|
par2.Y = 0
|
2016-10-14 05:48:50 -06:00
|
|
|
par2.BorderLabel = "Keys"
|
2018-09-06 15:48:09 -06:00
|
|
|
par2.BorderFg = ui.ColorYellow
|
2015-05-25 12:55:34 -06:00
|
|
|
tab1.AddBlocks(par2)
|
|
|
|
|
2015-10-20 19:45:28 -06:00
|
|
|
tab2 := extra.NewTab("drugi")
|
2018-09-06 15:48:09 -06:00
|
|
|
bc := ui.NewBarChart()
|
2015-05-25 12:55:34 -06:00
|
|
|
data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
|
|
|
|
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
|
2016-10-14 05:48:50 -06:00
|
|
|
bc.BorderLabel = "Bar Chart"
|
2015-05-25 12:55:34 -06:00
|
|
|
bc.Data = data
|
|
|
|
bc.Width = 26
|
|
|
|
bc.Height = 10
|
|
|
|
bc.DataLabels = bclabels
|
2018-09-06 15:48:09 -06:00
|
|
|
bc.TextColor = ui.ColorGreen
|
|
|
|
bc.BarColor = ui.ColorRed
|
|
|
|
bc.NumColor = ui.ColorYellow
|
2015-05-25 12:55:34 -06:00
|
|
|
tab2.AddBlocks(bc)
|
|
|
|
|
2015-10-20 19:45:28 -06:00
|
|
|
tab3 := extra.NewTab("trzeci")
|
|
|
|
tab4 := extra.NewTab("żółw")
|
|
|
|
tab5 := extra.NewTab("four")
|
|
|
|
tab6 := extra.NewTab("five")
|
2015-05-25 12:55:34 -06:00
|
|
|
|
2015-10-20 19:45:28 -06:00
|
|
|
tabpane := extra.NewTabpane()
|
2015-05-25 12:55:34 -06:00
|
|
|
tabpane.Y = 1
|
2015-10-20 19:45:28 -06:00
|
|
|
tabpane.Width = 30
|
2016-11-02 23:41:47 -06:00
|
|
|
tabpane.Border = true
|
2015-05-25 12:55:34 -06:00
|
|
|
|
2015-10-20 19:45:28 -06:00
|
|
|
tabpane.SetTabs(*tab1, *tab2, *tab3, *tab4, *tab5, *tab6)
|
2015-05-25 12:55:34 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Render(header, tabpane)
|
2015-10-20 19:45:28 -06:00
|
|
|
|
2018-09-06 17:36:14 -06:00
|
|
|
ui.Handle("q", func(ui.Event) {
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.StopLoop()
|
2016-11-02 23:41:47 -06:00
|
|
|
})
|
|
|
|
|
2018-09-06 17:36:14 -06:00
|
|
|
ui.Handle("j", func(ui.Event) {
|
2016-11-02 23:41:47 -06:00
|
|
|
tabpane.SetActiveLeft()
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Clear()
|
|
|
|
ui.Render(header, tabpane)
|
2016-11-02 23:41:47 -06:00
|
|
|
})
|
|
|
|
|
2018-09-06 17:36:14 -06:00
|
|
|
ui.Handle("k", func(ui.Event) {
|
2016-11-02 23:41:47 -06:00
|
|
|
tabpane.SetActiveRight()
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Clear()
|
|
|
|
ui.Render(header, tabpane)
|
2016-11-02 23:41:47 -06:00
|
|
|
})
|
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Loop()
|
2015-05-25 12:55:34 -06:00
|
|
|
}
|