2021-09-02 21:00:37 +03:00
|
|
|
package viewport
|
|
|
|
|
2022-11-09 15:20:21 +03:00
|
|
|
import "github.com/Maks1mS/bubbles/key"
|
2021-09-02 21:00:37 +03:00
|
|
|
|
|
|
|
const spacebar = " "
|
|
|
|
|
|
|
|
// KeyMap defines the keybindings for the viewport. Note that you don't
|
|
|
|
// necessary need to use keybindings at all; the viewport can be controlled
|
|
|
|
// programmatically with methods like Model.LineDown(1). See the GoDocs for
|
|
|
|
// details.
|
|
|
|
type KeyMap struct {
|
|
|
|
PageDown key.Binding
|
|
|
|
PageUp key.Binding
|
|
|
|
HalfPageUp key.Binding
|
|
|
|
HalfPageDown key.Binding
|
|
|
|
Down key.Binding
|
|
|
|
Up key.Binding
|
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultKeyMap returns a set of pager-like default keybindings.
|
|
|
|
func DefaultKeyMap() KeyMap {
|
|
|
|
return KeyMap{
|
|
|
|
PageDown: key.NewBinding(
|
|
|
|
key.WithKeys("pgdown", spacebar, "f"),
|
2022-04-28 23:09:31 +03:00
|
|
|
key.WithHelp("f/pgdn", "page down"),
|
2021-09-02 21:00:37 +03:00
|
|
|
),
|
|
|
|
PageUp: key.NewBinding(
|
|
|
|
key.WithKeys("pgup", "b"),
|
2022-04-28 23:09:31 +03:00
|
|
|
key.WithHelp("b/pgup", "page up"),
|
2021-09-02 21:00:37 +03:00
|
|
|
),
|
|
|
|
HalfPageUp: key.NewBinding(
|
|
|
|
key.WithKeys("u", "ctrl+u"),
|
2022-04-29 04:31:01 +03:00
|
|
|
key.WithHelp("u", "½ page up"),
|
2021-09-02 21:00:37 +03:00
|
|
|
),
|
|
|
|
HalfPageDown: key.NewBinding(
|
|
|
|
key.WithKeys("d", "ctrl+d"),
|
2022-04-29 04:31:01 +03:00
|
|
|
key.WithHelp("d", "½ page down"),
|
2021-09-02 21:00:37 +03:00
|
|
|
),
|
|
|
|
Up: key.NewBinding(
|
|
|
|
key.WithKeys("up", "k"),
|
2022-04-28 23:09:31 +03:00
|
|
|
key.WithHelp("↑/k", "up"),
|
2021-09-02 21:00:37 +03:00
|
|
|
),
|
|
|
|
Down: key.NewBinding(
|
|
|
|
key.WithKeys("down", "j"),
|
2022-04-28 23:09:31 +03:00
|
|
|
key.WithHelp("↓/j", "down"),
|
2021-09-02 21:00:37 +03:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|