diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-08-17 09:58:16 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-08-21 09:03:45 +0200 |
commit | b2d629b50a69d5286f5e496eef5aca0c73ff99bb (patch) | |
tree | 0c601a2bb92ca05ce2f41f8143824c51703a1052 /pkg/gui/controllers/scroll_off_margin.go | |
parent | 125d4fa9dc31931d2ff752316449b0a3a7a6d8df (diff) |
Add scrollOffEnabled config
Diffstat (limited to 'pkg/gui/controllers/scroll_off_margin.go')
-rw-r--r-- | pkg/gui/controllers/scroll_off_margin.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/pkg/gui/controllers/scroll_off_margin.go b/pkg/gui/controllers/scroll_off_margin.go index fe3e2cfc5..1b5e99c74 100644 --- a/pkg/gui/controllers/scroll_off_margin.go +++ b/pkg/gui/controllers/scroll_off_margin.go @@ -9,24 +9,28 @@ import ( // To be called after pressing up-arrow; checks whether the cursor entered the // top scroll-off margin, and so the view needs to be scrolled up one line func checkScrollUp(view types.IViewTrait, userConfig *config.UserConfig, lineIdxBefore int, lineIdxAfter int) { - viewPortStart, viewPortHeight := view.ViewPortYBounds() + if userConfig.Gui.ScrollOffBehavior != "jump" { + viewPortStart, viewPortHeight := view.ViewPortYBounds() - linesToScroll := calculateLinesToScrollUp( - viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter) - if linesToScroll != 0 { - view.ScrollUp(linesToScroll) + linesToScroll := calculateLinesToScrollUp( + viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter) + if linesToScroll != 0 { + view.ScrollUp(linesToScroll) + } } } // To be called after pressing down-arrow; checks whether the cursor entered the // bottom scroll-off margin, and so the view needs to be scrolled down one line func checkScrollDown(view types.IViewTrait, userConfig *config.UserConfig, lineIdxBefore int, lineIdxAfter int) { - viewPortStart, viewPortHeight := view.ViewPortYBounds() + if userConfig.Gui.ScrollOffBehavior != "jump" { + viewPortStart, viewPortHeight := view.ViewPortYBounds() - linesToScroll := calculateLinesToScrollDown( - viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter) - if linesToScroll != 0 { - view.ScrollDown(linesToScroll) + linesToScroll := calculateLinesToScrollDown( + viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter) + if linesToScroll != 0 { + view.ScrollDown(linesToScroll) + } } } |