wrappar.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. package main
  5. import ui "notabug.org/themusicgod1/termui"
  6. func main() {
  7. err := ui.Init()
  8. if err != nil {
  9. panic(err)
  10. }
  11. defer ui.Close()
  12. p := ui.NewPar("Press q to QUIT THE DEMO. [There](fg-blue) are other things [that](fg-red) are going to fit in here I think. What do you think? Now is the time for all good [men to](bg-blue) come to the aid of their country. [This is going to be one really really really long line](fg-green) that is going to go together and stuffs and things. Let's see how this thing renders out.\n Here is a new paragraph and stuffs and things. There should be a tab indent at the beginning of the paragraph. Let's see if that worked as well.")
  13. p.WrapLength = 48 // this should be at least p.Width - 2
  14. p.Height = 20
  15. p.Width = 50
  16. p.Y = 2
  17. p.X = 20
  18. p.TextFgColor = ui.ColorWhite
  19. p.BorderLabel = "Text Box with Wrapping"
  20. p.BorderFg = ui.ColorCyan
  21. //p.Border = false
  22. ui.Render(p)
  23. ui.Handle("/sys/kbd/q", func(ui.Event) {
  24. ui.StopLoop()
  25. })
  26. ui.Loop()
  27. }