itor/gui/view.go

49 lines
890 B
Go

package gui
import "fmt"
func (m *model) View() string {
if m.mode == Draw {
return m.viewDraw()
}
// Select is default mode
return m.viewSelect()
}
func (m *model) viewDraw() string {
s := "Draw Mode:\n\n"
s += m.cardListToString()
return s
}
func (m *model) viewSelect() string {
s := "Select cards to query:\n\n"
// Iterate over our choices
for i, choice := range m.cards {
// Is the cursor pointing at this choice?
cursor := " " // no cursor
if m.cursor == i {
cursor = ">" // cursor!
}
// Is this choice selected?
checked := " " // not selected
if _, ok := m.selected[i]; ok {
checked = "✓" // selected!
}
// Render the row
s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice.Front)
}
// The footer
s += "\nPress c to Create (_unimplemented_).\nPress d to Draw.\nPress q to quit.\n"
// Send the UI for rendering
return s
}