termui/_test/log_events.go

32 lines
554 B
Go
Raw Normal View History

2018-11-29 10:19:22 -07:00
// 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.
2018-12-28 14:07:47 -07:00
// +build ignore
2018-11-29 10:19:22 -07:00
package main
import (
"fmt"
ui "github.com/gizak/termui"
)
// logs all events to the termui window
// stdout can also be redirected to a file and read with `tail -f`
func main() {
2019-01-23 21:12:10 -07:00
if err := ui.Init(); err != nil {
2018-11-29 10:19:22 -07:00
panic(err)
}
defer ui.Close()
for {
e := <-ui.PollEvents()
2018-11-29 10:19:22 -07:00
fmt.Printf("%v", e)
switch e.ID {
case "q", "<C-c>":
return
}
}
}