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: case <-timestampQueue.C:
if !showingHelp { if !showingHelp {
screen.DrawTime() screen.Draw(time.Now())
} }
case <-quotesQueue.C: case <-quotesQueue.C:

@ -72,6 +72,9 @@ func (screen *Screen) Draw(objects ...interface{}) *Screen {
case *Quotes: case *Quotes:
object := ptr.(*Quotes) object := ptr.(*Quotes)
screen.draw(screen.layout.Quotes(object.Fetch())) 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: default:
screen.draw(ptr.(string)) screen.draw(ptr.(string))
} }
@ -100,13 +103,6 @@ func (screen *Screen) DrawLine(x int, y int, str string) {
termbox.Flush() 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) { func (screen *Screen) draw(str string) {
if !screen.cleared { if !screen.cleared {

Loading…
Cancel
Save