Import std.io.preferences
std.io.preferences
std.io's preferences: a program's settings, kept between its runs in the folder each OS keeps its users' programs' settings in, in a file of the program's own, which a save replaces whole.
std/io/preferences.fb
Types
Preferences
class
Public Class Preferences
A program's settings, by name, kept in //preferences.txt, where the folder is the OS's for its users' settings (Windows' %APPDATA%, macOS's ~/Library/Application Support, and elsewhere $XDG_CONFIG_HOME or ~/.config) unless one's given. Nothing is written until Save, which writes them atomically; IsChanged says whether there's something to save. The file is UTF-8 text a person can read and change: a "key=value" line for each setting, with "\", "\n", and "\r" for a backslash, a line break, and a carriage return in both, "=" for an '=' in a key and "#" for a '#' at its start; a line that starts with '#', or has no '=', is skipped, and so is a byte order mark an editor writes before the first.
std/io/preferences.fb, line 29
-
The program the preferences are for.
-
The file they're kept in.
-
The program
app's preferences, read from the OS's folder for them, or none when there's no file yet. Panics for an app's name that can't be a file's, and throws an IOError when the OS doesn't say where its folder is, or the file can't be read. -
The preferences of
appkept infolderin place of the OS's folder, as tests keep theirs in a temporary folder. -
The OS's folder for its users' programs' settings, which Preferences keep theirs in: Windows' %APPDATA%, macOS's ~/Library/Application Support, and elsewhere $XDG_CONFIG_HOME when it's a path from the root, or ~/.config. Throws an IOError of OTHER when the OS doesn't say.
-
@PanicsAtCaller Public Static Async Method OpenAsync(app: String): Preferences Throws IOErrorstatic method #New's Async twin, which reads the file without blocking the main thread.
-
@PanicsAtCaller Public Static Async Method OpenAsync(app: String, folder: Path): Preferences Throws IOErrorstatic method #New's Async twin, for
folder, which reads the file without blocking the main thread. -
The setting
key, or Null when there's none. -
The setting
key, orfallbackwhen there's none. -
The setting
keyas an integer, as Int64.Parse reads it, or Null when there's none, or it isn't one. -
The setting
keyas an integer, orfallbackwhen there's none, or it isn't one. -
The setting
keyas a Double, as Double.Parse reads it, or Null when there's none, or it isn't one. -
The setting
keyas a Double, orfallbackwhen there's none, or it isn't one. -
The setting
keyas a Bool, "True" or "False", or Null when there's none, or it's another. -
The setting
keyas a Bool, orfallbackwhen there's none, or it's another. -
Sets
keytovalue, which Save keeps. -
Sets
keyto the integer's text, which GetInt reads back. -
Sets
keyto the Double's text, the shortest that reads back as it, which GetDouble does, NaN and the infinities too. -
Sets
keyto "True" or "False", which GetBool reads back. -
Takes out the setting
key, and gives whether there was one. -
Whether there's a setting
key. -
The settings' names, in the order they were set, where one that's taken out and set again goes last, and in the file's order after a read.
-
How many settings there are.
-
Whether they've changed since they were read or saved.
-
Takes out every setting.
-
Writes the settings to their file, making its folder when it isn't there, atomically, so it holds either all of them or what it held before.
-
Save's Async twin. A change made while it writes isn't in the file, so IsChanged stays True.
Report an issue with this page or with FutureBlitz on GitHub.