2016-11-11 04:25:53 +00:00
|
|
|
// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2015-03-20 20:21:50 +00:00
|
|
|
// Use of this source code is governed by a MIT license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build ignore
|
|
|
|
|
2015-03-13 17:20:17 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "github.com/gizak/termui"
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
err := termui.Init()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer termui.Close()
|
|
|
|
|
2015-10-07 18:25:59 +00:00
|
|
|
//termui.UseTheme("helloworld")
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
g0 := termui.NewGauge()
|
|
|
|
g0.Percent = 40
|
|
|
|
g0.Width = 50
|
|
|
|
g0.Height = 3
|
2015-10-07 18:25:59 +00:00
|
|
|
g0.BorderLabel = "Slim Gauge"
|
2015-03-13 17:20:17 +00:00
|
|
|
g0.BarColor = termui.ColorRed
|
2015-10-07 18:25:59 +00:00
|
|
|
g0.BorderFg = termui.ColorWhite
|
|
|
|
g0.BorderLabelFg = termui.ColorCyan
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2015-04-21 13:56:10 +00:00
|
|
|
gg := termui.NewBlock()
|
|
|
|
gg.Width = 50
|
|
|
|
gg.Height = 5
|
|
|
|
gg.Y = 12
|
2015-10-07 18:25:59 +00:00
|
|
|
gg.BorderLabel = "TEST"
|
2015-04-21 13:56:10 +00:00
|
|
|
gg.Align()
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
g2 := termui.NewGauge()
|
|
|
|
g2.Percent = 60
|
|
|
|
g2.Width = 50
|
|
|
|
g2.Height = 3
|
|
|
|
g2.PercentColor = termui.ColorBlue
|
|
|
|
g2.Y = 3
|
2015-10-07 18:25:59 +00:00
|
|
|
g2.BorderLabel = "Slim Gauge"
|
2015-03-13 17:20:17 +00:00
|
|
|
g2.BarColor = termui.ColorYellow
|
2015-10-07 18:25:59 +00:00
|
|
|
g2.BorderFg = termui.ColorWhite
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
g1 := termui.NewGauge()
|
|
|
|
g1.Percent = 30
|
|
|
|
g1.Width = 50
|
|
|
|
g1.Height = 5
|
|
|
|
g1.Y = 6
|
2015-10-07 18:25:59 +00:00
|
|
|
g1.BorderLabel = "Big Gauge"
|
2015-03-13 17:20:17 +00:00
|
|
|
g1.PercentColor = termui.ColorYellow
|
|
|
|
g1.BarColor = termui.ColorGreen
|
2015-10-07 18:25:59 +00:00
|
|
|
g1.BorderFg = termui.ColorWhite
|
|
|
|
g1.BorderLabelFg = termui.ColorMagenta
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2015-04-21 14:43:09 +00:00
|
|
|
g3 := termui.NewGauge()
|
|
|
|
g3.Percent = 50
|
|
|
|
g3.Width = 50
|
|
|
|
g3.Height = 3
|
|
|
|
g3.Y = 11
|
2015-10-07 18:25:59 +00:00
|
|
|
g3.BorderLabel = "Gauge with custom label"
|
2015-04-21 14:43:09 +00:00
|
|
|
g3.Label = "{{percent}}% (100MBs free)"
|
2015-04-21 16:07:48 +00:00
|
|
|
g3.LabelAlign = termui.AlignRight
|
2015-04-21 14:43:09 +00:00
|
|
|
|
2015-04-22 20:04:30 +00:00
|
|
|
g4 := termui.NewGauge()
|
|
|
|
g4.Percent = 50
|
|
|
|
g4.Width = 50
|
|
|
|
g4.Height = 3
|
|
|
|
g4.Y = 14
|
2015-10-29 01:19:35 +00:00
|
|
|
g4.BorderLabel = "Gauge"
|
2015-04-22 20:04:30 +00:00
|
|
|
g4.Label = "Gauge with custom highlighted label"
|
|
|
|
g4.PercentColor = termui.ColorYellow
|
|
|
|
g4.BarColor = termui.ColorGreen
|
|
|
|
g4.PercentColorHighlighted = termui.ColorBlack
|
|
|
|
|
|
|
|
termui.Render(g0, g1, g2, g3, g4)
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2015-10-07 18:25:59 +00:00
|
|
|
termui.Handle("/sys/kbd/q", func(termui.Event) {
|
|
|
|
termui.StopLoop()
|
|
|
|
})
|
2015-10-22 15:17:20 +00:00
|
|
|
|
2015-10-07 18:25:59 +00:00
|
|
|
termui.Loop()
|
2015-03-13 17:20:17 +00:00
|
|
|
}
|