Use generic screen.Draw() to display current time

master
Michael Dvorkin 11 years ago
parent 89347a040e
commit 1bc102f7ee
  1. 2
      cmd/mop.go
  2. 10
      screen.go

@ -92,7 +92,7 @@ loop:
case <-timestampQueue.C:
if !showingHelp {
screen.DrawTime()
screen.Draw(time.Now())
}
case <-quotesQueue.C:

@ -72,6 +72,9 @@ func (screen *Screen) Draw(objects ...interface{}) *Screen {
case *Quotes:
object := ptr.(*Quotes)
screen.draw(screen.layout.Quotes(object.Fetch()))
case time.Time:
timestamp := ptr.(time.Time).Format(`3:04:05pm PST`)
screen.DrawLine(0, 0, `<right>` + timestamp + `</right>`)
default:
screen.draw(ptr.(string))
}
@ -100,13 +103,6 @@ func (screen *Screen) DrawLine(x int, y int, str string) {
termbox.Flush()
}
// DrawTime ...
func (screen *Screen) DrawTime() {
now := time.Now().Format(`3:04:05pm PST`)
screen.DrawLine(0, 0, `<right>` + now + `</right>`)
}
//-----------------------------------------------------------------------------
func (screen *Screen) draw(str string) {
if !screen.cleared {

Loading…
Cancel
Save