-
Notifications
You must be signed in to change notification settings - Fork 0
/
palette.go
91 lines (83 loc) · 1.74 KB
/
palette.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
)
type paletteCommand struct {
name string
command func(*mainModel) tea.Cmd
}
var PaletteCommands = []fmt.Stringer{
paletteCommand{
"add project",
func(m *mainModel) tea.Cmd {
m.inputModel.GetOnce("add project", "", func(input string) tea.Cmd {
return m.AddProject(input)
})
return nil
},
},
paletteCommand{
"archive project",
func(m *mainModel) tea.Cmd {
return m.ArchiveProject()
},
},
paletteCommand{
"rename section",
func(m *mainModel) tea.Cmd {
for _, sct := range m.local.Sections {
if sct.ID == m.sectionId {
m.inputModel.GetOnce("rename section", "", func(input string) tea.Cmd {
return m.RenameSection(sct, input)
})
}
}
return nil
},
},
paletteCommand{
"archive section",
func(m *mainModel) tea.Cmd {
if m.sectionId == "" {
dbg("no section to archive")
return nil
}
return m.ArchiveSection(m.sectionId)
},
},
paletteCommand{
"add section",
func(m *mainModel) tea.Cmd {
if m.projectId == "" {
dbg("no project to add section to")
return nil
}
m.inputModel.GetOnce("add section", "", func(input string) tea.Cmd {
return m.AddSection(input, m.projectId)
})
return nil
},
},
paletteCommand{
"rename project",
func(m *mainModel) tea.Cmd {
for _, prj := range m.local.Projects {
if prj.ID == m.projectId {
m.inputModel.GetOnce("rename project", prj.Name, func(input string) tea.Cmd {
return m.RenameProject(prj.ID, input)
})
}
}
return nil
},
},
}
// move section (to other project, it seems)
// context task
// edit content
// edit desc
// re-prioritise
func (pc paletteCommand) String() string {
return pc.name
}