par.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. par0 := termui.NewPar("Borderless Text")
  15. par0.Height = 1
  16. par0.Width = 20
  17. par0.Y = 1
  18. par0.Border = false
  19. par1 := termui.NewPar("你好,世界。")
  20. par1.Height = 3
  21. par1.Width = 17
  22. par1.X = 20
  23. par1.BorderLabel = "标签"
  24. par2 := termui.NewPar("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)")
  25. par2.Height = 5
  26. par2.Width = 37
  27. par2.Y = 4
  28. par2.BorderLabel = "Multiline"
  29. par2.BorderFg = termui.ColorYellow
  30. par3 := termui.NewPar("Long text with label and it is auto trimmed.")
  31. par3.Height = 3
  32. par3.Width = 37
  33. par3.Y = 9
  34. par3.BorderLabel = "Auto Trim"
  35. termui.Render(par0, par1, par2, par3)
  36. termui.Handle("/sys/kbd/q", func(termui.Event) {
  37. termui.StopLoop()
  38. })
  39. termui.Loop()
  40. }