Skip to content

Commit

Permalink
Stop the status bar when it does not have the focus
Browse files Browse the repository at this point in the history
  • Loading branch information
moncho committed Mar 14, 2016
1 parent 31ac82a commit 7c27853
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions ui/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 7c27853

Please sign in to comment.