mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
Add scroll to top and bottom
This commit is contained in:
parent
b9a1bbec36
commit
3058ce77f4
11
action.go
11
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() {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue