Documentation
¶
Overview ¶
Package settings keeps mdsh-gui's app-wide settings in a JSON file in the user's config folder.
Index ¶
- Constants
- func CleanTypes(list []string) []string
- func DefaultPath() (string, error)
- type FileView
- type Place
- type Settings
- func (s Settings) FileView(file string) (FileView, bool)
- func (s *Settings) OpenType(path string) bool
- func (s *Settings) Opened(file string)
- func (s *Settings) Pin(file string, pin bool) bool
- func (s Settings) Place(file string) (Place, bool)
- func (s *Settings) Placed(p Place) bool
- func (s Settings) SecretShow() time.Duration
- func (s Settings) StartDir(cwd, home, documents string) string
- func (s *Settings) Viewed(v FileView) bool
- type Store
Constants ¶
const MaxFileViews = 100
MaxFileViews is how many files' views are remembered.
const MaxPlaces = 100
MaxPlaces is how many files' window places are remembered.
const MaxRecent = 10
MaxRecent is how many files Open Recent remembers.
const SecretShowDefault = 60 * time.Second
SecretShowDefault is how long a secret stays shown, or on the clipboard, unless the settings say otherwise.
Variables ¶
This section is empty.
Functions ¶
func CleanTypes ¶
CleanTypes is list as OpenTypes keeps it: lower case, without dots or spaces, each once, and none empty.
func DefaultPath ¶
DefaultPath is where the settings live: mdsh/gui.json in the user's config folder.
Types ¶
type FileView ¶
type FileView struct {
File string `json:"file"`
View string `json:"view"`
History bool `json:"history,omitempty"`
}
FileView is how a file was last shown: View is "rendered", "source" or "both", and History is whether the History pane was open.
type Place ¶
type Place struct {
File string `json:"file"`
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
Place is where a file's window was and how big, in the screen's points. X and Y are its top left corner.
type Settings ¶
type Settings struct {
// Autosave saves the file after each run.
Autosave bool `json:"autosave"`
// Vim turns on Vim key bindings in the code editors.
Vim bool `json:"vim"`
// NoSpellCheck turns off spell checking of the prose in the code
// editor, which is on by default.
NoSpellCheck bool `json:"noSpellCheck"`
// Neovim makes the source pane an embedded Neovim, when Vim is on
// and a new enough nvim is found. Experimental.
Neovim bool `json:"neovim"`
// NeovimPath is the nvim to run; empty finds one.
NeovimPath string `json:"neovimPath"`
// NeovimClean starts Neovim without the user's config.
NeovimClean bool `json:"neovimClean"`
// NeovimOwnColors keeps the colorscheme from the user's Neovim
// config, rather than the app's theme, which is the default.
NeovimOwnColors bool `json:"neovimOwnColors"`
// Serve lets mdsh-gui serve notebooks: to a web browser on this
// machine, from File › Serve in Browser, and to the program that
// started it with --serve=stdio. Experimental, and off by default.
Serve bool `json:"serve"`
// Theme is "light" or "dark"; empty follows the system.
Theme string `json:"theme"`
// Look is a look's id from its look.css in web/looks, such as
// "tty" for Teletype; empty is the plain look.
Look string `json:"look"`
// TextSize is the text's size in percent, 80 to 150; 0 is the
// look's own (100 for plain, 115 for Teletype).
TextSize int `json:"textSize"`
// UIFont and CodeFont are font families for the interface and for
// code; empty is the look's own.
UIFont string `json:"uiFont"`
CodeFont string `json:"codeFont"`
// LineSpacing is "compact" or "relaxed"; empty is normal.
LineSpacing string `json:"lineSpacing"`
// NoSprockets, NoRules and NoShadows take the Teletype paper's
// sprocket strips, its line rules and the shadows under cards off.
NoSprockets bool `json:"noSprockets"`
NoRules bool `json:"noRules"`
NoShadows bool `json:"noShadows"`
// Accent is a #rrggbb color for links, run buttons and selection;
// empty is the look's own.
Accent string `json:"accent"`
// HistoryPane is the History pane's colors: "match" the window,
// "invert" them (light under a dark window, dark under a light one)
// or "dark" always. Empty is the look's own: dark for plain, match
// for Teletype.
HistoryPane string `json:"historyPane"`
// HistoryFocus is how the History pane's prompt shows it has the
// keyboard: "cursor" for a blinking block cursor where you type,
// in place of the outline around the field. Empty is the outline.
HistoryFocus string `json:"historyFocus"`
// SecretShowSeconds is how long a block's secret stays shown after
// its eye button shows it, and on the clipboard after it is copied.
// 0 is SecretShowDefault.
SecretShowSeconds int `json:"secretShowSeconds"`
// Shell, if set, overrides the front matter's shell for every file.
Shell string `json:"shell"`
// HistoryRC is a file, such as ~/.zshrc, the shells read while the
// History pane is on. Empty reads none.
HistoryRC string `json:"historyRC"`
// HistoryReuse has a command typed in the History pane that was
// typed before, and so has a #history-N block, run that block again,
// keeping its last output as an earlier run, rather than add another
// block. Off adds a block for every command.
HistoryReuse bool `json:"historyReuse"`
// View is how a file opens: "rendered", "source" or "both".
// Empty opens a file as it was last shown (see FileViews), and a
// file not shown before in the rendered view.
View string `json:"view"`
// StartFolder is the folder the start screen lists when the app
// isn't started from a terminal. Empty means the last folder used.
StartFolder string `json:"startFolder"`
// TemplateFolder holds the markdown files New File… offers to start
// from. Empty offers only a blank file.
TemplateFolder string `json:"templateFolder"`
// SessionFolder is where New Session makes a file for the day and
// Last Session finds the latest. Empty is ~/.mdsh/sessions.
SessionFolder string `json:"sessionFolder"`
// SessionTemplate is a markdown file a new session starts as a copy
// of. Empty starts it with a heading for the date.
SessionTemplate string `json:"sessionTemplate"`
// OpenTypes are the file extensions, such as "pdf", that a link in
// a document opens with the system's app for them. A link to any
// other file the app doesn't show itself is shown in the file
// manager instead, so one click on a link can't run something.
OpenTypes []string `json:"openTypes,omitempty"`
// LastFolder is the folder of the file opened last.
LastFolder string `json:"lastFolder"`
// Recent are the files opened last, newest first.
Recent []string `json:"recent"`
// Pinned are the files pinned to the top of the start screen, in
// the order they were pinned.
Pinned []string `json:"pinned,omitempty"`
// Places are where the windows of the files last shown alone in a
// new window were, newest first.
Places []Place `json:"places,omitempty"`
// FileViews are how the files shown last were left, newest first:
// the view and whether the History pane was open.
FileViews []FileView `json:"fileViews,omitempty"`
}
Settings are the app-wide settings. The zero value is the default.
func (*Settings) OpenType ¶
OpenType reports whether a link to path opens with the system's app, as OpenTypes says for its extension.
func (*Settings) Opened ¶
Opened notes that file was opened: it goes to the top of Recent and its folder becomes LastFolder.
func (*Settings) Pin ¶
Pin pins file to the start screen, after the files pinned before it, or unpins it. It reports whether that changed anything.
func (*Settings) Placed ¶
Placed remembers where p.File's window is: p goes to the top of Places, and the oldest are forgotten past MaxPlaces. It reports whether that changed anything.
func (Settings) SecretShow ¶
SecretShow is how long a secret stays shown, or on the clipboard.
func (Settings) StartDir ¶
StartDir is the folder the start screen lists. Started from a terminal, that is the current folder cwd. Started from Finder or the Dock the current folder is /, so it is StartFolder, else LastFolder, else documents (~/Documents on macOS), else home. Folders that no longer exist are passed over.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store reads and writes Settings.