2017-01-13 23:07:43 -07:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2015-03-20 14:21:50 -06: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 11:20:17 -06:00
|
|
|
package main
|
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
import ui "github.com/gizak/termui"
|
2015-03-13 11:20:17 -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-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
g0 := ui.NewGauge()
|
2015-03-13 11:20:17 -06:00
|
|
|
g0.Percent = 40
|
|
|
|
g0.Width = 50
|
|
|
|
g0.Height = 3
|
2015-10-07 12:25:59 -06:00
|
|
|
g0.BorderLabel = "Slim Gauge"
|
2018-09-06 15:48:09 -06:00
|
|
|
g0.BarColor = ui.ColorRed
|
|
|
|
g0.BorderFg = ui.ColorWhite
|
|
|
|
g0.BorderLabelFg = ui.ColorCyan
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
gg := ui.NewBlock()
|
2015-04-21 07:56:10 -06:00
|
|
|
gg.Width = 50
|
|
|
|
gg.Height = 5
|
|
|
|
gg.Y = 12
|
2015-10-07 12:25:59 -06:00
|
|
|
gg.BorderLabel = "TEST"
|
2015-04-21 07:56:10 -06:00
|
|
|
gg.Align()
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
g2 := ui.NewGauge()
|
2015-03-13 11:20:17 -06:00
|
|
|
g2.Percent = 60
|
|
|
|
g2.Width = 50
|
|
|
|
g2.Height = 3
|
2018-09-06 15:48:09 -06:00
|
|
|
g2.PercentColor = ui.ColorBlue
|
2015-03-13 11:20:17 -06:00
|
|
|
g2.Y = 3
|
2015-10-07 12:25:59 -06:00
|
|
|
g2.BorderLabel = "Slim Gauge"
|
2018-09-06 15:48:09 -06:00
|
|
|
g2.BarColor = ui.ColorYellow
|
|
|
|
g2.BorderFg = ui.ColorWhite
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
g1 := ui.NewGauge()
|
2015-03-13 11:20:17 -06:00
|
|
|
g1.Percent = 30
|
|
|
|
g1.Width = 50
|
|
|
|
g1.Height = 5
|
|
|
|
g1.Y = 6
|
2015-10-07 12:25:59 -06:00
|
|
|
g1.BorderLabel = "Big Gauge"
|
2018-09-06 15:48:09 -06:00
|
|
|
g1.PercentColor = ui.ColorYellow
|
|
|
|
g1.BarColor = ui.ColorGreen
|
|
|
|
g1.BorderFg = ui.ColorWhite
|
|
|
|
g1.BorderLabelFg = ui.ColorMagenta
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
g3 := ui.NewGauge()
|
2015-04-21 08:43:09 -06:00
|
|
|
g3.Percent = 50
|
|
|
|
g3.Width = 50
|
|
|
|
g3.Height = 3
|
|
|
|
g3.Y = 11
|
2015-10-07 12:25:59 -06:00
|
|
|
g3.BorderLabel = "Gauge with custom label"
|
2015-04-21 08:43:09 -06:00
|
|
|
g3.Label = "{{percent}}% (100MBs free)"
|
2018-09-06 15:48:09 -06:00
|
|
|
g3.LabelAlign = ui.AlignRight
|
2015-04-21 08:43:09 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
g4 := ui.NewGauge()
|
2015-04-22 14:04:30 -06:00
|
|
|
g4.Percent = 50
|
|
|
|
g4.Width = 50
|
|
|
|
g4.Height = 3
|
|
|
|
g4.Y = 14
|
2015-10-28 19:19:35 -06:00
|
|
|
g4.BorderLabel = "Gauge"
|
2015-04-22 14:04:30 -06:00
|
|
|
g4.Label = "Gauge with custom highlighted label"
|
2018-09-06 15:48:09 -06:00
|
|
|
g4.PercentColor = ui.ColorYellow
|
|
|
|
g4.BarColor = ui.ColorGreen
|
|
|
|
g4.PercentColorHighlighted = ui.ColorBlack
|
2015-04-22 14:04:30 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Render(g0, g1, g2, g3, g4)
|
2015-03-13 11:20:17 -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()
|
2015-10-07 12:25:59 -06:00
|
|
|
})
|
2015-10-22 09:17:20 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Loop()
|
2015-03-13 11:20:17 -06:00
|
|
|
}
|