diff --git a/TODO.txt b/TODO.txt index 17e9077..8b420de 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,5 @@ - Better error handling? (Add a status bar to screens displaying last error?) - Is the entry magic number really needed? - Would `WriteAt` be useful? Probably not. +- What value does it save to the .sta file after it's been edited? + - Doesn't seem to affect the association, so I assume it's using cart signature for that. \ No newline at end of file diff --git a/go.mod b/go.mod index 200c1e5..0769b25 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/g026r/pocket-toolkit -go 1.23.1 +go 1.23.2 require ( github.com/charmbracelet/bubbles v0.20.0 diff --git a/pkg/models/models.go b/pkg/models/models.go index 91704fe..d2b9094 100644 --- a/pkg/models/models.go +++ b/pkg/models/models.go @@ -12,7 +12,19 @@ import ( ) var EntrySort = func(a, b Entry) int { - return cmp.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) + if val := cmp.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)); val != 0 { + return val + } + if val := cmp.Compare(a.Crc32, b.Crc32); val != 0 { + return val + } + if val := cmp.Compare(a.Sig, b.Sig); val != 0 { + return val + } + if val := cmp.Compare(a.Magic, b.Magic); val != 0 { + return val + } + return cmp.Compare(a.System, b.System) // Technically system & magic number should be tied together. But you never know. } type Thumbnails struct { diff --git a/pkg/ui/menus.go b/pkg/ui/menus.go index 0852bd8..7901c3f 100644 --- a/pkg/ui/menus.go +++ b/pkg/ui/menus.go @@ -430,7 +430,7 @@ func generateSubMenu(l list.Model, items []list.Item, title string, width, heigh l.Title = title l.ResetSelected() l.ResetFilter() - l.SetItems(items) + _ = l.SetItems(items) // Don't care that it potentially returns a FilterMatchMsg command as we're resetting everything. // Need to reset height & width or else it doesn't display right the first time since the number of items in the list // has changed from the initial WindowSizeMsg that's fired on startup // It's overkill after it's displayed once, but an issue until then. diff --git a/pkg/ui/model.go b/pkg/ui/model.go index 6904ff6..27860d9 100644 --- a/pkg/ui/model.go +++ b/pkg/ui/model.go @@ -146,6 +146,11 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.gameList.SetHeight(msg.Height - 1) m.gameList.SetWidth(msg.Width - 1) return m, nil + case list.FilterMatchesMsg: + // Only m.gameList has filtering enabled, so don't need to check the current screen + listModel, cmd := m.gameList.Update(msg) + m.gameList = listModel + return m, cmd case initDoneMsg: m.initialized = true m.Clear() @@ -805,7 +810,7 @@ func (m *Model) saveEntry() (tea.Model, tea.Cmd) { slices.SortFunc(m.entries, models.EntrySort) var cmd tea.Cmd if m.Peek() == EditScreen { - // Only reset the items rather than the whole list so we can keep our position in the list + the active filter + // Only reset the items rather than re-initialize the whole list so that we can keep our position in the list + the active filter tmp := make([]list.Item, len(m.entries)) for i := range m.entries { tmp[i] = m.entries[i]