1
0
mirror of https://github.com/gizak/termui.git synced 2025-04-24 13:48:50 +08:00
termui/_examples/list.go

47 lines
847 B
Go
Raw Normal View History

2017-01-14 01:07:43 -05:00
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
2015-03-20 16:21:50 -04: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 14:48:09 -07:00
import ui "github.com/gizak/termui"
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
2018-09-06 14:48:09 -07:00
defer ui.Close()
strs := []string{
"[0] github.com/gizak/termui",
2015-10-08 22:11:26 -04:00
"[1] [你好,世界](fg-blue)",
"[2] [こんにちは世界](fg-red)",
"[3] [color output](fg-white,bg-green)",
"[4] output.go",
"[5] random_out.go",
"[6] dashboard.go",
"[7] nsf/termbox-go"}
2018-09-06 14:48:09 -07:00
ls := ui.NewList()
ls.Items = strs
2018-09-06 14:48:09 -07:00
ls.ItemFgColor = ui.ColorYellow
2015-10-08 22:11:26 -04:00
ls.BorderLabel = "List"
ls.Height = 7
ls.Width = 25
ls.Y = 0
2018-09-06 14:48:09 -07:00
ui.Render(ls)
uiEvents := ui.PollEvents()
2018-11-28 18:19:34 -08:00
for {
e := <-uiEvents
2018-11-28 18:19:34 -08:00
switch e.ID {
case "q", "<C-c>":
return
}
}
}