1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-09-28 04:58:50 +00:00
cchat-gtk/internal/ui/config/config.go

44 lines
814 B
Go

// Package config provides the repository for configuration and preferences.
package config
import "sort"
// List of config sections.
type Section uint8
const (
Appearance Section = iota
sectionLen
)
func (s Section) String() string {
switch s {
case Appearance:
return "Appearance"
default:
return "???"
}
}
var Sections = [sectionLen][]Entry{}
func sortSection(section Section) {
// TODO: remove the sorting and allow for declarative ordering
sort.Slice(Sections[section], func(i, j int) bool {
return Sections[section][i].Name < Sections[section][j].Name
})
}
type Entry struct {
Name string
Value EntryValue
}
func AppearanceAdd(name string, value EntryValue) {
Sections[Appearance] = append(Sections[Appearance], Entry{
Name: name,
Value: value,
})
sortSection(Appearance)
}