added wrappar.go example
This commit is contained in:
parent
bbf3fd8ce5
commit
7dd60de21e
32
_example/wrappar.go
Normal file
32
_example/wrappar.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import ui "github.com/jrmiller82/termui"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
err := ui.Init()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer ui.Close()
|
||||||
|
|
||||||
|
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.")
|
||||||
|
p.WrapLength = 48 // this should be at least p.Width - 2
|
||||||
|
p.Height = 30
|
||||||
|
p.Width = 50
|
||||||
|
p.Y = 2
|
||||||
|
p.X = 20
|
||||||
|
p.TextFgColor = ui.ColorWhite
|
||||||
|
p.BorderLabel = "Text Box with Wrapping"
|
||||||
|
p.BorderFg = ui.ColorCyan
|
||||||
|
//p.Border = false
|
||||||
|
|
||||||
|
ui.Render(p)
|
||||||
|
|
||||||
|
ui.Handle("/sys/kbd/q", func(ui.Event) {
|
||||||
|
ui.StopLoop()
|
||||||
|
})
|
||||||
|
|
||||||
|
ui.Loop()
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user