prefs

package
v0.6.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: 7 Imported by: 0 modules, 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 prefs holds the desktop app's preferences and small state (ADR-0021; docs/specs/ui.md#settings-batch-2): one versioned JSON file per device, whose defaults are Obsidian's. A stored value that is not one a preference takes falls back to its default, so an older or newer file never breaks the window. It ports app/src/data/prefs.ts.

Index

Constants

View Source
const MaxRecentCommands = 10

MaxRecentCommands is how many commands the palette remembers.

Variables

This section is empty.

Functions

func Save

func Save(path string, p Prefs) error

Save writes the preferences to path.

func SaveState

func SaveState(path string, s State) error

SaveState writes the state to path.

func ZoomStep

func ZoomStep(zoom float64, direction int) float64

ZoomStep is the next zoom step from zoom in a direction: +1 in, -1 out; it stays at either end.

Types

type Prefs

type Prefs struct {
	DefaultView        string  `json:"defaultView"` // edit, read
	EditingMode        string  `json:"editingMode"` // live, source
	InlineTitle        bool    `json:"inlineTitle"`
	ViewHeader         bool    `json:"viewHeader"`
	ReadableLineLength bool    `json:"readableLineLength"`
	Properties         string  `json:"properties"` // visible, hidden, source
	LineNumbers        bool    `json:"lineNumbers"`
	IndentGuides       bool    `json:"indentGuides"`
	FoldHeadings       bool    `json:"foldHeadings"`
	FoldIndent         bool    `json:"foldIndent"`
	AutoPairBrackets   bool    `json:"autoPairBrackets"`
	AutoPairMarkdown   bool    `json:"autoPairMarkdown"`
	SmartLists         bool    `json:"smartLists"`
	IndentWithTabs     bool    `json:"indentWithTabs"`
	TabSize            int     `json:"tabSize"`
	ConfirmDelete      bool    `json:"confirmDelete"`
	LoadRemoteImages   bool    `json:"loadRemoteImages"`
	ShowUnsupported    bool    `json:"showUnsupported"`
	Theme              string  `json:"theme"` // system, light, dark
	FontSize           int     `json:"fontSize"`
	Zoom               float64 `json:"zoom"`
	LastVault          string  `json:"lastVault"`
}

Prefs are the app's preferences.

func Default

func Default() Prefs

Default are Obsidian's defaults.

func Load

func Load(path string) Prefs

Load reads the preferences at path; a missing or broken file is the defaults.

func Parse

func Parse(data []byte) Prefs

Parse reads a stored record.

type State

type State struct {
	Pending        []WorkspaceEvent `json:"pending,omitzero"`
	PendingSeq     int64            `json:"pendingSeq,omitzero"`
	Seq            int64            `json:"seq"`
	RecentCommands []string         `json:"recentCommands"`
}

State is what the app keeps between runs that is no preference: the event resume point and the commands run lately.

func LoadState

func LoadState(path string) State

LoadState reads the state at path.

func (*State) RanCommand

func (s *State) RanCommand(id string)

RanCommand puts id first among the recent commands.

type WorkspaceEvent

type WorkspaceEvent struct {
	VaultID int64  `json:"vaultId"`
	From    string `json:"from"`
	To      string `json:"to,omitzero"`
}

WorkspaceEvent is a move or removal held until the vault list is available. To is empty for a removal; paths remain relative to VaultID.

Jump to

Keyboard shortcuts

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