gauge.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
  2. // Use of this source code is governed by a MIT license that can
  3. // be found in the LICENSE file.
  4. // +build ignore
  5. package main
  6. import "notabug.org/themusicgod1/termui"
  7. func main() {
  8. err := termui.Init()
  9. if err != nil {
  10. panic(err)
  11. }
  12. defer termui.Close()
  13. //termui.UseTheme("helloworld")
  14. g0 := termui.NewGauge()
  15. g0.Percent = 40
  16. g0.Width = 50
  17. g0.Height = 3
  18. g0.BorderLabel = "Slim Gauge"
  19. g0.BarColor = termui.ColorRed
  20. g0.BorderFg = termui.ColorWhite
  21. g0.BorderLabelFg = termui.ColorCyan
  22. gg := termui.NewBlock()
  23. gg.Width = 50
  24. gg.Height = 5
  25. gg.Y = 12
  26. gg.BorderLabel = "TEST"
  27. gg.Align()
  28. g2 := termui.NewGauge()
  29. g2.Percent = 60
  30. g2.Width = 50
  31. g2.Height = 3
  32. g2.PercentColor = termui.ColorBlue
  33. g2.Y = 3
  34. g2.BorderLabel = "Slim Gauge"
  35. g2.BarColor = termui.ColorYellow
  36. g2.BorderFg = termui.ColorWhite
  37. g1 := termui.NewGauge()
  38. g1.Percent = 30
  39. g1.Width = 50
  40. g1.Height = 5
  41. g1.Y = 6
  42. g1.BorderLabel = "Big Gauge"
  43. g1.PercentColor = termui.ColorYellow
  44. g1.BarColor = termui.ColorGreen
  45. g1.BorderFg = termui.ColorWhite
  46. g1.BorderLabelFg = termui.ColorMagenta
  47. g3 := termui.NewGauge()
  48. g3.Percent = 50
  49. g3.Width = 50
  50. g3.Height = 3
  51. g3.Y = 11
  52. g3.BorderLabel = "Gauge with custom label"
  53. g3.Label = "{{percent}}% (100MBs free)"
  54. g3.LabelAlign = termui.AlignRight
  55. g4 := termui.NewGauge()
  56. g4.Percent = 50
  57. g4.Width = 50
  58. g4.Height = 3
  59. g4.Y = 14
  60. g4.BorderLabel = "Gauge"
  61. g4.Label = "Gauge with custom highlighted label"
  62. g4.PercentColor = termui.ColorYellow
  63. g4.BarColor = termui.ColorGreen
  64. g4.PercentColorHighlighted = termui.ColorBlack
  65. termui.Render(g0, g1, g2, g3, g4)
  66. termui.Handle("/sys/kbd/q", func(termui.Event) {
  67. termui.StopLoop()
  68. })
  69. termui.Loop()
  70. }