1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-11-03 04:27:16 -05:00

Fix #52 pt 2, move tea.Quit to view

This commit is contained in:
マリウス 2024-07-31 17:08:14 -05:00
parent e5bf7e4c42
commit 970eec5f12
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
2 changed files with 15 additions and 1 deletions

View File

@ -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:

View File

@ -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