diff --git a/gui/create.go b/gui/create.go index 849ec38..aaa9c07 100644 --- a/gui/create.go +++ b/gui/create.go @@ -16,16 +16,19 @@ func (m *model) nextTabIndex() { } func (m *model) createCurrent() { + // Get the value of the front and back of the card front := m.createInputs[0].Value() back := m.createInputs[1].Value() + // Create a new card card := Card{ Front: front, Back: back, } - m.cards = append(m.cards, card) + // Add it to the deck + m.deck = append(m.deck, card) - // CLEAR + // Clear the inputs for i, _ := range m.createInputs { m.createInputs[i].Reset() } diff --git a/gui/gui.go b/gui/gui.go index b4d2353..80b5dc2 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -34,7 +34,7 @@ func (m *model) switchMode(mode Mode) { func (m *model) cardListToString() string { s := "" - for i, card := range m.cards { + for i, card := range m.deck { if _, ok := m.selected[i]; ok { s += fmt.Sprintf("%s [%s]\n", card.Front, card.Back) } diff --git a/gui/model.go b/gui/model.go index 057ad8f..834ed05 100644 --- a/gui/model.go +++ b/gui/model.go @@ -13,7 +13,7 @@ type Card struct { } type model struct { - cards []Card // items on the to-do list + deck []Card // items on the to-do list selectCardIndex int // which to-do list item our selectCardIndex is pointing at selected map[int]struct{} // which to-do items are selected createInputs []textinput.Model @@ -35,7 +35,7 @@ func initialModel() model { back.Width = 80 return model{ - cards: []Card{ + deck: []Card{ {Front: "Hello (JP)", Back: "Konnichi wa"}, {Front: "Hello (SP)", Back: "Hola"}, {Front: "Hello (DE)", Back: "Guten Tag"}, diff --git a/gui/select.go b/gui/select.go index 65678ba..5af11d3 100644 --- a/gui/select.go +++ b/gui/select.go @@ -22,7 +22,7 @@ func (m *model) updateSelect(msg tea.Msg) (tea.Model, tea.Cmd) { // The "down" and "j" keys move the selectCardIndex down case "down", "j": - if m.selectCardIndex < len(m.cards)-1 { + if m.selectCardIndex < len(m.deck)-1 { m.selectCardIndex++ } @@ -47,10 +47,10 @@ func (m *model) updateSelect(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } func (m *model) viewSelect() string { - s := "Select cards to query:\n\n" + s := "Select deck to query:\n\n" // Iterate over our choices - for i, choice := range m.cards { + for i, choice := range m.deck { // Is the selectCardIndex pointing at this choice? cursor := " " // no selectCardIndex