termui/_examples/par.go

49 lines
1014 B
Go
Raw Normal View History

2017-01-13 23:07:43 -07:00
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
2015-03-20 14:21:50 -06:00
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
// +build ignore
package main
2018-09-06 15:48:09 -06:00
import ui "github.com/gizak/termui"
func main() {
2018-09-06 15:48:09 -06:00
ui.Init()
defer ui.Close()
2018-09-06 15:48:09 -06:00
par0 := ui.NewPar("Borderless Text")
par0.Height = 1
par0.Width = 20
par0.Y = 1
2015-10-08 20:11:26 -06:00
par0.Border = false
2018-09-06 15:48:09 -06:00
par1 := ui.NewPar("你好,世界。")
par1.Height = 3
par1.Width = 17
par1.X = 20
2015-10-08 20:11:26 -06:00
par1.BorderLabel = "标签"
2018-09-06 15:48:09 -06:00
par2 := ui.NewPar("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)")
par2.Height = 5
par2.Width = 37
par2.Y = 4
2015-10-08 20:11:26 -06:00
par2.BorderLabel = "Multiline"
2018-09-06 15:48:09 -06:00
par2.BorderFg = ui.ColorYellow
2018-09-06 15:48:09 -06:00
par3 := ui.NewPar("Long text with label and it is auto trimmed.")
par3.Height = 3
par3.Width = 37
par3.Y = 9
2015-10-08 20:11:26 -06:00
par3.BorderLabel = "Auto Trim"
2018-09-06 15:48:09 -06:00
ui.Render(par0, par1, par2, par3)
2018-09-06 15:48:09 -06:00
ui.Handle("/sys/kbd/q", func(ui.Event) {
ui.StopLoop()
2015-10-08 20:11:26 -06:00
})
2018-09-06 15:48:09 -06:00
ui.Loop()
2015-10-08 20:11:26 -06:00
}