Scrolling fixes

Ensure scrolling is not interrupted by quotes ticker.

Redraw on Home/End.

Prevent scrolling too far down beyond the quotes.
master
root 3 years ago
parent 4512f39638
commit 83b716e9a4
  1. 4
      cmd/mop/main.go
  2. 2
      screen.go

@ -116,8 +116,10 @@ loop:
redrawQuotesFlag = true redrawQuotesFlag = true
} else if event.Key == termbox.KeyHome { } else if event.Key == termbox.KeyHome {
screen.ScrollTop() screen.ScrollTop()
redrawQuotesFlag = true
} else if event.Key == termbox.KeyEnd { } else if event.Key == termbox.KeyEnd {
screen.ScrollBottom(len(profile.Tickers)) screen.ScrollBottom(len(profile.Tickers))
redrawQuotesFlag = true
} }
} else if lineEditor != nil { } else if lineEditor != nil {
if done := lineEditor.Handle(event); done { if done := lineEditor.Handle(event); done {
@ -158,7 +160,7 @@ loop:
case <-quotesQueue.C: case <-quotesQueue.C:
if !showingHelp && !paused { if !showingHelp && !paused {
screen.Draw(quotes) redrawQuotesFlag = true
} }
case <-marketQueue.C: case <-marketQueue.C:

@ -92,7 +92,7 @@ func (screen *Screen) ClearLine(x int, y int) *Screen {
// Increase the offset for scrolling feature by n // Increase the offset for scrolling feature by n
// Takes number of tickers as max, so not scrolling down forever // Takes number of tickers as max, so not scrolling down forever
func (screen *Screen) IncreaseOffset(n int, max int) { func (screen *Screen) IncreaseOffset(n int, max int) {
if screen.offset + n + 1 < max { if screen.offset + n < max - screen.height + screen.headerLine{
screen.offset += n screen.offset += n
} }
} }

Loading…
Cancel
Save