Next/Prev task edit

This commit is contained in:
Martin Pander
2024-06-05 16:29:47 +02:00
parent 0572763e31
commit 3e1cb9d1bc
3 changed files with 32 additions and 0 deletions

View File

@ -17,6 +17,8 @@ type Keymap struct {
Down key.Binding
Left key.Binding
Right key.Binding
Next key.Binding
Prev key.Binding
SetReport key.Binding
SetContext key.Binding
SetProject key.Binding
@ -86,6 +88,16 @@ func NewKeymap() *Keymap {
key.WithHelp("→/l", "Right"),
),
Next: key.NewBinding(
key.WithKeys("tab"),
key.WithHelp("tab", "Next"),
),
Prev: key.NewBinding(
key.WithKeys("shift+tab"),
key.WithHelp("shift+tab", "Previous"),
),
SetReport: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "Set report"),

View File

@ -174,6 +174,26 @@ func (p *TaskEditorPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch {
case key.Matches(msg, p.common.Keymap.Back):
return p, changeMode(modeNormal)
case key.Matches(msg, p.common.Keymap.Prev):
var cmd tea.Cmd
if p.columnCursor == 0 {
picker, cmd := p.areaPicker.Update(msg)
p.areaPicker = picker.(*areaPicker)
return p, cmd
} else {
p.areas[p.area], cmd = p.areas[p.area].Update(prevFieldMsg{})
return p, cmd
}
case key.Matches(msg, p.common.Keymap.Next):
var cmd tea.Cmd
if p.columnCursor == 0 {
picker, cmd := p.areaPicker.Update(msg)
p.areaPicker = picker.(*areaPicker)
return p, cmd
} else {
p.areas[p.area], cmd = p.areas[p.area].Update(nextFieldMsg{})
return p, cmd
}
case key.Matches(msg, p.common.Keymap.Ok):
area, cmd := p.areas[p.area].Update(msg)
p.areas[p.area] = area

Binary file not shown.