Skip to content

Commit

Permalink
feat(navigation): add shift+tab kebinding to focus previous pane
Browse files Browse the repository at this point in the history
  • Loading branch information
jackMort committed Nov 9, 2024
1 parent 221965f commit 21c1934
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,39 @@ func (m *Model) Next() (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...)
}

func (m *Model) Prev() (tea.Model, tea.Cmd) {
var cmd tea.Cmd
var cmds []tea.Cmd

if m.focused != "" {
var previous tea.Model = m.tui.ModelMap[m.focused]
m.tui.ModelMap[m.focused], cmd = previous.Update(config.WindowFocusedMsg{State: false})
cmds = append(cmds, cmd)
}

coll := m.tui.ModelMap["collections"].(collections.Collections)

switch m.focused {
case "collections":
m.focused = "results"
case "results":
m.focused = "request"
case "request":
m.focused = "url"
default:
if coll.IsMinified() {
m.focused = "results"
} else {
m.focused = "collections"
}
}

m.tui.ModelMap[m.focused], cmd = m.tui.ModelMap[m.focused].Update(config.WindowFocusedMsg{State: true})

cmds = append(cmds, cmd)
return m, tea.Batch(cmds...)
}

func (m *Model) SetFocused(newFocused string) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
var cmds []tea.Cmd
Expand Down Expand Up @@ -324,6 +357,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m, cmd := m.Next()
return m, cmd

case "shift+tab":
m, cmd := m.Prev()
return m, cmd

case "ctrl+f":
coll := m.tui.ModelMap["collections"].(collections.Collections)
minified := coll.IsMinified()
Expand Down

0 comments on commit 21c1934

Please sign in to comment.