config

package
v0.45.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config carries the user-supplied YAML config that any tuilib component can consult: the starting palette and surface, block-glyph support, the double-click window. As other packages grow user-tunable knobs (logview defaults, runner clear-screen, custom keymaps, custom palettes), their fields land on Config too.

The library never writes the file and never creates the directory — config is opt-in. A missing file is the steady state for users who haven't set anything; Load returns (Config{}, nil) in that case. Parse errors on a malformed file are surfaced so silent corruption doesn't mask itself.

Cross-package usage:

cfg, _ := config.Load()
start := cfg.Palette                // pkg/app reads this at app.New
// later, hypothetically:
lvOpts := logview.FromConfig(cfg)   // reads cfg.Logview

Each consumer pulls just the fields it cares about; this package owns only the file shape and I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the path tuilib will read from. Honors $XDG_CONFIG_HOME, falling back to $HOME/.config/tuilib/config.yaml. The returned path may not exist — callers are expected to stat-and-skip.

Types

type Config

type Config struct {
	// Theme is the old name for Palette, still read when Palette is unset:
	// a user's config file is outside any app's control, and a renamed key
	// would silently reset their choice.
	Theme string `yaml:"theme"`

	// Palette names the palette to start in, for apps that choose palette
	// and surface separately. Theme is read as an alias when it is unset.
	Palette string `yaml:"palette"`

	// Surface names the surface to start in — outlined, filled, banded,
	// elevated, accented, or one the app defines. Ignored when the app
	// offers only one.
	Surface string `yaml:"surface"`

	// BlockGlyphs says whether the terminal draws block elements (▄ ▀ ▌)
	// without seams. Unset, it is assumed off for terminals known to draw
	// them from the font (macOS Terminal) and on everywhere else; surfaces
	// that need block glyphs fall back when it is off.
	BlockGlyphs *bool `yaml:"block_glyphs"`

	// DoubleClickMs is the window, in milliseconds, in which a second press
	// in the same cell counts as a double click. Comfortable timing varies
	// a lot between people and input devices, which is why it lives here
	// rather than being fixed per app. Zero or absent leaves the app's own
	// setting in force, falling back to mouse.DefaultDoubleClickInterval.
	DoubleClickMs int `yaml:"double_click_ms"`
}

Config is the unmarshaled form of $XDG_CONFIG_HOME/tuilib/config.yaml. Unknown YAML keys are tolerated by yaml.Unmarshal so adding new fields is backwards-compatible.

func Load

func Load() (Config, error)

Load reads Path(). When the file doesn't exist, returns (Config{}, nil) — opt-in is the design, so file-not-found is not an error condition.

Returns an error only on permission denied, malformed YAML, or other I/O problems that aren't "file not found".

func LoadFrom

func LoadFrom(path string) (Config, error)

LoadFrom reads a specific path. Same semantics as Load — file-not-found returns (Config{}, nil); other errors propagate. Useful for per-app override paths or tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL