Module SILE.settings
core settings instance
Class settings
settings:pushState() | Stash the current values of all settings in a stack to be returned to later |
settings:popState() | Return the most recently pushed set of values in the setting stack |
settings:declare(specs) | Declare a new setting |
settings:reset() | Reset all settings to their registered default values. |
settings:toplevelState() | Restore all settings to the value they had in the top-level state, that is at the tap of the settings stack (normally the document level). |
settings:get(parameter) | Get the value of a setting |
settings:set(parameter, value[, makedefault=false[, reset=false]]) | Set the value of a setting |
settings:registerHook(parameter, func) | Register a callback hook to be run when a setting changes. |
settings:runHooks(parameter, value) | Trigger execution of callback hooks for a given setting. |
settings:temporarily(func) | Isolate a block of processing so that setting changes made during the block don't last past the block. |
settings:wrap() | Create a settings wrapper function that applies current settings to later content processing. |
Class settings
- settings:pushState()
- Stash the current values of all settings in a stack to be returned to later
- settings:popState()
- Return the most recently pushed set of values in the setting stack
- settings:declare(specs)
-
Declare a new setting
Parameters:
- specs table { parameter, type, default, help, hook, ... } declaration specification
- settings:reset()
- Reset all settings to their registered default values.
- settings:toplevelState()
- Restore all settings to the value they had in the top-level state, that is at the tap of the settings stack (normally the document level).
- settings:get(parameter)
-
Get the value of a setting
Parameters:
- parameter string The full name of the setting to fetch.
Returns:
-
Value of setting
- settings:set(parameter, value[, makedefault=false[, reset=false]])
-
Set the value of a setting
Parameters:
- parameter string The full name of the setting to change.
- value The new value to change it to.
- makedefault boolean Whether to make this the new default value. (default false)
- reset boolean Whether to reset the value to the current default value. (default false)
- settings:registerHook(parameter, func)
-
Register a callback hook to be run when a setting changes.
Parameters:
- parameter string Name of the setting to add a hook to.
- func function Callback function accepting one argument (the new value).
- settings:runHooks(parameter, value)
-
Trigger execution of callback hooks for a given setting.
Parameters:
- parameter string The name of the parameter changes.
- value The new value of the setting, passed as the first argument to the hook function.
- settings:temporarily(func)
-
Isolate a block of processing so that setting changes made during the block don't last past the block.
(Under the hood this just uses
:pushState()
, the processes the function, then runs:popState()
)Parameters:
- func function A function wrapping the actions to take without affecting settings for future use.
- settings:wrap()
-
Create a settings wrapper function that applies current settings to later content processing.
Returns:
-
function
a closure function accepting one argument (content) to process using
typesetter settings as they are at the time of closure creation.