2017-01-14 14:07:43 +08:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2015-03-21 04:21:50 +08:00
|
|
|
// Use of this source code is governed by a MIT license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build ignore
|
|
|
|
|
2015-03-14 01:20:17 +08:00
|
|
|
package main
|
|
|
|
|
2019-01-24 12:12:10 +08:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
ui "github.com/gizak/termui"
|
|
|
|
"github.com/gizak/termui/widgets"
|
|
|
|
)
|
2015-03-14 01:20:17 +08:00
|
|
|
|
|
|
|
func main() {
|
2019-01-24 12:12:10 +08:00
|
|
|
if err := ui.Init(); err != nil {
|
|
|
|
log.Fatalf("failed to initialize termui: %v", err)
|
2018-09-07 09:22:04 +08:00
|
|
|
}
|
2018-09-07 05:48:09 +08:00
|
|
|
defer ui.Close()
|
2015-03-14 01:20:17 +08:00
|
|
|
|
2019-01-24 12:12:10 +08:00
|
|
|
l := widgets.NewList()
|
|
|
|
l.Title = "List"
|
|
|
|
l.Rows = []string{
|
2015-03-14 01:20:17 +08:00
|
|
|
"[0] github.com/gizak/termui",
|
2019-01-24 12:12:10 +08:00
|
|
|
"[1] [你好,世界](fg:blue)",
|
|
|
|
"[2] [こんにちは世界](fg:red)",
|
2019-01-24 13:44:00 +08:00
|
|
|
"[3] [color](fg:white,bg:green) output",
|
2015-03-14 01:20:17 +08:00
|
|
|
"[4] output.go",
|
|
|
|
"[5] random_out.go",
|
|
|
|
"[6] dashboard.go",
|
2019-01-24 12:12:10 +08:00
|
|
|
"[7] nsf/termbox-go",
|
|
|
|
}
|
|
|
|
l.TextStyle = ui.NewStyle(ui.ColorYellow)
|
|
|
|
l.Wrap = false
|
|
|
|
l.SetRect(0, 0, 25, 50)
|
2015-03-14 01:20:17 +08:00
|
|
|
|
2019-01-24 12:12:10 +08:00
|
|
|
ui.Render(l)
|
2018-09-07 05:48:09 +08:00
|
|
|
|
2018-11-30 07:32:42 +08:00
|
|
|
uiEvents := ui.PollEvents()
|
2018-11-29 10:19:34 +08:00
|
|
|
for {
|
2018-11-30 07:32:42 +08:00
|
|
|
e := <-uiEvents
|
2018-11-29 10:19:34 +08:00
|
|
|
switch e.ID {
|
|
|
|
case "q", "<C-c>":
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2015-03-14 01:20:17 +08:00
|
|
|
}
|