diff --git a/action.go b/action.go index 7239698..5a7ffa8 100644 --- a/action.go +++ b/action.go @@ -105,6 +105,9 @@ func init() { ActionFunc(doScrollLeft).Register("ScrollLeft") ActionFunc(doScrollRight).Register("ScrollRight") + ActionFunc(doScrollTop).Register("ScrollTop", termbox.KeyHome) + ActionFunc(doScrollBottom).Register("ScrollBottom", termbox.KeyEnd) + ActionFunc(doToggleSelection).Register("ToggleSelection") ActionFunc(doToggleSelectionAndSelectNext).Register( "ToggleSelectionAndSelectNext", @@ -416,6 +419,14 @@ func doScrollRight(ctx context.Context, state *Peco, e termbox.Event) { state.Hub().SendPaging(ToScrollRight) } +func doScrollTop(ctx context.Context, state *Peco, e termbox.Event) { + state.Hub().SendPaging(ToScrollTop) +} + +func doScrollBottom(ctx context.Context, state *Peco, e termbox.Event) { + state.Hub().SendPaging(ToScrollBottom) +} + func doToggleSelectionAndSelectNext(ctx context.Context, state *Peco, e termbox.Event) { toplevel, _ := ctx.Value(isTopLevelActionCall).(bool) state.Hub().Batch(func() { diff --git a/interface.go b/interface.go index 6ffded8..9eaea6b 100644 --- a/interface.go +++ b/interface.go @@ -29,6 +29,8 @@ const ( ToScrollLeft // ToScrollLeft scrolls screen to the left ToScrollRight // ToScrollRight scrolls screen to the right ToLineInPage // ToLineInPage jumps to a particular line on the page + ToScrollTop // ToScrollTop + ToScrollBottom // ToScrollBottom ) const ( diff --git a/layout.go b/layout.go index 83778b7..8a9f886 100644 --- a/layout.go +++ b/layout.go @@ -758,6 +758,10 @@ func verticalScroll(state *Peco, l *BasicLayout, p PagingRequest) bool { lineno -= lpp case ToLineInPage: lineno = loc.PerPage()*(loc.Page()-1) + p.(JumpToLineRequest).Line() + case ToScrollTop: + lineno = 0 + case ToScrollBottom: + lineno = lcur - 1 } } else { switch p.Type() {