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