From d20bd3e8220d4e0eb828ddd7a272753f1ad9fd8a Mon Sep 17 00:00:00 2001 From: Michael Dvorkin Date: Tue, 23 Jul 2013 11:43:24 -0700 Subject: [PATCH] Minor simplification --- lib/format.go | 2 +- lib/screen.go | 6 ++++++ mop.go | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/format.go b/lib/format.go index 549dbf5..c9222a2 100644 --- a/lib/format.go +++ b/lib/format.go @@ -149,7 +149,7 @@ func last_of_pair(str string) string { //----------------------------------------------------------------------------- func with_currency(str string) string { - if str == `N/A` || str == `0.00` { + if str == `N/A` { return `-` } else { switch str[0:1] { diff --git a/lib/screen.go b/lib/screen.go index 3709877..85d6659 100644 --- a/lib/screen.go +++ b/lib/screen.go @@ -13,6 +13,7 @@ import ( type Screen struct { width int height int + cleared bool tags map[string]termbox.Attribute } @@ -44,12 +45,14 @@ func (self *Screen) Initialize() *Screen { //----------------------------------------------------------------------------- func (self *Screen) Resize() *Screen { self.width, self.height = termbox.Size() + self.cleared = false return self } //----------------------------------------------------------------------------- func (self *Screen) Clear() *Screen { termbox.Clear(termbox.ColorDefault, termbox.ColorDefault) + self.cleared = true return self } @@ -121,6 +124,9 @@ func (self *Screen) DrawLine(x int, y int, str string) { // private //----------------------------------------------------------------------------- func (self *Screen) draw(str string) { + if !self.cleared { + self.Clear() + } for row, line := range strings.Split(str, "\n") { self.DrawLine(0, row, line) } diff --git a/mop.go b/mop.go index cd95946..10257d0 100644 --- a/mop.go +++ b/mop.go @@ -24,7 +24,6 @@ func mainLoop(screen *mop.Screen, profile *mop.Profile) { market := new(mop.Market).Initialize().Fetch() quotes := new(mop.Quotes).Initialize(market, profile) - screen.Clear() screen.DrawMarket(market) screen.DrawQuotes(quotes) @@ -48,7 +47,7 @@ loop: } } case termbox.EventResize: - screen.Resize().Clear() + screen.Resize() screen.DrawMarket(market) screen.DrawQuotes(quotes) }