diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-11-25 16:45:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 16:45:33 -0500 |
commit | 821c198fe6700a9e9e9eb07ab6922e7bde7f2bfb (patch) | |
tree | 33f696ab2dfa433bc1513fd44b313419b74cc812 /internal/switcher/switcher.go | |
parent | bad902e67b98a2630ff4396f846a223e3eed6a7a (diff) |
Accept initial color using -c flag (#14)
Diffstat (limited to 'internal/switcher/switcher.go')
-rw-r--r-- | internal/switcher/switcher.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/switcher/switcher.go b/internal/switcher/switcher.go index fce242c..ec5c47a 100644 --- a/internal/switcher/switcher.go +++ b/internal/switcher/switcher.go @@ -51,8 +51,29 @@ func (m *Model) Prev() int { return m.active } +func (m *Model) SetActive(i int) { + m.active = m.fixSel(i) +} + +func (m *Model) UpdatePicker(i int, c colors.ColorSpace) { + m.pickers[i].SetColor(c) +} + +func (m *Model) NewNotice(msg string) tea.Cmd { + return m.notices.New(msg) +} + func (m Model) Init() tea.Cmd { cmds := []tea.Cmd{} + + // Make a backup of notices received before the program starts + // then reinitialize them with a proper expiration time. + noticeBackup := m.notices.Notices + m.notices = notices.New() + for _, v := range noticeBackup { + cmds = append(cmds, m.NewNotice(v)) + } + for _, p := range m.pickers { cmds = append(cmds, p.Init()) } |