summaryrefslogtreecommitdiff
path: root/internal/switcher/switcher.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-11-24 01:10:15 -0500
committerGitHub <noreply@github.com>2024-11-24 01:10:15 -0500
commitd92c9c601e1ef8c183562c94141db493de50921f (patch)
tree6caffa28f14f92be4711c91887c83db74f4460af /internal/switcher/switcher.go
parentf66e718496fdc5c9a9bac1c281ba8e9f3f825791 (diff)
Remove useless code and implement clipboard functionality (#1)
* Remove dead code * Implement clipboard * Improve Stringer color interfaces
Diffstat (limited to 'internal/switcher/switcher.go')
-rw-r--r--internal/switcher/switcher.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/switcher/switcher.go b/internal/switcher/switcher.go
index 0680996..7ff7164 100644
--- a/internal/switcher/switcher.go
+++ b/internal/switcher/switcher.go
@@ -9,6 +9,7 @@ import (
"github.com/charmbracelet/bubbletea-app-template/internal/picker"
"github.com/charmbracelet/bubbletea-app-template/internal/preview"
"github.com/charmbracelet/bubbletea-app-template/internal/quit"
+ "github.com/charmbracelet/bubbletea-app-template/internal/util"
)
type Model struct {
@@ -74,9 +75,22 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
cs := m.pickers[m.active].GetColor()
m.Prev()
m.pickers[m.active].SetColor(cs)
+ case key.Matches(msg, keys.cpHex):
+ util.Copy(colors.Hex(m.pickers[m.active].GetColor()))
+ case key.Matches(msg, keys.cpRgb):
+ pc := m.pickers[m.active].GetColor().ToPrecise()
+ rgb := colors.RGB{}.FromPrecise(pc).(colors.RGB)
+ util.Copy(rgb.String())
+ case key.Matches(msg, keys.cpHsl):
+ pc := m.pickers[m.active].GetColor().ToPrecise()
+ hsl := colors.HSL{}.FromPrecise(pc).(colors.HSL)
+ util.Copy(hsl.String())
+ case key.Matches(msg, keys.cpCmyk):
+ pc := m.pickers[m.active].GetColor().ToPrecise()
+ cmyk := colors.CMYK{}.FromPrecise(pc).(colors.CMYK)
+ util.Copy(cmyk.String())
case key.Matches(msg, keys.quit):
return quit.Model{}, tea.Quit
- // return m, tea.Quit
default:
// Update the picker
newActive, cmd := m.pickers[m.active].Update(msg)