49 lines
928 B
Go
49 lines
928 B
Go
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
|
// Use of this source code is governed by a MIT license that can
|
|
// be found in the LICENSE file.
|
|
|
|
// +build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
ui "github.com/gizak/termui"
|
|
"github.com/gizak/termui/widgets"
|
|
)
|
|
|
|
func main() {
|
|
if err := ui.Init(); err != nil {
|
|
log.Fatalf("failed to initialize termui: %v", err)
|
|
}
|
|
defer ui.Close()
|
|
|
|
l := widgets.NewList()
|
|
l.Title = "List"
|
|
l.Rows = []string{
|
|
"[0] github.com/gizak/termui",
|
|
"[1] [你好,世界](fg:blue)",
|
|
"[2] [こんにちは世界](fg:red)",
|
|
"[3] [color](fg:white,bg:green) output",
|
|
"[4] output.go",
|
|
"[5] random_out.go",
|
|
"[6] dashboard.go",
|
|
"[7] nsf/termbox-go",
|
|
}
|
|
l.TextStyle = ui.NewStyle(ui.ColorYellow)
|
|
l.Wrap = false
|
|
l.SetRect(0, 0, 25, 50)
|
|
|
|
ui.Render(l)
|
|
|
|
uiEvents := ui.PollEvents()
|
|
for {
|
|
e := <-uiEvents
|
|
switch e.ID {
|
|
case "q", "<C-c>":
|
|
return
|
|
}
|
|
}
|
|
}
|