Skip to content

Commit

Permalink
fix: enable layer scrolling (wagoodman#521)
Browse files Browse the repository at this point in the history
Fixes wagoodman#469
Fixes wagoodman#494
Fixes wagoodman#540
Refs wagoodman#473
Refs wagoodman#478
Refs wagoodman#520

Co-authored-by: st-gr <38470677+st-gr@users.noreply.github.com>
  • Loading branch information
joschi and st-gr committed Nov 7, 2024
1 parent 64e76eb commit 600b722
Showing 1 changed file with 17 additions and 0 deletions.
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

0 comments on commit 600b722

Please sign in to comment.