mode

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mode stores the user's display preference (super-compact vs standard) in a global file under XDG_CONFIG_HOME (or $HOME/.config). Phase 4.2.a: real implementation — XDG-aware path, atomic write, flock.

Index

Constants

View Source
const Default = Standard

Default is returned by Load when the file is missing or its contents do not match a known Mode.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the absolute path of the mode storage file. Resolves via XDG_CONFIG_HOME when set, otherwise falls back to $HOME/.config/cc-probeline/mode. Returns "" when both XDG_CONFIG_HOME and HOME are empty. Decision C-1: global single file, not per-session/per-cwd.

func Save

func Save(m Mode) error

Save persists m atomically to the mode storage file. Write sequence: MkdirAll → write to <path>.tmp → rename to <path>. The entire write is guarded by a flock on <path>.lock (a separate lock file so that concurrent readers on the mode file itself are never blocked). Decision C-2: atomic .tmp+rename; flock on dedicated .lock file.

Types

type Mode

type Mode string

Mode names the rendering mode selected by the user.

const (
	SuperCompact Mode = "super-compact"
	Standard     Mode = "standard"
)

func Load

func Load() Mode

Load reads the persisted Mode from disk. Returns Default (Standard) when the file does not exist, Path() is empty, or the file contains an unrecognised value. Whitespace around the stored value is trimmed. Decision C-3: Default = Standard on any error or unknown value.

func Parse

func Parse(s string) Mode

Parse converts a config string (e.g. config.General.Mode) into a Mode. Whitespace is trimmed; empty or unrecognised values return Default (Standard). Phase 6.95.b: the render path reads the mode from the TOML config via this helper instead of the legacy per-session mode file.

func Toggle

func Toggle() (Mode, error)

Toggle reads the current Mode, flips it, saves it, and returns the new value. Standard → SuperCompact; SuperCompact → Standard. Decision C-2: persistence via Save (atomic write + flock).

Jump to

Keyboard shortcuts

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