Redraw market without fetch on resize.

master
root 3 years ago
parent cb4d384c5f
commit 69865574e8
  1. 11
      cmd/mop/main.go
  2. 15
      screen.go

@ -60,6 +60,7 @@ func mainLoop(screen *mop.Screen, profile *mop.Profile) {
paused := false paused := false
upDownJump := profile.UpDownJump upDownJump := profile.UpDownJump
redrawQuotesFlag := false redrawQuotesFlag := false
redrawMarketFlag := false
go func() { go func() {
for { for {
@ -137,8 +138,12 @@ loop:
case termbox.EventResize: case termbox.EventResize:
screen.Resize() screen.Resize()
if !showingHelp { if !showingHelp {
screen.Draw(market) //screen.Draw(market)
//redrawQuotesFlag = true
//screen.Draw(market)
redrawQuotesFlag = true redrawQuotesFlag = true
redrawMarketFlag = true
//screen.DrawOldQuotes(quotes)
} else { } else {
screen.Draw(help) screen.Draw(help)
} }
@ -176,6 +181,10 @@ loop:
screen.DrawOldQuotes(quotes) screen.DrawOldQuotes(quotes)
redrawQuotesFlag = false redrawQuotesFlag = false
} }
if redrawMarketFlag && len(keyboardQueue) == 0 {
screen.Draw(market)
redrawMarketFlag = false
}
} }
} }

@ -96,8 +96,8 @@ func (screen *Screen) IncreaseOffset(n int) {
if screen.offset+n <= screen.max { if screen.offset+n <= screen.max {
screen.offset += n screen.offset += n
} else if screen.max > screen.height { } else if screen.max > screen.height {
screen.offset = screen.max screen.offset = screen.max
} }
} }
// Decrease the offset for scrolling feature by n // Decrease the offset for scrolling feature by n
@ -114,9 +114,9 @@ func (screen *Screen) ScrollTop() {
} }
func (screen *Screen) ScrollBottom() { func (screen *Screen) ScrollBottom() {
if screen.max > screen.height { if screen.max > screen.height {
screen.offset = screen.max screen.offset = screen.max
} }
} }
func (screen *Screen) DrawOldQuotes(quotes *Quotes) { func (screen *Screen) DrawOldQuotes(quotes *Quotes) {
@ -124,6 +124,11 @@ func (screen *Screen) DrawOldQuotes(quotes *Quotes) {
termbox.Flush() termbox.Flush()
} }
func (screen *Screen) DrawOldMarket(market *Market) {
screen.draw(screen.layout.Market(market), false)
termbox.Flush()
}
// Draw accepts variable number of arguments and knows how to display the // Draw accepts variable number of arguments and knows how to display the
// market data, stock quotes, current time, and an arbitrary string. // market data, stock quotes, current time, and an arbitrary string.
func (screen *Screen) Draw(objects ...interface{}) *Screen { func (screen *Screen) Draw(objects ...interface{}) *Screen {

Loading…
Cancel
Save