2017-01-14 06:07:43 +00:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2016-01-27 01:45:18 +00:00
|
|
|
// Use of this source code is governed by a MIT license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
2015-06-16 21:16:37 +00:00
|
|
|
// +build ignore
|
|
|
|
|
2015-05-25 18:55:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-09-06 21:48:09 +00:00
|
|
|
ui "github.com/gizak/termui"
|
2015-10-21 01:45:28 +00:00
|
|
|
"github.com/gizak/termui/extra"
|
2015-05-25 18:55:34 +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()
|
2015-05-25 18:55:34 +00:00
|
|
|
|
2018-11-29 02:24:38 +00:00
|
|
|
header := ui.NewParagraph("Press q to quit, Press h or l to switch tabs")
|
2015-05-25 18:55:34 +00:00
|
|
|
header.Height = 1
|
|
|
|
header.Width = 50
|
2016-11-03 05:41:47 +00:00
|
|
|
header.Border = false
|
2018-09-06 21:48:09 +00:00
|
|
|
header.TextBgColor = ui.ColorBlue
|
2015-05-25 18:55:34 +00:00
|
|
|
|
2015-10-21 01:45:28 +00:00
|
|
|
tab1 := extra.NewTab("pierwszy")
|
2018-11-29 02:24:38 +00:00
|
|
|
p2 := ui.NewParagraph("Press q to quit\nPress h or l to switch tabs\n")
|
|
|
|
p2.Height = 5
|
|
|
|
p2.Width = 37
|
|
|
|
p2.Y = 0
|
|
|
|
p2.BorderLabel = "Keys"
|
|
|
|
p2.BorderFg = ui.ColorYellow
|
|
|
|
tab1.AddBlocks(p2)
|
2015-05-25 18:55:34 +00:00
|
|
|
|
2015-10-21 01:45:28 +00:00
|
|
|
tab2 := extra.NewTab("drugi")
|
2018-09-06 21:48:09 +00:00
|
|
|
bc := ui.NewBarChart()
|
2015-05-25 18:55:34 +00: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 11:48:50 +00:00
|
|
|
bc.BorderLabel = "Bar Chart"
|
2015-05-25 18:55:34 +00:00
|
|
|
bc.Data = data
|
|
|
|
bc.Width = 26
|
|
|
|
bc.Height = 10
|
|
|
|
bc.DataLabels = bclabels
|
2018-09-06 21:48:09 +00:00
|
|
|
bc.TextColor = ui.ColorGreen
|
|
|
|
bc.BarColor = ui.ColorRed
|
|
|
|
bc.NumColor = ui.ColorYellow
|
2015-05-25 18:55:34 +00:00
|
|
|
tab2.AddBlocks(bc)
|
|
|
|
|
2015-10-21 01:45:28 +00:00
|
|
|
tab3 := extra.NewTab("trzeci")
|
|
|
|
tab4 := extra.NewTab("żółw")
|
|
|
|
tab5 := extra.NewTab("four")
|
|
|
|
tab6 := extra.NewTab("five")
|
2015-05-25 18:55:34 +00:00
|
|
|
|
2015-10-21 01:45:28 +00:00
|
|
|
tabpane := extra.NewTabpane()
|
2015-05-25 18:55:34 +00:00
|
|
|
tabpane.Y = 1
|
2015-10-21 01:45:28 +00:00
|
|
|
tabpane.Width = 30
|
2016-11-03 05:41:47 +00:00
|
|
|
tabpane.Border = true
|
2015-05-25 18:55:34 +00:00
|
|
|
|
2015-10-21 01:45:28 +00:00
|
|
|
tabpane.SetTabs(*tab1, *tab2, *tab3, *tab4, *tab5, *tab6)
|
2015-05-25 18:55:34 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Render(header, tabpane)
|
2015-10-21 01:45:28 +00:00
|
|
|
|
2018-11-29 02:19:34 +00:00
|
|
|
for {
|
|
|
|
e := <-ui.PollEvent()
|
|
|
|
switch e.ID {
|
|
|
|
case "q", "<C-c>":
|
|
|
|
return
|
|
|
|
case "h":
|
|
|
|
tabpane.SetActiveLeft()
|
|
|
|
ui.Clear()
|
|
|
|
ui.Render(header, tabpane)
|
|
|
|
case "l":
|
|
|
|
tabpane.SetActiveRight()
|
|
|
|
ui.Clear()
|
|
|
|
ui.Render(header, tabpane)
|
|
|
|
}
|
|
|
|
}
|
2015-05-25 18:55:34 +00:00
|
|
|
}
|