From 7c27853f44a3d6dd3e09322b46e3318628ace594 Mon Sep 17 00:00:00 2001 From: moncho Date: Mon, 14 Mar 2016 08:39:06 +0100 Subject: [PATCH] Stop the status bar when it does not have the focus --- app/loop.go | 5 ++++- ui/status.go | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/loop.go b/app/loop.go index 1aa0a6b9..51929908 100644 --- a/app/loop.go +++ b/app/loop.go @@ -49,7 +49,7 @@ func RenderLoop(dry *Dry, screen *ui.Screen) { defer close(viewClosed) defer close(renderChan) - //rendes dry on message + //renders dry on message go func() { for { _, stillOpen := <-renderChan @@ -81,6 +81,9 @@ func RenderLoop(dry *Dry, screen *ui.Screen) { statusBar.Render() } screen.Flush() + } else { + //stop the status bar until the focus is retrieved + statusBar.Stop() } } else { return diff --git a/ui/status.go b/ui/status.go index a6da7945..a0e8b440 100644 --- a/ui/status.go +++ b/ui/status.go @@ -29,7 +29,9 @@ func NewStatusBar(screenPos int) *StatusBar { } -func (s *StatusBar) stopTimer() { +//Stop stops the status bar from showing any output, setting a new status +//message will activate it again +func (s *StatusBar) Stop() { s.barMutex.Lock() defer s.barMutex.Unlock() if t := s.clearTimer; t != nil { @@ -46,7 +48,7 @@ func (s *StatusBar) setClearTimer(t *time.Timer) { // StatusMessage sets a new status message for the given duration func (s *StatusBar) StatusMessage(msg string, clearDelay time.Duration) { - s.stopTimer() + s.Stop() s.lastMessage = msg //set a timer to clear the status if clearDelay != 0 {