Minor progress

This commit is contained in:
Adam Cooper 2022-05-08 10:03:33 -04:00
parent 61f0a3d74c
commit f0d76461dd
2 changed files with 22 additions and 10 deletions

BIN
breakfast Executable file

Binary file not shown.

32
main.go
View file

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