mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-03 13:21:56 +02:00
add keybindings for paging in list panels and jumping to top/bottom
This commit is contained in:
parent
96c7741ba0
commit
229f5ee48c
@ -53,6 +53,10 @@ Default path for the config file:
|
||||
nextItem: '<down>' # go one line down
|
||||
prevItem-alt: 'k' # go one line up
|
||||
nextItem-alt: 'j' # go one line down
|
||||
prevPage: ',' # go to next page in list
|
||||
nextPage: '.' # go to previous page in list
|
||||
gotoTop: '<' # go to top of list
|
||||
gotoBottom: '>' # go to bottom of list
|
||||
prevBlock: '<left>' # goto the previous block / panel
|
||||
nextBlock: '<right>' # goto the next block / panel
|
||||
prevBlock-alt: 'h' # goto the previous block / panel
|
||||
|
@ -283,6 +283,10 @@ keybinding:
|
||||
nextItem: '<down>'
|
||||
prevItem-alt: 'k'
|
||||
nextItem-alt: 'j'
|
||||
prevPage: ','
|
||||
nextPage: '.'
|
||||
gotoTop: '<'
|
||||
gotoBottom: '>'
|
||||
prevBlock: '<left>'
|
||||
nextBlock: '<right>'
|
||||
prevBlock-alt: 'h'
|
||||
|
@ -1510,6 +1510,10 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, Handler: listView.handlePrevLine},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.nextItem-alt"), Modifier: gocui.ModNone, Handler: listView.handleNextLine},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.nextItem"), Modifier: gocui.ModNone, Handler: listView.handleNextLine},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.prevPage"), Modifier: gocui.ModNone, Handler: listView.handlePrevPage},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.nextPage"), Modifier: gocui.ModNone, Handler: listView.handleNextPage},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.gotoTop"), Modifier: gocui.ModNone, Handler: listView.handleGotoTop},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.gotoBottom"), Modifier: gocui.ModNone, Handler: listView.handleGotoBottom},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, Handler: listView.handleNextLine},
|
||||
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseLeft, Modifier: gocui.ModNone, Handler: listView.handleClick},
|
||||
}...)
|
||||
|
@ -42,6 +42,40 @@ func (lv *listView) handleLineChange(change int) error {
|
||||
return lv.handleItemSelect(lv.gui.g, view)
|
||||
}
|
||||
|
||||
func (lv *listView) handleNextPage(g *gocui.Gui, v *gocui.View) error {
|
||||
view, err := lv.gui.g.View(lv.viewName)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
_, height := view.Size()
|
||||
delta := height - 1
|
||||
if delta == 0 {
|
||||
delta = 1
|
||||
}
|
||||
return lv.handleLineChange(delta)
|
||||
}
|
||||
|
||||
func (lv *listView) handleGotoTop(g *gocui.Gui, v *gocui.View) error {
|
||||
return lv.handleLineChange(-lv.getItemsLength())
|
||||
}
|
||||
|
||||
func (lv *listView) handleGotoBottom(g *gocui.Gui, v *gocui.View) error {
|
||||
return lv.handleLineChange(lv.getItemsLength())
|
||||
}
|
||||
|
||||
func (lv *listView) handlePrevPage(g *gocui.Gui, v *gocui.View) error {
|
||||
view, err := lv.gui.g.View(lv.viewName)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
_, height := view.Size()
|
||||
delta := height - 1
|
||||
if delta == 0 {
|
||||
delta = 1
|
||||
}
|
||||
return lv.handleLineChange(-delta)
|
||||
}
|
||||
|
||||
func (lv *listView) handleClick(g *gocui.Gui, v *gocui.View) error {
|
||||
if !lv.gui.isPopupPanel(lv.viewName) && lv.gui.popupPanelFocused() {
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user