606c98548cc1ad77798b43f41ae07fa899af85cd

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Add shift+tab keybinding

Diff

 1diff --git a/ui.go b/ui.go
 2index e028a7372b85b6e5f7f02781c88d6d6b077ab6ef..3a9f98d8a680e0c1fa639063e7a99ef317ceb272 100644
 3--- a/ui.go
 4+++ b/ui.go
 5@@ -22,12 +22,12 @@ const (
 6 type audioDoneMsg struct{}
 7 
 8 type model struct {
 9-	catalog   []Song
10-	order     []int
11-	pos       int
12-	rounds    int
13-	played    int
14-	score     int
15+	catalog     []Song
16+	order       []int
17+	pos         int
18+	rounds      int
19+	played      int
20+	score       int
21 	resultParts []string
22 
23 	inputs []textinput.Model
24@@ -106,7 +106,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
25 		case stateGuess:
26 			switch msg.Type {
27 			case tea.KeyTab:
28-				m.toggleField()
29+				m.moveField(1)
30+				return m, nil
31+			case tea.KeyShiftTab:
32+				m.moveField(-1)
33 				return m, nil
34 			case tea.KeyCtrlR:
35 				if m.playing {
36@@ -171,8 +174,8 @@ func (m *model) beginRound(song Song) tea.Cmd {
37 	return startAudio(song, 1)
38 }
39 
40-func (m *model) toggleField() {
41-	m.active = (m.active + 1) % len(m.inputs)
42+func (m *model) moveField(dir int) {
43+	m.active = (m.active + dir + len(m.inputs)) % len(m.inputs)
44 	for i := range m.inputs {
45 		m.inputs[i].Blur()
46 	}
47@@ -255,7 +258,7 @@ func (m model) View() string {
48 			b.WriteString(input.View())
49 		}
50 		b.WriteString("\n\n")
51-		b.WriteString(dim.Render("Tab: switch field   Ctrl+R: replay   Ctrl+L: play 2s"))
52+		b.WriteString(dim.Render("Ctrl+R: replay   Ctrl+L: play 2s"))
53 
54 	case stateResult:
55 		var style lipgloss.Style