diff --git a/cmd/mop/main.go b/cmd/mop/main.go index 1368303..e280e48 100644 --- a/cmd/mop/main.go +++ b/cmd/mop/main.go @@ -114,6 +114,10 @@ loop: } else if event.Key == termbox.KeyArrowDown || event.Ch == 'j' { screen.IncreaseOffset(1, len(profile.Tickers)) redrawQuotesFlag = true + } else if event.Key == termbox.KeyHome { + screen.ScrollTop() + } else if event.Key == termbox.KeyEnd { + screen.ScrollBottom(len(profile.Tickers)) } } else if lineEditor != nil { if done := lineEditor.Handle(event); done { diff --git a/screen.go b/screen.go index b7c32fe..12e6a8a 100644 --- a/screen.go +++ b/screen.go @@ -106,6 +106,19 @@ func (screen *Screen) DecreaseOffset(n int) { } } +func (screen *Screen) ScrollTop() { + screen.offset = 0 +} + +func (screen *Screen) ScrollBottom(max int) { + bottom := max - screen.height + screen.headerLine + if bottom > 0 { + screen.offset = bottom + } else { + screen.offset = 0 + } +} + // 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 {