Merge branch 'master' of https://github.com/NHOrus/termui into NHOrus-master

This commit is contained in:
gizak 2015-04-22 12:50:28 -04:00
commit d6e54064ce

View File

@ -92,34 +92,39 @@ func main() {
// calculate layout // calculate layout
ui.Body.Align() ui.Body.Align()
draw := func(t int) { done := make(chan bool)
sp.Lines[0].Data = spdata[t:]
lc.Data = sinps[2*t:] draw := func() {
ui.Render(ui.Body) for i := 0; i < 103; i++ {
for _, g := range gs {
g.Percent = (g.Percent + 3) % 100
}
sp.Lines[0].Data = spdata[i:]
lc.Data = sinps[2*i:]
time.Sleep(time.Second / 2)
}
done <- true
} }
evt := ui.EventCh() evt := ui.EventCh()
i := 0 go draw()
for { for {
select { select {
case e := <-evt: case e := <-evt:
if e.Type == ui.EventKey && e.Ch == 'q' { if e.Type == ui.EventKey && e.Ch == 'q' {
return return
} }
default: if e.Type == ui.EventResize {
for _, g := range gs {
g.Percent = (g.Percent + 3) % 100
}
ui.Body.Width = ui.TermWidth() ui.Body.Width = ui.TermWidth()
ui.Body.Align() ui.Body.Align()
}
draw(i) case <-done:
i++
if i == 102 {
return return
} default:
time.Sleep(time.Second / 2) ui.Render(ui.Body)
} }
} }
} }