mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Refactored keymap help, fixed sorting of forums
This commit is contained in:
parent
520686204e
commit
42e9987d29
@ -43,7 +43,7 @@ func (a *Aggregator) ListForums() ([]forum.Forum, []error) {
|
||||
}
|
||||
|
||||
sort.SliceStable(forums, func(i, j int) bool {
|
||||
return strings.Compare(forums[i].Name, forums[j].Name) == 1
|
||||
return strings.Compare(forums[i].Name, forums[j].Name) == -1
|
||||
})
|
||||
|
||||
return forums, errs
|
||||
|
@ -19,13 +19,7 @@ func (tk *ToolKit) Dialog(title string, content string, bbar bool) string {
|
||||
Width(tk.ViewWidth()).
|
||||
Render(title)
|
||||
|
||||
var bindings []string
|
||||
for _, binding := range tk.keybindings {
|
||||
var tmp string = ""
|
||||
tmp = binding.Help().Key + " " + binding.Help().Desc
|
||||
bindings = append(bindings, tmp)
|
||||
}
|
||||
bindings = append(bindings, "esc close")
|
||||
bindings := tk.KeymapHelpStrings()
|
||||
|
||||
var ui string
|
||||
if bbar {
|
||||
@ -72,13 +66,7 @@ func (tk *ToolKit) ErrorDialog(title string, content string) string {
|
||||
Width(tk.ViewWidth()).
|
||||
Render(title)
|
||||
|
||||
var bindings []string
|
||||
for _, binding := range tk.keybindings {
|
||||
var tmp string = ""
|
||||
tmp = binding.Help().Key + " " + binding.Help().Desc
|
||||
bindings = append(bindings, tmp)
|
||||
}
|
||||
bindings = append(bindings, "esc close")
|
||||
bindings := tk.KeymapHelpStrings()
|
||||
|
||||
bottombar := tk.theme.ErrorDialogBox.Bottombar.
|
||||
Width(tk.ViewWidth()).
|
||||
|
@ -1,6 +1,11 @@
|
||||
package toolkit
|
||||
|
||||
import "github.com/charmbracelet/bubbles/key"
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/bubbles/key"
|
||||
)
|
||||
|
||||
func (tk *ToolKit) KeymapAdd(id string, help string, keys ...string) {
|
||||
keysview := ""
|
||||
@ -28,3 +33,19 @@ func (tk *ToolKit) KeymapGet(id string) key.Binding {
|
||||
|
||||
return key.NewBinding()
|
||||
}
|
||||
|
||||
func (tk *ToolKit) KeymapHelpStrings() []string {
|
||||
var bindings []string
|
||||
for _, binding := range tk.keybindings {
|
||||
var tmp string = ""
|
||||
tmp = binding.Help().Key + " " + binding.Help().Desc
|
||||
bindings = append(bindings, tmp)
|
||||
}
|
||||
sort.SliceStable(bindings, func(i, j int) bool {
|
||||
return strings.Compare(bindings[i], bindings[j]) == -1
|
||||
})
|
||||
|
||||
bindings = append(bindings, "esc close")
|
||||
|
||||
return bindings
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user