exit tui properly

This commit is contained in:
abs3nt 2023-01-10 09:48:05 -08:00
parent 17ae2f1b4e
commit 20e0a21289
5 changed files with 6 additions and 6 deletions

View File

@ -40,7 +40,7 @@ func (m deviceModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) { switch msg := msg.(type) {
case tea.KeyMsg: case tea.KeyMsg:
if msg.String() == "ctrl+c" { if msg.String() == "ctrl+c" {
return m, tea.Quit os.Exit(0)
} }
if msg.String() == "enter" { if msg.String() == "enter" {
device := m.list.SelectedItem() device := m.list.SelectedItem()

View File

@ -78,7 +78,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
} }
if msg.String() == "ctrl+c" { if msg.String() == "ctrl+c" {
return m, tea.Quit os.Exit(0)
} }
if msg.String() == "ctrl+r" { if msg.String() == "ctrl+r" {
track := m.list.SelectedItem() track := m.list.SelectedItem()

View File

@ -57,8 +57,8 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
switch msg := msg.(type) { switch msg := msg.(type) {
case tea.KeyMsg: case tea.KeyMsg:
if msg.String() == "ctrl+c" { if msg.String() == "ctrl+c" || msg.String() == "q" || msg.String() == "esc" {
return m, tea.Quit os.Exit(0)
} }
if msg.String() == "enter" { if msg.String() == "enter" {
switch m.list.SelectedItem().(mainItem).SpotifyItem.(type) { switch m.list.SelectedItem().(mainItem).SpotifyItem.(type) {

View File

@ -63,7 +63,7 @@ func (m playlistModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) { switch msg := msg.(type) {
case tea.KeyMsg: case tea.KeyMsg:
if msg.String() == "ctrl+c" { if msg.String() == "ctrl+c" {
return m, tea.Quit os.Exit(0)
} }
if msg.String() == "enter" { if msg.String() == "enter" {
playlist := m.list.SelectedItem().(playlistItem).SimplePlaylist playlist := m.list.SelectedItem().(playlistItem).SimplePlaylist

View File

@ -77,7 +77,7 @@ func (m playlistTracksModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
} }
if msg.String() == "ctrl+c" { if msg.String() == "ctrl+c" {
return m, tea.Quit os.Exit(0)
} }
if msg.String() == "ctrl+r" { if msg.String() == "ctrl+r" {
track := m.list.SelectedItem() track := m.list.SelectedItem()