Made screen.Draw() to accept variable number of arguments

master
Michael Dvorkin 12 years ago
parent 9695ec3ad0
commit c7e2456ced
  1. 18
      lib/screen.go
  2. 6
      mop.go

@ -62,14 +62,16 @@ func (self *Screen) Close() {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
func (self *Screen) Draw(ptr interface{}) { func (self *Screen) Draw(objects ...interface{}) {
switch ptr.(type) { for _, ptr := range objects {
case *Market: switch ptr.(type) {
object := ptr.(*Market) case *Market:
self.draw(object.Fetch().Format()) object := ptr.(*Market)
case *Quotes: self.draw(object.Fetch().Format())
object := ptr.(*Quotes) case *Quotes:
self.draw(object.Fetch().Format()) object := ptr.(*Quotes)
self.draw(object.Fetch().Format())
}
} }
} }

@ -24,8 +24,7 @@ func mainLoop(screen *mop.Screen, profile *mop.Profile) {
market := new(mop.Market).Initialize().Fetch() market := new(mop.Market).Initialize().Fetch()
quotes := new(mop.Quotes).Initialize(market, profile) quotes := new(mop.Quotes).Initialize(market, profile)
screen.Draw(market) screen.Draw(market, quotes)
screen.Draw(quotes)
loop: loop:
for { for {
@ -48,8 +47,7 @@ loop:
} }
case termbox.EventResize: case termbox.EventResize:
screen.Resize() screen.Resize()
screen.Draw(market) screen.Draw(market, quotes)
screen.Draw(quotes)
} }
case <-timestamp_queue.C: case <-timestamp_queue.C:

Loading…
Cancel
Save