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