settings

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package settings is the Settings port: user settings whose source of truth is the config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKeys

func DefaultKeys() map[string]string

DefaultKeys are the hotkeys before any are rebound.

func ValidBinding

func ValidBinding(binding string) bool

ValidBinding reports whether binding is a well-formed key sequence.

Types

type Diff

type Diff struct {
	// CollapseThreshold is the changed-line count above which a file's diff
	// starts collapsed.
	CollapseThreshold int `toml:"collapse_threshold"`
	// ExpandLines is how many unchanged lines each click on a gap between
	// changes reveals.
	ExpandLines int `toml:"expand_lines"`
}

Diff holds settings for rendering diffs.

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is an in-memory Store for tests.

func NewMemory

func NewMemory(cfg Settings) *Memory

NewMemory returns a Memory store holding cfg.

func (*Memory) Load

func (m *Memory) Load() (Settings, error)

func (*Memory) Save

func (m *Memory) Save(cfg Settings) error

type Settings

type Settings struct {
	Port     int      `toml:"port"`
	Theme    string   `toml:"theme"`
	ViewMode ViewMode `toml:"view_mode"`
	Diff     Diff     `toml:"diff"`
	// Keys binds actions to key sequences: keys separated by spaces, each
	// optionally with modifiers, e.g. "ctrl+k" or "] c".
	Keys map[string]string `toml:"keys"`
}

Settings are the user's settings.

func Defaults

func Defaults() Settings

Defaults returns the settings used for anything the config file leaves unset.

func (Settings) Validate

func (s Settings) Validate() error

Validate reports the first invalid field.

func (Settings) WithKeyDefaults

func (s Settings) WithKeyDefaults() Settings

WithKeyDefaults fills in any action Keys leaves unbound.

type Store

type Store interface {
	Load() (Settings, error)
	Save(Settings) error
}

Store loads and saves Settings.

type ViewMode

type ViewMode string

ViewMode is whether a diff is shown Split (side-by-side) or Unified.

const (
	Split   ViewMode = "split"
	Unified ViewMode = "unified"
)

Directories

Path Synopsis
Package tomlfile is the Settings adapter backed by a TOML file, normally $XDG_CONFIG_HOME/scrutiny/config.toml.
Package tomlfile is the Settings adapter backed by a TOML file, normally $XDG_CONFIG_HOME/scrutiny/config.toml.

Jump to

Keyboard shortcuts

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