Go语言实现的终端仪表板:termui
ew45
10年前
Go语言实现的终端仪表板。受blessed-contrib启发,但纯Go实现。
跨平台,易于编译和完全可定制。
示例:
安装
go get github.com/gizak/termui
使用
Each component's layout is a bit like HTML block (box model), which has border and padding.
TheBorderproperty can be chosen to hide or display (with its border label), when it comes to display, the label takes 1 padding space (i.e. in css:padding: 1;, innerHeight and innerWidth therefore shrunk by 1).
import ui "github.com/gizak/termui" // <- ui shortcut, optional func main() { err := ui.Init() if err != nil { panic(err) } defer ui.Close() p := ui.NewPar(":PRESS q TO QUIT DEMO") p.Height = 3 p.Width = 50 p.TextFgColor = ui.ColorWhite p.Border.Label = "Text Box" p.Border.FgColor = ui.ColorCyan g := ui.NewGauge() g.Percent = 50 g.Width = 50 g.Height = 3 g.Y = 11 g.Border.Label = "Gauge" g.BarColor = ui.ColorRed g.Border.FgColor = ui.ColorWhite g.Border.LabelFgColor = ui.ColorCyan ui.Render(p, g) // event handler... }
项目主页:http://www.open-open.com/lib/view/home/1426163588342