From e356ac116a77cdea80c102da8793ab39bbac802d Mon Sep 17 00:00:00 2001 From: abs3nt Date: Wed, 11 Jan 2023 14:24:31 -0800 Subject: [PATCH] fix quit keys --- internal/tui/main.go | 5 +++-- internal/tui/tui.go | 11 ----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/internal/tui/main.go b/internal/tui/main.go index 5f5c8b9..81a9b11 100644 --- a/internal/tui/main.go +++ b/internal/tui/main.go @@ -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")), diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 0e82ab9..521aaf5 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -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")