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

63 lines
1.6 KiB

// Copyright (c) 2013 by Michael Dvorkin. All Rights Reserved.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package main
import (
"fmt"
"time"
"github.com/michaeldv/mop/lib"
"github.com/nsf/termbox-go"
)
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()
}
}()
12 years ago
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:
// Draw(profile)
// x, y := termbox.Size()
str := fmt.Sprintf("(%d:%d)", event.Width, event.Height)
mop.DrawScreen(str + ": <red>Hello world</red>, how <white>are</white> <blue>you?</blue>")
}
case <-event_tick.C:
mop.DrawScreen(time.Now().Format("3:04:05pm PST"))
//mop.Draw(profile)
}
}
}
//-----------------------------------------------------------------------------
func main() {
initTermbox()
defer termbox.Close()
profile := mop.LoadProfile()
mainLoop(profile)
}