building on model
This commit is contained in:
parent
4357aa1555
commit
81f6e853c2
@ -31,7 +31,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
// The "down" and "j" keys move the cursor down
|
// The "down" and "j" keys move the cursor down
|
||||||
case "down", "j":
|
case "down", "j":
|
||||||
if m.cursor < len(m.choices)-1 {
|
if m.cursor < len(m.todos)-1 {
|
||||||
m.cursor++
|
m.cursor++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
model.go
16
model.go
@ -1,19 +1,25 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
type model struct {
|
type model struct {
|
||||||
choices []string // items on the to-do list
|
todos []string // ALL items on the to-do list
|
||||||
|
list []string // items currently visible on the list right now
|
||||||
cursor int // which to-do list item our cursor is pointing at
|
cursor int // which to-do list item our cursor is pointing at
|
||||||
selected map[int]struct{} // which to-do items are selected
|
done map[int]struct{} // which to-do items are selected
|
||||||
|
tab int // which tab is selected
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialModel() model {
|
func initialModel() model {
|
||||||
return model{
|
return model{
|
||||||
// Our to-do list is a grocery list
|
// Start empty
|
||||||
choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},
|
todos: []string{},
|
||||||
|
|
||||||
|
// start on today tab
|
||||||
|
// 0: inbox, 1: today, 2: tomorrow, 3: scheduled, 4: anytime
|
||||||
|
tab: 1,
|
||||||
|
|
||||||
// A map which indicates which choices are selected. We're using
|
// A map which indicates which choices are selected. We're using
|
||||||
// the map like a mathematical set. The keys refer to the indexes
|
// the map like a mathematical set. The keys refer to the indexes
|
||||||
// of the `choices` slice, above.
|
// of the `choices` slice, above.
|
||||||
selected: make(map[int]struct{}),
|
done: make(map[int]struct{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user