fix quit keys

This commit is contained in:
abs3nt 2023-01-11 14:24:31 -08:00
parent 0d1de1349b
commit e356ac116a
2 changed files with 3 additions and 13 deletions

View File

@ -200,7 +200,7 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.list.ResetSelected()
m.list.NewStatusMessage("Setting view to devices")
}
if msg.String() == "backspace" {
if msg.String() == "backspace" || msg.String() == "esc" {
if m.mode == "playlist" || m.mode == "tracks" || m.mode == "devices" {
m.mode = "main"
m.list.NewStatusMessage("Setting view to main")
@ -214,7 +214,7 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
m.list.ResetSelected()
}
if msg.String() == "ctrl+c" {
if msg.String() == "ctrl+c" || msg.String() == "q" {
return m, tea.Quit
}
if msg.String() == "enter" || msg.String() == "spacebar" {
@ -437,6 +437,7 @@ func InitMain(ctx *gctx.Context, client *spotify.Client, mode string) (tea.Model
}
m.list.Title = "GOSPT"
go m.Tick()
m.list.DisableQuitKeybindings()
m.list.AdditionalShortHelpKeys = func() []key.Binding {
return []key.Binding{
key.NewBinding(key.WithKeys("ctrl"+"r"), key.WithHelp("ctrl+r", "start radio")),

View File

@ -2,7 +2,6 @@ package tui
import (
"fmt"
"log"
"gospt/internal/gctx"
@ -12,16 +11,6 @@ import (
// StartTea the entry point for the UI. Initializes the model.
func StartTea(ctx *gctx.Context, client *spotify.Client, mode string) error {
if f, err := tea.LogToFile("debug.log", "help"); err != nil {
return err
} else {
defer func() {
err = f.Close()
if err != nil {
log.Fatal(err)
}
}()
}
m, err := InitMain(ctx, client, mode)
if err != nil {
fmt.Println("UH OH")