Skip to content

Commit

Permalink
feat: table jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed Aug 22, 2024
1 parent 662f8df commit 4081b1b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
type keyMap struct {
Up key.Binding
Down key.Binding
JumpUp key.Binding
JumpDown key.Binding
Back key.Binding
Help key.Binding
Quit key.Binding
Expand Down Expand Up @@ -44,6 +46,7 @@ func (k keyMap) FullHelp(m Model) [][]key.Binding {
case "home":
help = [][]key.Binding{
{k.Up, k.Down},
{k.JumpUp, k.JumpDown},
{k.Back, k.Open},
{k.Search, k.ReadAll},
{k.Refresh, k.RefreshAll},
Expand All @@ -52,6 +55,7 @@ func (k keyMap) FullHelp(m Model) [][]key.Binding {
case "content":
help = [][]key.Binding{
{k.Up, k.Down},
{k.JumpUp, k.JumpDown},
{k.Back, k.Open},
{k.Search},
{k.Refresh, k.RefreshAll},
Expand All @@ -61,6 +65,7 @@ func (k keyMap) FullHelp(m Model) [][]key.Binding {
case "mixed":
help = [][]key.Binding{
{k.Up, k.Down},
{k.JumpUp, k.JumpDown},
{k.Back, k.Open},
{k.Search, k.ToggleRead},
// {k.Refresh, k.RefreshAll},
Expand Down Expand Up @@ -213,6 +218,11 @@ func (m Model) handleKeys(msg tea.KeyMsg) (Model, tea.Cmd) {

// handle global keys
switch {
case key.Matches(msg, m.keys.JumpUp):
m.table.MoveUp(5)
case key.Matches(msg, m.keys.JumpDown):
m.table.MoveDown(5)

case key.Matches(msg, m.keys.Search):
if m.context.curr != "search" {
m.loadSearch()
Expand Down Expand Up @@ -242,6 +252,14 @@ var keys = keyMap{
key.WithKeys("down", "j"),
key.WithHelp("↓/j", "move down"),
),
JumpUp: key.NewBinding(
key.WithKeys("shift+up", "K"),
key.WithHelp("↑/k", "jump move up"),
),
JumpDown: key.NewBinding(
key.WithKeys("shift+down", "J"),
key.WithHelp("↓/j", "jump move down"),
),
Back: key.NewBinding(
key.WithKeys("left", "h", "shift+tab"),
key.WithHelp("←/h", "back"),
Expand Down

0 comments on commit 4081b1b

Please sign in to comment.