|
|
|
@ -13,11 +13,12 @@ type commandChoice struct { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type model struct { |
|
|
|
|
cursor int |
|
|
|
|
browserSessions []string |
|
|
|
|
commands []commandChoice |
|
|
|
|
selectedSessions map[int]struct{} |
|
|
|
|
selectedCommands map[int]struct{} |
|
|
|
|
browserSessionsCursor int |
|
|
|
|
commandsCursor int |
|
|
|
|
browserSessions []string |
|
|
|
|
commands []commandChoice |
|
|
|
|
selectedSessions map[int]struct{} |
|
|
|
|
selectedCommands map[int]struct{} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getBrowserSessions() []string { |
|
|
|
@ -58,15 +59,26 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
|
|
|
|
m.cursor-- |
|
|
|
|
} |
|
|
|
|
case "down", "j": |
|
|
|
|
if m.cursor < len(m.choices)-1 { |
|
|
|
|
if m.cursor < len(m.browserSessions)+len(m.commands)-1 { |
|
|
|
|
m.cursor++ |
|
|
|
|
} |
|
|
|
|
case "enter", " ": |
|
|
|
|
_, ok := m.selected[m.cursor] |
|
|
|
|
if ok { |
|
|
|
|
delete(m.selected, m.cursor) |
|
|
|
|
// TODO: Let's have two separate cursors, and have tab move the active
|
|
|
|
|
// set from brower sessions to terminals.
|
|
|
|
|
if m.cursor < len(m.browserSessions)-1 { |
|
|
|
|
_, ok := m.selected[m.cursor] |
|
|
|
|
if ok { |
|
|
|
|
delete(m.selected, m.cursor) |
|
|
|
|
} else { |
|
|
|
|
m.selected[m.cursor] = struct{}{} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
m.selected[m.cursor] = struct{}{} |
|
|
|
|
_, ok := m.selected[m.cursor] |
|
|
|
|
if ok { |
|
|
|
|
delete(m.selected, m.cursor) |
|
|
|
|
} else { |
|
|
|
|
m.selected[m.cursor] = struct{}{} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|