From 671c944272657a665394a25b3c7e0e08396edd77 Mon Sep 17 00:00:00 2001 From: Bradley Cicenas Date: Mon, 12 Jun 2017 13:52:45 +0000 Subject: [PATCH] disable timed display refresh while scrolling --- cursor.go | 13 ++++++++++--- grid.go | 7 +++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cursor.go b/cursor.go index 40e87c8..ad8b383 100644 --- a/cursor.go +++ b/cursor.go @@ -14,9 +14,10 @@ var enabledConnectors = map[string]func() connector.Connector{ } type GridCursor struct { - selectedID string // id of currently selected container - filtered container.Containers - cSource connector.Connector + selectedID string // id of currently selected container + filtered container.Containers + cSource connector.Connector + isScrolling bool // toggled when actively scrolling } func NewGridCursor(connector string) *GridCursor { @@ -109,6 +110,9 @@ func (gc *GridCursor) ScrollPage() { } func (gc *GridCursor) Up() { + gc.isScrolling = true + defer func() { gc.isScrolling = false }() + idx := gc.Idx() if idx <= 0 { // already at top return @@ -125,6 +129,9 @@ func (gc *GridCursor) Up() { } func (gc *GridCursor) Down() { + gc.isScrolling = true + defer func() { gc.isScrolling = false }() + idx := gc.Idx() if idx >= gc.Len()-1 { // already at bottom return diff --git a/grid.go b/grid.go index e8d379f..c2ff991 100644 --- a/grid.go +++ b/grid.go @@ -62,8 +62,11 @@ func ExpandView(c *container.Container) { } func RefreshDisplay() { - needsClear := cursor.RefreshContainers() - RedrawRows(needsClear) + // skip display refresh during scroll + if !cursor.isScrolling { + needsClear := cursor.RefreshContainers() + RedrawRows(needsClear) + } } func Display() bool {