diff --git a/go.mod b/go.mod index 0b5ad2f..f85d1a1 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/vvaibhavv11/player go 1.25.0 require ( + github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/charmbracelet/bubbles v0.21.0 // indirect github.com/charmbracelet/bubbletea v1.3.10 // indirect diff --git a/go.sum b/go.sum index 352b117..180680e 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= diff --git a/main.go b/main.go index 5389a38..47e270d 100644 --- a/main.go +++ b/main.go @@ -4,49 +4,50 @@ import ( "fmt" "os" + "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" ) type model struct { - counter int + textInput textinput.Model } func initialModel() model { - return model{counter: 0} + ti := textinput.New() + ti.Placeholder = "Search" + ti.Width = 30 + ti.CharLimit = 30 + ti.Focus() + return model{ + textInput: ti, + } } func (m model) Init() tea.Cmd { - return nil + return textinput.Blink } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + var cmd tea.Cmd switch msg := msg.(type) { - case tea.KeyMsg: switch msg.String() { case "q", "ctrl+c": return m, tea.Quit - case "+": - m.counter++ - case "-": - m.counter-- } } - return m, nil + m.textInput, cmd = m.textInput.Update(msg) + return m, cmd } func (m model) View() string { - return fmt.Sprintf( - "Counter: %d\n\nPress + / - to change\nPress q to quit\n", - m.counter, - ) + return fmt.Sprint(m.textInput.View()) } func main() { - p := tea.NewProgram(initialModel()) - if err := p.Start(); err != nil { + p := tea.NewProgram(initialModel(), tea.WithAltScreen()) + if _, err := p.Run(); err != nil { fmt.Println("Error:", err) os.Exit(1) } } - diff --git a/player b/player new file mode 100755 index 0000000..33b6fa4 Binary files /dev/null and b/player differ