From 7090a2c0d57489d25a63ee264441c2675731130a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 May 2022 00:37:18 +0100 Subject: [PATCH] Scrolling performance - redraw old quotes. Rather than fetching quotes each time we need to redraw them becuase the user has scrolled the screen, just redraw the old quotes. --- cmd/mop/main.go | 2 +- screen.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/mop/main.go b/cmd/mop/main.go index 83e6f82..ec34be6 100644 --- a/cmd/mop/main.go +++ b/cmd/mop/main.go @@ -168,7 +168,7 @@ loop: } if redrawQuotesFlag && len(keyboardQueue) == 0 { - screen.Draw(quotes) + screen.DrawOldQuotes(quotes) redrawQuotesFlag = false } } diff --git a/screen.go b/screen.go index 28c1dac..1159dfa 100644 --- a/screen.go +++ b/screen.go @@ -119,6 +119,12 @@ func (screen *Screen) ScrollBottom(max int) { } } +func (screen *Screen) DrawOldQuotes(quotes *Quotes) { + screen.draw(screen.layout.Quotes(quotes), true) + termbox.Flush() +} + + // Draw accepts variable number of arguments and knows how to display the // market data, stock quotes, current time, and an arbitrary string. func (screen *Screen) Draw(objects ...interface{}) *Screen {