termbox-goとは?
golangからterminalのAPIを叩けるlibrary. pecoの内部でも利用している。
基本
importする
import "github.com/nsf/termbox-go"
初期化 & エラー処理
err := termbox.Init()
if err != nil {
panic(err)
}
終了処理
defer termbox.Close()
WindowやKey入力のEvent Wait
for {
switch ev := termbox.PollEvent(); ev.Type {
case termbox.EventKey:
switch ev.Key {
case termbox.KeyEsc:
return
}
default:
draw()
}
}
全体
Show current time using termbox-go
...