mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
Add scrollOffEnabled config
This commit is contained in:
@ -35,7 +35,8 @@ gui:
|
|||||||
windowSize: 'normal' # one of 'normal' | 'half' | 'full' default is 'normal'
|
windowSize: 'normal' # one of 'normal' | 'half' | 'full' default is 'normal'
|
||||||
scrollHeight: 2 # how many lines you scroll by
|
scrollHeight: 2 # how many lines you scroll by
|
||||||
scrollPastBottom: true # enable scrolling past the bottom
|
scrollPastBottom: true # enable scrolling past the bottom
|
||||||
scrollOffMargin: 2 # how many lines to keep before/after the cursor when it reaches the top/bottom of the view
|
scrollOffMargin: 2 # how many lines to keep before/after the cursor when it reaches the top/bottom of the view; see 'Scroll-off Margin' section below
|
||||||
|
scrollOffBehavior: 'margin' # one of 'margin' | 'jump'; see 'Scroll-off Margin' section below
|
||||||
sidePanelWidth: 0.3333 # number from 0 to 1
|
sidePanelWidth: 0.3333 # number from 0 to 1
|
||||||
expandFocusedSidePanel: false
|
expandFocusedSidePanel: false
|
||||||
mainPanelSplitMode: 'flexible' # one of 'horizontal' | 'flexible' | 'vertical'
|
mainPanelSplitMode: 'flexible' # one of 'horizontal' | 'flexible' | 'vertical'
|
||||||
@ -349,6 +350,14 @@ or
|
|||||||
LG_CONFIG_FILE="$HOME/.base_lg_conf,$HOME/.light_theme_lg_conf" lazygit
|
LG_CONFIG_FILE="$HOME/.base_lg_conf,$HOME/.light_theme_lg_conf" lazygit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Scroll-off Margin
|
||||||
|
|
||||||
|
When the selected line gets close to the bottom of the window and you hit down-arrow, there's a feature called "scroll-off margin" that lets the view scroll a little earlier so that you can see a bit of what's coming in the direction that you are moving. This is controlled by the `gui.scrollOffMargin` setting (default: 2), so it keeps 2 lines below the selection visible as you scroll down. It can be set to 0 to scroll only when the selection reaches the bottom of the window.
|
||||||
|
|
||||||
|
That's the behavior when `gui.scrollOffBehavior` is set to "margin" (the default). If you set `gui.scrollOffBehavior` to "jump", then upon reaching the last line of a view and hitting down-arrow the view will scroll by half a page so that the selection ends up in the middle of the view. This may feel a little jarring because the cursor jumps around when continuously moving down, but it has the advantage that the view doesn't scroll as often.
|
||||||
|
|
||||||
|
This setting applies both to all list views (e.g. commits and branches etc), and to the staging view.
|
||||||
|
|
||||||
## Color Attributes
|
## Color Attributes
|
||||||
|
|
||||||
For color attributes you can choose an array of attributes (with max one color attribute)
|
For color attributes you can choose an array of attributes (with max one color attribute)
|
||||||
|
@ -32,6 +32,7 @@ type GuiConfig struct {
|
|||||||
ScrollHeight int `yaml:"scrollHeight"`
|
ScrollHeight int `yaml:"scrollHeight"`
|
||||||
ScrollPastBottom bool `yaml:"scrollPastBottom"`
|
ScrollPastBottom bool `yaml:"scrollPastBottom"`
|
||||||
ScrollOffMargin int `yaml:"scrollOffMargin"`
|
ScrollOffMargin int `yaml:"scrollOffMargin"`
|
||||||
|
ScrollOffBehavior string `yaml:"scrollOffBehavior"`
|
||||||
MouseEvents bool `yaml:"mouseEvents"`
|
MouseEvents bool `yaml:"mouseEvents"`
|
||||||
SkipDiscardChangeWarning bool `yaml:"skipDiscardChangeWarning"`
|
SkipDiscardChangeWarning bool `yaml:"skipDiscardChangeWarning"`
|
||||||
SkipStashWarning bool `yaml:"skipStashWarning"`
|
SkipStashWarning bool `yaml:"skipStashWarning"`
|
||||||
@ -420,6 +421,7 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
ScrollHeight: 2,
|
ScrollHeight: 2,
|
||||||
ScrollPastBottom: true,
|
ScrollPastBottom: true,
|
||||||
ScrollOffMargin: 2,
|
ScrollOffMargin: 2,
|
||||||
|
ScrollOffBehavior: "margin",
|
||||||
MouseEvents: true,
|
MouseEvents: true,
|
||||||
SkipDiscardChangeWarning: false,
|
SkipDiscardChangeWarning: false,
|
||||||
SkipStashWarning: false,
|
SkipStashWarning: false,
|
||||||
|
@ -9,24 +9,28 @@ import (
|
|||||||
// To be called after pressing up-arrow; checks whether the cursor entered the
|
// 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
|
// 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) {
|
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(
|
linesToScroll := calculateLinesToScrollUp(
|
||||||
viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter)
|
viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter)
|
||||||
if linesToScroll != 0 {
|
if linesToScroll != 0 {
|
||||||
view.ScrollUp(linesToScroll)
|
view.ScrollUp(linesToScroll)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be called after pressing down-arrow; checks whether the cursor entered the
|
// 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
|
// 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) {
|
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(
|
linesToScroll := calculateLinesToScrollDown(
|
||||||
viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter)
|
viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter)
|
||||||
if linesToScroll != 0 {
|
if linesToScroll != 0 {
|
||||||
view.ScrollDown(linesToScroll)
|
view.ScrollDown(linesToScroll)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user