Documentation
¶
Index ¶
- type Config
- type Opener
- type Prefs
- func (p *Prefs) Font(ctx context.Context) *string
- func (p *Prefs) Glob(ctx context.Context, pattern string) []string
- func (p *Prefs) Lookup(file, key string) (any, error)
- func (p *Prefs) SetDefault(file, key string, v any) error
- func (p *Prefs) UI(ctx context.Context, l ...ui.NamedConstructor) (string, ui.Creator, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a type to mirror viper.Config, but with better custom type support. This stems from the closure of github.com/spf13/viper#271.
func New ¶
New returns a Config for the given Config file name (without extension) and list of valid directories for that file to be found in.
func (*Config) Get ¶
Get gets the value at k. If the default value has been set using SetDefault, the data will be converted to the same type as the default value.
func (*Config) SetDefault ¶
SetDefault sets the type and the default value for the data at k.
type Opener ¶
type Opener interface { Open(path string) (f io.ReadCloser, err error) Create(path string) (f io.WriteCloser, err error) }
Opener is a type which can read files.
type Prefs ¶
type Prefs struct {
// contains filtered or unexported fields
}
func (*Prefs) Font ¶
Font returns the user's preferred font.
TODO: - decide how to represent fonts. - figure out how to load system fonts properly. - figure out how to set font preferences.
func (*Prefs) UI ¶
UI finds the user's preferred UI plugin and returns it. The name of the chosen UI will be returned even if the ui errors, so that logs/output are able to include the UI library's name.
TODO:
- Add user preference settings for UIs
- Actually loop through the list looking for a preferred UI
- Handle errors, maybe falling back to other UIs if the preferred one fails.