Skip to content

Commit

Permalink
scrollDownMain now works properly with ScrollPastBottom enabled #31
Browse files Browse the repository at this point in the history
  • Loading branch information
winhung committed Aug 6, 2019
1 parent b899796 commit 4e25f78
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/gui/main_panel.go
Expand Up @@ -16,21 +16,20 @@ func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error {

func (gui *Gui) scrollDownMain(g *gocui.Gui, v *gocui.View) error {
mainView := gui.getMainView()
mainView.Autoscroll = false
ox, oy := mainView.Origin()
y := oy

reservedLines := 0
if !gui.Config.UserConfig.Gui.ScrollPastBottom {
_, sy := mainView.Size()
y += sy
_, sizeY := mainView.Size()
reservedLines = sizeY
}

_, sizeY := mainView.Size()
totalLines := mainView.ViewLinesHeight()
if oy+sizeY >= totalLines {
if oy+reservedLines >= totalLines {
return nil
}

// for some reason we can't work out whether we've hit the bottomq
// there is a large discrepancy in the origin's y value and the length of BufferLines
return mainView.SetOrigin(ox, oy+gui.Config.UserConfig.Gui.ScrollHeight)
}

Expand Down

0 comments on commit 4e25f78

Please sign in to comment.