diff --git a/internal/player/keymap.go b/internal/player/keymap.go index ff045e91..a431aa5c 100644 --- a/internal/player/keymap.go +++ b/internal/player/keymap.go @@ -60,6 +60,14 @@ func newKeymap() keymap { key.WithKeys("shift+right", "L", "D"), key.WithHelp("shift+right", "jump forward"), ), + stepPrev: key.NewBinding( + key.WithKeys(","), + key.WithHelp(", (when paused)", "step backward"), + ), + stepNext: key.NewBinding( + key.WithKeys("."), + key.WithHelp(". (when paused)", "step forward"), + ), help: key.NewBinding( key.WithKeys("?"), key.WithHelp("?", "help"), @@ -80,6 +88,8 @@ type keymap struct { jump key.Binding jumpPrev key.Binding jumpNext key.Binding + stepPrev key.Binding + stepNext key.Binding help key.Binding } @@ -105,6 +115,10 @@ func (k keymap) FullHelp() [][]key.Binding { k.jump, k.jumpPrev, k.jumpNext, + k.stepPrev, + k.stepNext, + }, + { k.help, k.quit, }, diff --git a/internal/player/player.go b/internal/player/player.go index c91b4619..d870b401 100644 --- a/internal/player/player.go +++ b/internal/player/player.go @@ -148,6 +148,16 @@ func (p *Player) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if p.isPlaying() { return p, p.play() } + case key.Matches(msg, p.keymap.stepPrev): + if !p.isPlaying() && p.frame > 0 { + p.frame-- + return p, nil + } + case key.Matches(msg, p.keymap.stepNext): + if !p.isPlaying() && p.frame < len(p.movie.Frames)-1 { + p.frame++ + return p, nil + } case key.Matches(msg, p.keymap.jumps...): for i, binding := range p.keymap.jumps { if key.Matches(msg, binding) {