rename cards to deck
This commit is contained in:
parent
e80577d625
commit
ff8572e1b2
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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"},
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user