You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mop/mop.go

58 lines
1.1 KiB

// Copyright (c) 2013 by Michael Dvorkin. All Rights Reserved.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package main
import (
"github.com/michaeldv/mop/lib"
"github.com/nsf/termbox-go"
"time"
)
12 years ago
//-----------------------------------------------------------------------------
func initTermbox() {
err := termbox.Init()
if err != nil {
panic(err)
}
}
//-----------------------------------------------------------------------------
func mainLoop(profile string) {
event_queue := make(chan termbox.Event)
event_tick := time.NewTicker(1 * time.Second)
go func() {
for {
event_queue <- termbox.PollEvent()
}
}()
mop.Draw(profile)
loop:
for {
select {
case event := <-event_queue:
switch event.Type {
case termbox.EventKey:
if event.Key == termbox.KeyEsc {
break loop
}
case termbox.EventResize:
mop.Draw(profile)
}
case <-event_tick.C:
mop.Draw(profile)
}
}
}
//-----------------------------------------------------------------------------
func main() {
initTermbox()
defer termbox.Close()
profile := mop.LoadProfile()
mainLoop(profile)
}