From 20e0a21289fd15e4b7d2d016031c787210ecd6fe Mon Sep 17 00:00:00 2001 From: abs3nt Date: Tue, 10 Jan 2023 09:48:05 -0800 Subject: [PATCH] exit tui properly --- internal/tui/device.go | 2 +- internal/tui/list.go | 2 +- internal/tui/main.go | 4 ++-- internal/tui/playlists.go | 2 +- internal/tui/playlisttracks.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/tui/device.go b/internal/tui/device.go index 9414e58..aaf57ae 100644 --- a/internal/tui/device.go +++ b/internal/tui/device.go @@ -40,7 +40,7 @@ func (m deviceModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: if msg.String() == "ctrl+c" { - return m, tea.Quit + os.Exit(0) } if msg.String() == "enter" { device := m.list.SelectedItem() diff --git a/internal/tui/list.go b/internal/tui/list.go index d066d44..ffdb70b 100644 --- a/internal/tui/list.go +++ b/internal/tui/list.go @@ -78,7 +78,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } if msg.String() == "ctrl+c" { - return m, tea.Quit + os.Exit(0) } if msg.String() == "ctrl+r" { track := m.list.SelectedItem() diff --git a/internal/tui/main.go b/internal/tui/main.go index bd8c282..0b40edf 100644 --- a/internal/tui/main.go +++ b/internal/tui/main.go @@ -57,8 +57,8 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } switch msg := msg.(type) { case tea.KeyMsg: - if msg.String() == "ctrl+c" { - return m, tea.Quit + if msg.String() == "ctrl+c" || msg.String() == "q" || msg.String() == "esc" { + os.Exit(0) } if msg.String() == "enter" { switch m.list.SelectedItem().(mainItem).SpotifyItem.(type) { diff --git a/internal/tui/playlists.go b/internal/tui/playlists.go index ca9c95b..bad0fb6 100644 --- a/internal/tui/playlists.go +++ b/internal/tui/playlists.go @@ -63,7 +63,7 @@ func (m playlistModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: if msg.String() == "ctrl+c" { - return m, tea.Quit + os.Exit(0) } if msg.String() == "enter" { playlist := m.list.SelectedItem().(playlistItem).SimplePlaylist diff --git a/internal/tui/playlisttracks.go b/internal/tui/playlisttracks.go index 9984e86..a25b332 100644 --- a/internal/tui/playlisttracks.go +++ b/internal/tui/playlisttracks.go @@ -77,7 +77,7 @@ func (m playlistTracksModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } if msg.String() == "ctrl+c" { - return m, tea.Quit + os.Exit(0) } if msg.String() == "ctrl+r" { track := m.list.SelectedItem()