termui/_examples/wrapper.go

39 lines
1.2 KiB
Go
Raw Normal View History

2017-01-14 06:07:43 +00:00
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
2016-11-11 04:25:53 +00:00
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
2018-08-17 03:05:56 +00:00
// +build ignore
2015-10-30 03:41:35 +00:00
package main
2016-03-10 20:49:31 +00:00
import ui "github.com/gizak/termui"
2015-10-30 03:41:35 +00:00
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
2015-10-30 03:41:35 +00:00
defer ui.Close()
2018-11-29 02:24:38 +00:00
p := ui.NewParagraph("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.")
2015-10-30 03:41:35 +00:00
p.WrapLength = 48 // this should be at least p.Width - 2
2016-03-10 20:49:31 +00:00
p.Height = 20
2015-10-30 03:41:35 +00:00
p.Width = 50
p.Y = 2
p.X = 20
p.TextFgColor = ui.ColorWhite
p.BorderLabel = "Text Box with Wrapping"
p.BorderFg = ui.ColorCyan
ui.Render(p)
uiEvents := ui.PollEvents()
2018-11-29 02:19:34 +00:00
for {
e := <-uiEvents
2018-11-29 02:19:34 +00:00
switch e.ID {
case "q", "<C-c>":
return
}
}
2015-10-30 03:41:35 +00:00
}