mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-22 23:21:03 +00:00
Merge ba25bab134 into 7e7aadc207
This commit is contained in:
commit
ad028b01ae
2 changed files with 40 additions and 4 deletions
|
|
@ -78,25 +78,25 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
ViewName: "",
|
||||
Key: gocui.KeyPgup,
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: wrappedHandler(gui.scrollUpMain),
|
||||
Handler: wrappedHandler(gui.scrollUpPageMain),
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
Key: gocui.KeyPgdn,
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: wrappedHandler(gui.scrollDownMain),
|
||||
Handler: wrappedHandler(gui.scrollDownPageMain),
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
Key: gocui.KeyCtrlU,
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: wrappedHandler(gui.scrollUpMain),
|
||||
Handler: wrappedHandler(gui.scrollUpPageMain),
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
Key: gocui.KeyCtrlD,
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: wrappedHandler(gui.scrollDownMain),
|
||||
Handler: wrappedHandler(gui.scrollDownPageMain),
|
||||
},
|
||||
{
|
||||
ViewName: "",
|
||||
|
|
|
|||
|
|
@ -14,6 +14,19 @@ func (gui *Gui) scrollUpMain() error {
|
|||
return mainView.SetOrigin(ox, newOy)
|
||||
}
|
||||
|
||||
func (gui *Gui) scrollUpPageMain() error {
|
||||
mainView := gui.Views.Main
|
||||
mainView.Autoscroll = false
|
||||
ox, oy := mainView.Origin()
|
||||
|
||||
// Scroll up by half a page, capping at the top
|
||||
_, sizeY := mainView.Size()
|
||||
deltaY := sizeY / 2
|
||||
newOy := max(0, oy-deltaY)
|
||||
|
||||
return mainView.SetOrigin(ox, newOy)
|
||||
}
|
||||
|
||||
func (gui *Gui) scrollDownMain() error {
|
||||
mainView := gui.Views.Main
|
||||
mainView.Autoscroll = false
|
||||
|
|
@ -33,6 +46,29 @@ func (gui *Gui) scrollDownMain() error {
|
|||
return mainView.SetOrigin(ox, oy+gui.Config.UserConfig.Gui.ScrollHeight)
|
||||
}
|
||||
|
||||
func (gui *Gui) scrollDownPageMain() error {
|
||||
mainView := gui.Views.Main
|
||||
mainView.Autoscroll = false
|
||||
ox, oy := mainView.Origin()
|
||||
|
||||
// Scroll down by half a page
|
||||
_, sizeY := mainView.Size()
|
||||
totalLines := mainView.ViewLinesHeight()
|
||||
deltaY := sizeY / 2
|
||||
|
||||
reservedLines := 0
|
||||
if !gui.Config.UserConfig.Gui.ScrollPastBottom {
|
||||
_, sizeY := mainView.Size()
|
||||
reservedLines = sizeY
|
||||
}
|
||||
|
||||
// Clamp to maximum scroll position if we'd scroll too far
|
||||
maxScroll := totalLines - reservedLines
|
||||
newOy := min(oy+deltaY, maxScroll)
|
||||
|
||||
return mainView.SetOrigin(ox, newOy)
|
||||
}
|
||||
|
||||
func (gui *Gui) scrollLeftMain(g *gocui.Gui, v *gocui.View) error {
|
||||
mainView := gui.Views.Main
|
||||
ox, oy := mainView.Origin()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue