Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable layer scrolling, fixes #494 #521

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions runtime/ui/view/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ func (v *Layer) CursorUp() error {
return nil
}

// SetOrigin updates the origin of the layer view pane.
func (v *Layer) SetOrigin(x, y int) error {
if err := v.body.SetOrigin(x, y); err != nil {
return err
}
return nil
}

// SetCursor resets the cursor and orients the file tree view based on the given layer index.
func (v *Layer) SetCursor(layer int) error {
v.vm.LayerIndex = layer
Expand Down Expand Up @@ -340,6 +348,15 @@ func (v *Layer) Render() error {
return err
}
}

// Adjust origin, if necessary
maxBodyDisplayHeight := int(v.height())
if v.vm.LayerIndex > maxBodyDisplayHeight {
if err := v.SetOrigin(0, v.vm.LayerIndex-maxBodyDisplayHeight); err != nil {
return err
}
}

return nil
})
return nil
Expand Down