diff --git a/ui/ui.go b/ui/ui.go index 8086094..e69d7bc 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -101,7 +101,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, m.keymap.Close): closed, ccmds := m.wm.CloseFocused() if !closed { - return m, tea.Quit + break + // return m, tea.Quit } return m, tea.Batch(ccmds...) case key.Matches(msg, m.keymap.SystemSelect): @@ -242,6 +243,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case cmd.WinClose: + m.ctx.Logger.Debugf("got cmd.WinClose, target: %s", msg.Target) + switch msg.Target { case postcreate.WIN_ID: diff --git a/ui/views/posts/posts.go b/ui/views/posts/posts.go index d068726..f09328c 100644 --- a/ui/views/posts/posts.go +++ b/ui/views/posts/posts.go @@ -24,6 +24,7 @@ type KeyMap struct { Refresh key.Binding NewPost key.Binding Select key.Binding + Quit key.Binding } var DefaultKeyMap = KeyMap{ @@ -39,6 +40,10 @@ var DefaultKeyMap = KeyMap{ key.WithKeys("r", "enter"), key.WithHelp("r/enter", "read"), ), + Quit: key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "quit"), + ), } type Model struct { @@ -80,6 +85,7 @@ func NewModel(c *ctx.Ctx) Model { m.list = list.New(m.items, listDelegate, 0, 0) m.list.SetShowTitle(false) m.list.SetShowStatusBar(false) + m.list.DisableQuitKeybindings() m.a, _ = aggregator.New(m.ctx) @@ -92,6 +98,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch { + case key.Matches(msg, m.keymap.Quit): + if m.list.FilterState() == list.Filtering { + break + } + return m, tea.Quit case key.Matches(msg, m.keymap.Refresh): m.ctx.Loading = true