Table of Contents

Class ConfigurationManager

Namespace
Terminal.Gui.Configuration
Assembly
Terminal.Gui.dll

Provides settings and configuration management for Terminal.Gui applications. See the Configuration Deep Dive for more information: https://gui-cs.github.io/Terminal.GuiV2Docs/docs/config.html.

Users can set Terminal.Gui settings on a global or per-application basis by providing JSON formatted configuration files. The configuration files can be placed in at .tui folder in the user's home directory (e.g. C:/Users/username/.tui, or /usr/username/.tui), the folder where the Terminal.Gui application was launched from (e.g. ./.tui ), or as a resource within the Terminal.Gui application's main assembly.

Settings are defined in JSON format, according to this schema: https://gui-cs.github.io/Terminal.GuiV2Docs/schemas/tui-config-schema.json

Settings that will apply to all applications (global settings) reside in files named config.json. Settings that will apply to a specific Terminal.Gui application reside in files named appname.config.json, where appname is the assembly name of the application (e.g. UICatalog.config.json).

Settings are applied using the precedence defined in ConfigLocations.

Configuration Management is based on static properties decorated with the ConfigurationPropertyAttribute. Since these properties are static, changes to configuration settings are applied process-wide.

Configuration Management is disabled by default and can be enabled by setting calling Enable(ConfigLocations).

See the UICatalog example for a complete example of how to use ConfigurationManager.

public static class ConfigurationManager
Inheritance
ConfigurationManager
Inherited Members

Properties

AppName

Name of the running application. By default, this property is set to the application's assembly name.

AppSettings

Gets or sets the application-specific configuration settings (config properties with the AppSettingsScope scope.

IsEnabled

Gets whether ConfigurationManager is enabled or not. If false, only the hard coded defaults will be loaded. See Enable(ConfigLocations) and Disable(bool)

RuntimeConfig

Gets or sets the in-memory config.json. See Runtime.

Settings

The root object of Terminal.Gui configuration settings / JSON schema.

SourcesManager

Gets the Sources Manager - manages the loading of configuration sources from files and resources.

ThrowOnJsonErrors

Gets or sets whether the ConfigurationManager should throw an exception if it encounters an error on deserialization. If false (the default), the error is logged and printed to the console when Shutdown() is called.

Methods

Apply()

Applies the configuration settings to static ConfigurationPropertyAttribute properties. ConfigurationManager must be Enabled.

Disable(bool)

Disables ConfigurationManager.

Enable(ConfigLocations)

Enables ConfigurationManager. If locations is None, ConfigurationManager will be enabled as-is; no configuration will be loaded or applied. If locations is HardCoded, ConfigurationManager will be enabled and reset to hard-coded defaults. For any other value, ConfigurationManager will be enabled and the configuration will be loaded from the specified locations and applied.

GetEmptyConfig()

Returns an empty Json document with just the $schema tag.

GetHardCodedConfig()

Returns a Json document containing the hard-coded config.

Load(ConfigLocations)

Loads all settings found in locations. Use Apply() to cause the loaded settings to be applied to the running application.

OnUpdated()

Called when the configuration has been updated from a configuration file or reset. Invokes the Updated event.

PrintJsonErrors()

Prints any Json deserialization errors that occurred during deserialization to the console.

Events

Applied

Event fired when an updated configuration has been applied to the application.

Updated

Event fired when the configuration has been updated from a configuration source or reset.